diff --git a/src/aiovantage/command_client/events.py b/src/aiovantage/command_client/events.py index d926a8e5..ffb1ade4 100644 --- a/src/aiovantage/command_client/events.py +++ b/src/aiovantage/command_client/events.py @@ -3,7 +3,7 @@ import asyncio import logging from collections import defaultdict -from collections.abc import Callable, Coroutine, Iterable, Sequence +from collections.abc import Awaitable, Callable, Iterable, Sequence from contextlib import suppress from enum import Enum from inspect import iscoroutinefunction @@ -71,7 +71,7 @@ class EnhancedLogEvent(TypedDict): Event = ConnectEvent | DisconnectEvent | ReconnectEvent | StatusEvent | EnhancedLogEvent # Type aliases for callbacks for event subscriptions -EventCallback = Callable[[Event], Coroutine | None] +EventCallback = Callable[[Event], Awaitable[None] | None] EventFilter = Callable[[Event], bool] EventSubscription = tuple[EventCallback, EventFilter | None] @@ -181,7 +181,7 @@ def subscribe( if isinstance(event_filter, EventType): subscription = (callback, lambda event: event["type"] == event_filter) elif isinstance(event_filter, Iterable): - subscription = (callback, lambda event: event["type"] in event_filter) # type: ignore[operator] + subscription = (callback, lambda event: event["type"] in event_filter) else: subscription = (callback, event_filter) diff --git a/src/aiovantage/config_client/models/__init__.py b/src/aiovantage/config_client/models/__init__.py index e5ab0ce9..5e2c3289 100644 --- a/src/aiovantage/config_client/models/__init__.py +++ b/src/aiovantage/config_client/models/__init__.py @@ -8,19 +8,26 @@ from .blind_group_base import BlindGroupBase from .button import Button from .child_device import ChildDevice +from .contact_input import ContactInput from .custom_device import CustomDevice from .dc_power_profile import DCPowerProfile from .dimmer import Dimmer +from .din_contact_input import DINContactInput +from .din_high_voltage_relay_station import DINHighVoltageRelayStation +from .din_low_voltage_relay_station import DINLowVoltageRelayStation +from .din_station import DINStation from .dry_contact import DryContact from .dual_relay_station import DualRelayStation from .eq_ctrl import EqCtrl from .eq_ux import EqUX from .gmem import GMem +from .high_voltage_relay_station import HighVoltageRelayStation from .keypad import Keypad from .light_sensor import LightSensor from .load import Load from .load_group import LoadGroup from .location_object import LocationObject +from .low_voltage_relay_station import LowVoltageRelayStation from .master import Master from .module import Module from .module_gen2 import ModuleGen2 @@ -33,6 +40,8 @@ from .qube_blind import QubeBlind from .relay_blind import RelayBlind from .rgb_load_base import RGBLoadBase +from .rs232_station import RS232Station +from .rs485_station import RS485Station from .scene_point_relay import ScenePointRelay from .sensor import Sensor from .somfy_rs_485_group_child import SomfyRS485GroupChild @@ -62,19 +71,26 @@ "BlindGroupBase", "Button", "ChildDevice", + "ContactInput", "CustomDevice", "DCPowerProfile", "Dimmer", + "DINContactInput", + "DINHighVoltageRelayStation", + "DINLowVoltageRelayStation", + "DINStation", "DryContact", "DualRelayStation", "EqCtrl", "EqUX", "GMem", + "HighVoltageRelayStation", "Keypad", "LightSensor", "Load", "LoadGroup", "LocationObject", + "LowVoltageRelayStation", "Master", "Module", "ModuleGen2", @@ -88,6 +104,8 @@ "QubeBlind", "RelayBlind", "RGBLoadBase", + "RS232Station", + "RS485Station", "ScenePointRelay", "Sensor", "SomfyRS485GroupChild", diff --git a/src/aiovantage/config_client/models/contact_input.py b/src/aiovantage/config_client/models/contact_input.py new file mode 100644 index 00000000..7ee655a6 --- /dev/null +++ b/src/aiovantage/config_client/models/contact_input.py @@ -0,0 +1,10 @@ +"""Contact Input.""" + +from dataclasses import dataclass + +from .station_object import StationObject + + +@dataclass +class ContactInput(StationObject): + """Contact Input.""" diff --git a/src/aiovantage/config_client/models/din_contact_input.py b/src/aiovantage/config_client/models/din_contact_input.py new file mode 100644 index 00000000..c435106e --- /dev/null +++ b/src/aiovantage/config_client/models/din_contact_input.py @@ -0,0 +1,10 @@ +"""DIN Contact Input Station.""" + +from dataclasses import dataclass + +from .din_station import DINStation + + +@dataclass +class DINContactInput(DINStation): + """DIN Contact Input Station.""" diff --git a/src/aiovantage/config_client/models/din_high_voltage_relay_station.py b/src/aiovantage/config_client/models/din_high_voltage_relay_station.py new file mode 100644 index 00000000..19a54290 --- /dev/null +++ b/src/aiovantage/config_client/models/din_high_voltage_relay_station.py @@ -0,0 +1,10 @@ +"""DIN High Voltage Relay Station.""" + +from dataclasses import dataclass + +from .din_station import DINStation + + +@dataclass +class DINHighVoltageRelayStation(DINStation): + """DIN High Voltage Relay Station.""" diff --git a/src/aiovantage/config_client/models/din_low_voltage_relay_station.py b/src/aiovantage/config_client/models/din_low_voltage_relay_station.py new file mode 100644 index 00000000..04ff045c --- /dev/null +++ b/src/aiovantage/config_client/models/din_low_voltage_relay_station.py @@ -0,0 +1,10 @@ +"""DIN Low Voltage Relay Station.""" + +from dataclasses import dataclass + +from .din_station import DINStation + + +@dataclass +class DINLowVoltageRelayStation(DINStation): + """DIN Low Voltage Relay Station.""" diff --git a/src/aiovantage/config_client/models/din_station.py b/src/aiovantage/config_client/models/din_station.py new file mode 100644 index 00000000..4b7204e7 --- /dev/null +++ b/src/aiovantage/config_client/models/din_station.py @@ -0,0 +1,10 @@ +"""Base class for DIN station objects.""" + +from dataclasses import dataclass + +from .station_object import StationObject + + +@dataclass +class DINStation(StationObject): + """Base class for DIN station objects.""" diff --git a/src/aiovantage/config_client/models/high_voltage_relay_station.py b/src/aiovantage/config_client/models/high_voltage_relay_station.py new file mode 100644 index 00000000..83a8c3ee --- /dev/null +++ b/src/aiovantage/config_client/models/high_voltage_relay_station.py @@ -0,0 +1,10 @@ +"""High Voltage Relay Station.""" + +from dataclasses import dataclass + +from .station_object import StationObject + + +@dataclass +class HighVoltageRelayStation(StationObject): + """High Voltage Relay Station.""" diff --git a/src/aiovantage/config_client/models/low_voltage_relay_station.py b/src/aiovantage/config_client/models/low_voltage_relay_station.py new file mode 100644 index 00000000..096b03b4 --- /dev/null +++ b/src/aiovantage/config_client/models/low_voltage_relay_station.py @@ -0,0 +1,10 @@ +"""Low Voltage Relay Station.""" + +from dataclasses import dataclass + +from .station_object import StationObject + + +@dataclass +class LowVoltageRelayStation(StationObject): + """Low Voltage Relay Station.""" diff --git a/src/aiovantage/config_client/models/rs232_station.py b/src/aiovantage/config_client/models/rs232_station.py new file mode 100644 index 00000000..8871cd79 --- /dev/null +++ b/src/aiovantage/config_client/models/rs232_station.py @@ -0,0 +1,10 @@ +"""RS-232 Station.""" + +from dataclasses import dataclass + +from .station_object import StationObject + + +@dataclass +class RS232Station(StationObject): + """RS-232 Station.""" diff --git a/src/aiovantage/config_client/models/rs485_station.py b/src/aiovantage/config_client/models/rs485_station.py new file mode 100644 index 00000000..7e9b7171 --- /dev/null +++ b/src/aiovantage/config_client/models/rs485_station.py @@ -0,0 +1,10 @@ +"""RS-485 Station.""" + +from dataclasses import dataclass + +from .station_object import StationObject + + +@dataclass +class RS485Station(StationObject): + """RS-485 Station.""" diff --git a/src/aiovantage/controllers/stations.py b/src/aiovantage/controllers/stations.py index 8885abea..bba911e5 100644 --- a/src/aiovantage/controllers/stations.py +++ b/src/aiovantage/controllers/stations.py @@ -13,11 +13,19 @@ class StationsController(BaseController[StationObject]): """ vantage_types = ( + "ContactInput", "Dimmer", + "DINContactInput", + "DINHighVoltageRelayStation", + "DINLowVoltageRelayStation", "DualRelayStation", "EqCtrl", "EqUX", + "HighVoltageRelayStation", "Keypad", + "LowVoltageRelayStation", + "RS232Station", + "RS485Station", "ScenePointRelay", "Vantage.DmxDaliGateway", ) diff --git a/src/aiovantage/query.py b/src/aiovantage/query.py index 623649e6..f9f8d2fb 100644 --- a/src/aiovantage/query.py +++ b/src/aiovantage/query.py @@ -92,7 +92,7 @@ def filter(self, *args: Any, **kwargs: Any) -> "QuerySet[T]": return queryset @overload - def get(self, key: int, default: T | None = None) -> T | None: ... + def get(self, key: int) -> T | None: ... @overload def get(self, match: Callable[[T], Any]) -> T | None: ... @@ -104,13 +104,13 @@ def get(self, *args: Any, **kwargs: Any) -> T | None: """Get the first object that matches the given filter.""" # Handle the case where we're getting an object by key if len(args) == 1 and isinstance(args[0], int): - return self.__data.get(args[0], kwargs.get("default", None)) + return self.__data.get(args[0], None) # Otherwise, pass through to filter and return the first object return next(iter(self.filter(*args, **kwargs)), None) @overload - async def aget(self, key: int, default: T | None = None) -> T | None: ... + async def aget(self, key: int) -> T | None: ... @overload async def aget(self, match: Callable[[T], Any]) -> T | None: ...