2022-10-19 03:43:58 +02:00
|
|
|
from typing import TypeVar
|
|
|
|
from models.devices import GenericDevice, LightDevice, SwitchDevice
|
2022-11-02 12:54:59 +01:00
|
|
|
from models.groups import DeviceGroup, Room
|
2022-10-19 03:43:58 +02:00
|
|
|
|
|
|
|
|
2022-11-02 12:54:59 +01:00
|
|
|
DEVICE_TYPE = TypeVar("DEVICE_TYPE", type(GenericDevice), type(SwitchDevice), type(LightDevice), type(Room), type(DeviceGroup))
|
2022-10-19 03:43:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
def filter_devices(devices: list[GenericDevice], type: DEVICE_TYPE) -> list[DEVICE_TYPE]:
|
|
|
|
"""Filters out devices that are not of a specific type."""
|
|
|
|
return [device for device in devices if isinstance(device, DEVICE_TYPE)]
|