Skip to content

Commit

Permalink
Fix response to RemoteControlActive events
Browse files Browse the repository at this point in the history
  • Loading branch information
ekutner committed Feb 25, 2022
1 parent 830fc65 commit 2da6dfc
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
11 changes: 11 additions & 0 deletions custom_components/home_connect_alt/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,18 @@ def pretty_enum(self, val:str) -> str:
parts = re.findall('[A-Z0-9]+[^A-Z]*', name)
return' '.join(parts)

class InteractiveEntityBase(EntityBase):
""" Base class for interactive entities (select, switch and number) """

async def async_added_to_hass(self):
await super().async_added_to_hass()
if self._key != "BSH.Common.Status.RemoteControlActive":
self._appliance.register_callback(self.async_on_update, "BSH.Common.Status.RemoteControlActive")

async def async_will_remove_from_hass(self):
await super().async_will_remove_from_hass()
if self._key != "BSH.Common.Status.RemoteControlActive":
self._appliance.deregister_callback(self.async_on_update, "BSH.Common.Status.RemoteControlActive")

class EntityManager():
""" Helper class for managing entity registration
Expand Down
2 changes: 1 addition & 1 deletion custom_components/home_connect_alt/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "home_connect_alt",
"name": "Home Connect Alt",
"version": "0.4.2",
"version": "0.4.3",
"config_flow": true,
"documentation": "https://github.com/ekutner/home-connect-hass",
"issue_tracker": "https://github.com/ekutner/home-connect-hass/issues",
Expand Down
6 changes: 3 additions & 3 deletions custom_components/home_connect_alt/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType

from .common import EntityBase, EntityManager
from .common import InteractiveEntityBase, EntityManager
from .const import DOMAIN, SPECIAL_ENTITIES


Expand Down Expand Up @@ -43,7 +43,7 @@ def remove_appliance(appliance:Appliance) -> None:
add_appliance(appliance)


class OptionNumber(EntityBase, NumberEntity):
class OptionNumber(InteractiveEntityBase, NumberEntity):
""" Class for numeric options """
@property
def device_class(self) -> str:
Expand Down Expand Up @@ -112,7 +112,7 @@ async def async_on_update(self, appliance:Appliance, key:str, value) -> None:
self.async_write_ha_state()


class SettingsNumber(EntityBase, NumberEntity):
class SettingsNumber(InteractiveEntityBase, NumberEntity):
""" Class for numeric settings """
@property
def device_class(self) -> str:
Expand Down
10 changes: 5 additions & 5 deletions custom_components/home_connect_alt/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType

from .common import EntityBase, EntityManager
from .common import InteractiveEntityBase, EntityManager
from .const import DEVICE_ICON_MAP, DOMAIN, SPECIAL_ENTITIES

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -49,7 +49,7 @@ def remove_appliance(appliance:Appliance) -> None:
for appliance in homeconnect.appliances.values():
add_appliance(appliance)

class ProgramSelect(EntityBase, SelectEntity):
class ProgramSelect(InteractiveEntityBase, SelectEntity):
""" Selection of available programs """

@property
Expand Down Expand Up @@ -110,7 +110,7 @@ async def async_on_update(self, appliance:Appliance, key:str, value) -> None:
self.async_write_ha_state()


class OptionSelect(EntityBase, SelectEntity):
class OptionSelect(InteractiveEntityBase, SelectEntity):
""" Selection of program options """
@property
def device_class(self) -> str:
Expand Down Expand Up @@ -179,7 +179,7 @@ async def async_on_update(self, appliance:Appliance, key:str, value) -> None:
self.async_write_ha_state()


class SettingsSelect(EntityBase, SelectEntity):
class SettingsSelect(InteractiveEntityBase, SelectEntity):
""" Selection of settings """
@property
def device_class(self) -> str:
Expand Down Expand Up @@ -231,7 +231,7 @@ async def async_on_update(self, appliance:Appliance, key:str, value) -> None:
self.async_write_ha_state()


class DelayedStartSelect(EntityBase, SelectEntity):
class DelayedStartSelect(InteractiveEntityBase, SelectEntity):
""" Class for delayed start select box """
def __init__(self, appliance: Appliance, key: str = None, conf: dict = None) -> None:
super().__init__(appliance, key, conf)
Expand Down
6 changes: 3 additions & 3 deletions custom_components/home_connect_alt/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType

from .common import EntityBase, EntityManager
from .common import InteractiveEntityBase, EntityManager
from .const import DOMAIN, SPECIAL_ENTITIES


Expand Down Expand Up @@ -45,7 +45,7 @@ def remove_appliance(appliance:Appliance) -> None:
add_appliance(appliance)


class OptionSwitch(EntityBase, SwitchEntity):
class OptionSwitch(InteractiveEntityBase, SwitchEntity):
""" Switch for binary options """
@property
def device_class(self) -> str:
Expand Down Expand Up @@ -99,7 +99,7 @@ async def async_on_update(self, appliance:Appliance, key:str, value) -> None:
self.async_write_ha_state()


class SettingsSwitch(EntityBase, SwitchEntity):
class SettingsSwitch(InteractiveEntityBase, SwitchEntity):
""" Switch for binary settings """
@property
def device_class(self) -> str:
Expand Down

0 comments on commit 2da6dfc

Please sign in to comment.