M custom_components/ouman_eh800/climate.py => custom_components/ouman_eh800/climate.py +14 -1
@@ 12,7 12,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import OumanEH800Device
-from .const import DOMAIN
+from .const import DOMAIN, EVENT_CHANGE_L1_OPERATION_MODE
from .eh800 import OPERATION_MODES
_LOGGER = logging.getLogger(__name__)
@@ 67,6 67,18 @@ class OumanEH800DeviceClimate(ClimateEntity):
self._attr_unique_id = f"ouman_eh800_{description.key}"
self._attr_device_info = device.device_info
+ async def async_added_to_hass(self):
+ self.hass.bus.async_listen(
+ EVENT_CHANGE_L1_OPERATION_MODE, self.async_update_event_handler
+ )
+
+ async def async_update_event_handler(
+ self,
+ event, # pylint: disable=unused-argument
+ ):
+ await self.async_update()
+ self.async_write_ha_state()
+
@property
def extra_state_attributes(self) -> dict:
return self._device.device.data
@@ 131,6 143,7 @@ class OumanEH800DeviceClimate(ClimateEntity):
self.entity_description.operation_mode_key,
operation_mode.value,
)
+ self.hass.bus.async_fire(EVENT_CHANGE_L1_OPERATION_MODE)
self.async_write_ha_state()
async def async_update(self) -> None:
M custom_components/ouman_eh800/const.py => custom_components/ouman_eh800/const.py +2 -0
@@ 8,3 8,5 @@ CONF_HOST = "host"
CONF_PORT = "port"
CONF_USERNAME = "username"
CONF_PASSWORD = "password"
+
+EVENT_CHANGE_L1_OPERATION_MODE = "ouman_eh800_change_l1_operation_mode"
M custom_components/ouman_eh800/select.py => custom_components/ouman_eh800/select.py +14 -1
@@ 9,7 9,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import OumanEH800Device
-from .const import DOMAIN
+from .const import DOMAIN, EVENT_CHANGE_L1_OPERATION_MODE
from .eh800 import OPERATION_MODES
_LOGGER = logging.getLogger(__name__)
@@ 48,6 48,18 @@ class OumanEH800DeviceSelect(SelectEntity):
self._attr_unique_id = f"ouman_eh800_{description.key}"
self._attr_device_info = device.device_info
+ async def async_added_to_hass(self):
+ self.hass.bus.async_listen(
+ EVENT_CHANGE_L1_OPERATION_MODE, self.async_update_event_handler
+ )
+
+ async def async_update_event_handler(
+ self,
+ event, # pylint: disable=unused-argument
+ ):
+ await self.async_update()
+ self.async_write_ha_state()
+
@property
def current_option(self) -> str:
operation_mode = int(
@@ 70,6 82,7 @@ class OumanEH800DeviceSelect(SelectEntity):
self.entity_description.key,
operation_mode.value,
)
+ self.hass.bus.async_fire(EVENT_CHANGE_L1_OPERATION_MODE)
self.async_write_ha_state()
async def async_update(self) -> None: