Skip to content

Commit

Permalink
Make HmIP-BSM a switch (only dimable devices should be lights) (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
SukramJ authored Dec 23, 2021
1 parent 89fac98 commit 2becd69
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 50 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions hahomematic/devices/entity_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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],
Expand Down
47 changes: 0 additions & 47 deletions hahomematic/devices/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down Expand Up @@ -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]:
Expand All @@ -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]),
Expand Down
3 changes: 2 additions & 1 deletion hahomematic/devices/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,15 @@ def make_ip_switch(
device,
address,
HmSwitch,
EntityDefinition.IP_LIGHT_SWITCH,
EntityDefinition.IP_SWITCH,
group_base_channels,
)


# 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]),
Expand Down

0 comments on commit 2becd69

Please sign in to comment.