From 2becd696d75ca7ac17403ff6b58bed43cda9a35e Mon Sep 17 00:00:00 2001 From: SukramJ Date: Thu, 23 Dec 2021 16:23:54 +0100 Subject: [PATCH] Make HmIP-BSM a switch (only dimable devices should be lights) (#88) --- changelog.txt | 3 ++ hahomematic/devices/entity_definition.py | 4 +- hahomematic/devices/light.py | 47 ------------------------ hahomematic/devices/switch.py | 3 +- 4 files changed, 7 insertions(+), 50 deletions(-) diff --git a/changelog.txt b/changelog.txt index eda8832f..b9bbb711 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +Version 0.3.1 (2021-12-23) +- Make HmIP-BSM a switch (only dimable devices should be lights) + Version 0.3.0 (2021-12-23) - Cleanup API, device/entity - Add ACTIVE_PROFILE to IPThermostat diff --git a/hahomematic/devices/entity_definition.py b/hahomematic/devices/entity_definition.py index 7609248a..5599330e 100644 --- a/hahomematic/devices/entity_definition.py +++ b/hahomematic/devices/entity_definition.py @@ -77,7 +77,7 @@ class EntityDefinition(Enum): IP_COVER = "IPCover" IP_DIMMER = "IPDimmer" IP_GARAGE = "IPGarage" - IP_LIGHT_SWITCH = "IPLightSwitch" + IP_SWITCH = "IPSwitch" IP_LIGHT_BSL = "IPLightBSL" IP_LOCK = "IPLock" IP_THERMOSTAT = "IPThermostat" @@ -199,7 +199,7 @@ def __str__(self) -> str: }, }, }, - EntityDefinition.IP_LIGHT_SWITCH: { + EntityDefinition.IP_SWITCH: { ED_DEVICE_GROUP: { ED_PHY_CHANNEL: [1], ED_VIRT_CHANNEL: [2, 3], diff --git a/hahomematic/devices/light.py b/hahomematic/devices/light.py index fd817103..3fcaa26d 100644 --- a/hahomematic/devices/light.py +++ b/hahomematic/devices/light.py @@ -159,43 +159,6 @@ def extra_state_attributes(self) -> dict[str, Any]: return state_attr -class HmLight(BaseHmLight): - """Class for homematic light entities.""" - - @property - def _state(self) -> bool | None: - """Return the state of the light.""" - return self._get_entity_state(FIELD_STATE) - - @property - def _channel_state(self) -> bool | None: - """Return the channel state of the light.""" - return self._get_entity_state(FIELD_CHANNEL_STATE) - - @property - def is_on(self) -> bool: - """Return true if light is on.""" - return self._state is True - - async def turn_on( - self, hs_color: tuple[float, float] | None, brightness: int | None - ) -> None: - """Turn the light on.""" - await self._send_value(FIELD_STATE, True) - - async def turn_off(self) -> None: - """Turn the light off.""" - await self._send_value(FIELD_STATE, False) - - @property - def extra_state_attributes(self) -> dict[str, Any]: - """Return the state attributes of the light.""" - state_attr = super().extra_state_attributes - if self._channel_state and self._channel_state != self._state: - state_attr[ATTR_CHANNEL_STATE] = self._channel_state - return state_attr - - class IPLightBSL(BaseHmLight): """Class for homematic HmIP-BSL light entities.""" @@ -334,15 +297,6 @@ def make_rf_dimmer( ) -def make_ip_light( - device: hm_device.HmDevice, address: str, group_base_channels: list[int] -) -> list[hm_entity.BaseEntity]: - """Creates homematic classic light entities.""" - return make_custom_entity( - device, address, HmLight, EntityDefinition.IP_LIGHT_SWITCH, group_base_channels - ) - - def make_ip_light_bsl( device: hm_device.HmDevice, address: str, group_base_channels: list[int] ) -> list[hm_entity.BaseEntity]: @@ -356,7 +310,6 @@ def make_ip_light_bsl( # device_type and sub_type(IP-only) can be used here DEVICES: dict[str, tuple[Any, list[int]]] = { "HmIP-BSL": (make_ip_light_bsl, [7, 11]), - "HmIP-BSM": (make_ip_light, [3]), "HmIP-BDT": (make_ip_dimmer, [3]), "HmIP-FDT": (make_ip_dimmer, [1]), "HmIP-PDT*": (make_ip_dimmer, [2]), diff --git a/hahomematic/devices/switch.py b/hahomematic/devices/switch.py index 2480fe21..ba5e85f3 100644 --- a/hahomematic/devices/switch.py +++ b/hahomematic/devices/switch.py @@ -90,7 +90,7 @@ def make_ip_switch( device, address, HmSwitch, - EntityDefinition.IP_LIGHT_SWITCH, + EntityDefinition.IP_SWITCH, group_base_channels, ) @@ -98,6 +98,7 @@ def make_ip_switch( # Case for device model is not relevant # device_type and sub_type(IP-only) can be used here DEVICES: dict[str, tuple[Any, list[int]]] = { + "HmIP-BSM": (make_ip_switch, [3]), "HmIP-FSM*": (make_ip_switch, [1]), "HmIP-FSI*": (make_ip_switch, [2]), "HmIP-PS*": (make_ip_switch, [2]),