Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch for Home Assistant Core 2024.5 #234

Merged
merged 2 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion custom_components/ecoflow_cloud/entities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _updated(self, data: dict[str, Any]):
self._attr_entity_registry_enabled_default = True

if self._update_value(data[self._mqtt_key]):
self.async_write_ha_state()
self.schedule_update_ha_state()

@property
def extra_state_attributes(self) -> Mapping[str, Any] | None:
Expand Down
10 changes: 5 additions & 5 deletions custom_components/ecoflow_cloud/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,19 +325,19 @@ def __check_status(self, now: datetime):
# online, updated and outdated - reconnect
self._attrs[ATTR_STATUS_RECONNECTS] = self._attrs[ATTR_STATUS_RECONNECTS] + 1
self._client.reconnect()
self.async_write_ha_state()
self.schedule_update_ha_state()

elif not self._client.is_connected(): # validate connection even for offline device
self._attrs[ATTR_STATUS_RECONNECTS] = self._attrs[ATTR_STATUS_RECONNECTS] + 1
self._client.reconnect()
self.async_write_ha_state()
self.schedule_update_ha_state()

def __params_update(self, data: dict[str, Any]):
self._attrs[ATTR_STATUS_DATA_LAST_UPDATE] = self._client.data.params_time()
if self._online == 0:
self._update_status(0)

self.async_write_ha_state()
self.schedule_update_ha_state()

def _update_status(self, data_outdated_sec):
if data_outdated_sec > self.__check_interval_sec * self.DEADLINE_PHASE:
Expand All @@ -349,7 +349,7 @@ def _update_status(self, data_outdated_sec):

self._attrs[ATTR_STATUS_LAST_UPDATE] = utcnow()
self._attrs[ATTR_STATUS_UPDATES] = self._attrs[ATTR_STATUS_UPDATES] + 1
self.async_write_ha_state()
self.schedule_update_ha_state()

@property
def extra_state_attributes(self) -> Mapping[str, Any] | None:
Expand Down Expand Up @@ -390,4 +390,4 @@ def __get_reply_update(self, data: list[dict[str, Any]]):
else:
self._attr_native_value = "offline"

self.async_write_ha_state()
self.schedule_update_ha_state()
Loading