Fix update entity when changing config

This commit is contained in:
Andre Basche 2024-03-30 19:47:46 +01:00
parent 510c10bd9f
commit 36aed2e6ea
5 changed files with 14 additions and 14 deletions

View file

@ -232,7 +232,7 @@ class HonACClimateEntity(HonEntity, ClimateEntity):
self._device.sync_command("startProgram", "settings") self._device.sync_command("startProgram", "settings")
self._set_temperature_bound() self._set_temperature_bound()
self._handle_coordinator_update(update=False) self._handle_coordinator_update(update=False)
self.async_write_ha_state() self.coordinator.async_set_updated_data(None)
self._attr_preset_mode = preset_mode self._attr_preset_mode = preset_mode
await self._device.commands["startProgram"].send() await self._device.commands["startProgram"].send()
self.async_write_ha_state() self.async_write_ha_state()
@ -408,7 +408,7 @@ class HonClimateEntity(HonEntity, ClimateEntity):
self._device.sync_command(command, "settings") self._device.sync_command(command, "settings")
self._set_temperature_bound() self._set_temperature_bound()
self._attr_preset_mode = preset_mode self._attr_preset_mode = preset_mode
self.async_write_ha_state() self.coordinator.async_set_updated_data(None)
await self._device.commands[command].send() await self._device.commands[command].send()
self.async_write_ha_state() self.async_write_ha_state()

View file

@ -58,7 +58,7 @@ class HonLockEntity(HonEntity, LockEntity):
setting.value = setting.max if isinstance(setting, HonParameterRange) else 1 setting.value = setting.max if isinstance(setting, HonParameterRange) else 1
self.async_write_ha_state() self.async_write_ha_state()
await self._device.commands["settings"].send() await self._device.commands["settings"].send()
self.async_write_ha_state() self.coordinator.async_set_updated_data(None)
async def async_unlock(self, **kwargs: Any) -> None: async def async_unlock(self, **kwargs: Any) -> None:
"""Unlock method.""" """Unlock method."""
@ -68,7 +68,7 @@ class HonLockEntity(HonEntity, LockEntity):
setting.value = setting.min if isinstance(setting, HonParameterRange) else 0 setting.value = setting.min if isinstance(setting, HonParameterRange) else 0
self.async_write_ha_state() self.async_write_ha_state()
await self._device.commands["settings"].send() await self._device.commands["settings"].send()
self.async_write_ha_state() self.coordinator.async_set_updated_data(None)
@property @property
def available(self) -> bool: def available(self) -> bool:

View file

@ -257,7 +257,7 @@ class HonNumberEntity(HonEntity, NumberEntity):
await self._device.commands[command].send() await self._device.commands[command].send()
if command != "settings": if command != "settings":
self._device.sync_command(command, "settings") self._device.sync_command(command, "settings")
self.async_write_ha_state() self.coordinator.async_set_updated_data(None)
@callback @callback
def _handle_coordinator_update(self, update: bool = True) -> None: def _handle_coordinator_update(self, update: bool = True) -> None:
@ -308,7 +308,7 @@ class HonConfigNumberEntity(HonEntity, NumberEntity):
setting = self._device.settings[self.entity_description.key] setting = self._device.settings[self.entity_description.key]
if isinstance(setting, HonParameterRange): if isinstance(setting, HonParameterRange):
setting.value = value setting.value = value
self.async_write_ha_state() self.coordinator.async_set_updated_data(None)
@property @property
def available(self) -> bool: def available(self) -> bool:

View file

@ -263,7 +263,7 @@ class HonConfigSelectEntity(HonEntity, SelectEntity):
async def async_select_option(self, option: str) -> None: async def async_select_option(self, option: str) -> None:
setting = self._device.settings[self.entity_description.key] setting = self._device.settings[self.entity_description.key]
setting.value = self._option_to_number(option, setting.values) setting.value = self._option_to_number(option, setting.values)
self.async_write_ha_state() self.coordinator.async_set_updated_data(None)
@callback @callback
def _handle_coordinator_update(self, update: bool = True) -> None: def _handle_coordinator_update(self, update: bool = True) -> None:
@ -317,7 +317,7 @@ class HonSelectEntity(HonEntity, SelectEntity):
await self._device.commands[command].send() await self._device.commands[command].send()
if command != "settings": if command != "settings":
self._device.sync_command(command, "settings") self._device.sync_command(command, "settings")
self.async_write_ha_state() self.coordinator.async_set_updated_data(None)
@property @property
def available(self) -> bool: def available(self) -> bool:

View file

@ -447,7 +447,7 @@ class HonSwitchEntity(HonEntity, SwitchEntity):
setting.value = setting.max if isinstance(setting, HonParameterRange) else 1 setting.value = setting.max if isinstance(setting, HonParameterRange) else 1
self.async_write_ha_state() self.async_write_ha_state()
await self._device.commands["settings"].send() await self._device.commands["settings"].send()
self.async_write_ha_state() self.coordinator.async_set_updated_data(None)
async def async_turn_off(self, **kwargs: Any) -> None: async def async_turn_off(self, **kwargs: Any) -> None:
setting = self._device.settings[f"settings.{self.entity_description.key}"] setting = self._device.settings[f"settings.{self.entity_description.key}"]
@ -456,7 +456,7 @@ class HonSwitchEntity(HonEntity, SwitchEntity):
setting.value = setting.min if isinstance(setting, HonParameterRange) else 0 setting.value = setting.min if isinstance(setting, HonParameterRange) else 0
self.async_write_ha_state() self.async_write_ha_state()
await self._device.commands["settings"].send() await self._device.commands["settings"].send()
self.async_write_ha_state() self.coordinator.async_set_updated_data(None)
@property @property
def available(self) -> bool: def available(self) -> bool:
@ -489,14 +489,14 @@ class HonControlSwitchEntity(HonEntity, SwitchEntity):
async def async_turn_on(self, **kwargs: Any) -> None: async def async_turn_on(self, **kwargs: Any) -> None:
self._device.sync_command(self.entity_description.turn_on_key, "settings") self._device.sync_command(self.entity_description.turn_on_key, "settings")
self.async_write_ha_state() self.coordinator.async_set_updated_data(None)
await self._device.commands[self.entity_description.turn_on_key].send() await self._device.commands[self.entity_description.turn_on_key].send()
self._device.attributes[self.entity_description.key] = True self._device.attributes[self.entity_description.key] = True
self.async_write_ha_state() self.async_write_ha_state()
async def async_turn_off(self, **kwargs: Any) -> None: async def async_turn_off(self, **kwargs: Any) -> None:
self._device.sync_command(self.entity_description.turn_off_key, "settings") self._device.sync_command(self.entity_description.turn_off_key, "settings")
self.async_write_ha_state() self.coordinator.async_set_updated_data(None)
await self._device.commands[self.entity_description.turn_off_key].send() await self._device.commands[self.entity_description.turn_off_key].send()
self._device.attributes[self.entity_description.key] = False self._device.attributes[self.entity_description.key] = False
self.async_write_ha_state() self.async_write_ha_state()
@ -541,7 +541,7 @@ class HonConfigSwitchEntity(HonEntity, SwitchEntity):
if type(setting) == HonParameter: if type(setting) == HonParameter:
return return
setting.value = setting.max if isinstance(setting, HonParameterRange) else "1" setting.value = setting.max if isinstance(setting, HonParameterRange) else "1"
self.async_write_ha_state() self.coordinator.async_set_updated_data(None)
self.async_write_ha_state() self.async_write_ha_state()
async def async_turn_off(self, **kwargs: Any) -> None: async def async_turn_off(self, **kwargs: Any) -> None:
@ -549,7 +549,7 @@ class HonConfigSwitchEntity(HonEntity, SwitchEntity):
if type(setting) == HonParameter: if type(setting) == HonParameter:
return return
setting.value = setting.min if isinstance(setting, HonParameterRange) else "0" setting.value = setting.min if isinstance(setting, HonParameterRange) else "0"
self.async_write_ha_state() self.coordinator.async_set_updated_data(None)
self.async_write_ha_state() self.async_write_ha_state()
@callback @callback