Skip to content

Commit

Permalink
Fix last update attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
kloemi committed Nov 26, 2024
1 parent f28638a commit 29c29f0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion custom_components/samsvolleyball/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def __init__(
self._lang: str = ""
self._ticker_data = None
self._match_data = None
self._changed = False

async def async_added_to_hass(self) -> None:
"""Subscribe timer events."""
Expand All @@ -103,6 +104,7 @@ async def async_added_to_hass(self) -> None:
def _update_overview(self, data):
_LOGGER.debug("Update team data for sensor %s", self._name)
self._ticker_data = data
self._changed = True
uuid_list = SamsUtils.get_uuids_by_name(data, self._name, self._league_name)
if len(uuid_list) == 0:
_LOGGER.warning(
Expand Down Expand Up @@ -146,6 +148,7 @@ def _handle_coordinator_update(self) -> None:
elif SamsUtils.is_match(data):
if self._match and SamsUtils.is_my_match(data, self._match):
self._match_data = SamsUtils.get_match_data(data)
self._changed = True
super()._handle_coordinator_update()

@property
Expand All @@ -165,6 +168,8 @@ def state(self) -> str:
@property
def extra_state_attributes(self) -> dict[str, Any]:
"""Return the state message."""
if not self._changed:
return self._attr

self._attr[ATTR_ATTRIBUTION] = ATTRIBUTION
self._attr["sport"] = VOLLEYBALL
Expand All @@ -189,7 +194,7 @@ def extra_state_attributes(self) -> dict[str, Any]:
)
except Exception as e:
_LOGGER.warning("Fill attributes - exception %s", e)

self._changed = False
return self._attr

@property
Expand Down

0 comments on commit 29c29f0

Please sign in to comment.