Skip to content

Commit

Permalink
fix: moved calls to async_write_ha_state into jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
klevytskyi committed Jan 6, 2025
1 parent 3e33e19 commit 001ac99
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions custom_components/ecoflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def __on_disconnected(self, bms_id: Optional[int]):
self._connected = False
if self._attr_available:
self._attr_available = False
self.async_write_ha_state()
self.hass.loop.call_soon_threadsafe(self.async_write_ha_state)


class EcoFlowEntity(EcoFlowBaseEntity):
Expand All @@ -259,7 +259,7 @@ async def async_added_to_hass(self):
def __updated(self, data: dict[str, Any]):
self._attr_available = True
self._on_updated(data)
self.async_write_ha_state()
self.hass.loop.call_soon_threadsafe(self.async_write_ha_state)

def _on_updated(self, data: dict[str, Any]):
pass
Expand All @@ -281,7 +281,9 @@ async def async_added_to_hass(self):
def __updated(self, data):
if not self._connected:
self._connected = True
self.async_schedule_update_ha_state(True)
self.hass.loop.call_soon_threadsafe(
self.async_schedule_update_ha_state, True
)


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
Expand Down

0 comments on commit 001ac99

Please sign in to comment.