forked from veles_labs/pyveles
21 lines
653 B
Python
21 lines
653 B
Python
from typing import Final, Dict, Any, TypeVar, Type, Iterable
|
|
from .generic import Device
|
|
from .sensor_wired import SensorWiredIAQ, SensorWiredRHT
|
|
|
|
# links device identifiers to its class
|
|
DEVICE_IDENTIFIERS: Final[Dict[int, Device]] = {
|
|
SensorWiredIAQ.DEVICE_CODE: SensorWiredIAQ,
|
|
SensorWiredRHT.DEVICE_CODE: SensorWiredRHT,
|
|
}
|
|
|
|
T = TypeVar("T", bound=Device)
|
|
|
|
|
|
def find_devices(device_cls: Type[T], address_space: Iterable[Any], dev="/dev/rs485", baudrate=19200) -> list[T]:
|
|
"""
|
|
Look for devices in given address space
|
|
"""
|
|
return list(filter(lambda x: device_cls.probe(x,dev,baudrate), address_space))
|
|
|
|
# TODO add device args
|