Compare commits

...

2 Commits

Author SHA1 Message Date
Niek Schoemaker 8e8a7b12dc Change async_write_ha_state to schedule_update_ha_state in entity.py 2025-01-16 13:53:32 +01:00
Niek Schoemaker 3325bb27b9 Correctly call on_update function with hass.add_job so it runs on the correct thread 2025-01-16 13:52:48 +01:00
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
coordinator: DataUpdateCoordinator[dict[str, Any]] = DataUpdateCoordinator(
hass, _LOGGER, name=DOMAIN
)
hon.subscribe_updates(coordinator.async_set_updated_data)
hon.subscribe_updates(lambda data: hass.add_job(coordinator.async_set_updated_data, data))
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.unique_id] = {"hon": hon, "coordinator": coordinator}
+1 -1
View File
@@ -52,4 +52,4 @@ class HonEntity(CoordinatorEntity[DataUpdateCoordinator[dict[str, Any]]]):
@callback
def _handle_coordinator_update(self, update: bool = True) -> None:
if update:
self.async_write_ha_state()
self.schedule_update_ha_state()