mirror of
https://github.com/home-assistant/core
synced 2024-07-15 09:42:11 +02:00
Fix Swiss public transport initial data for attributes (#107452)
faster initial data for attributes
This commit is contained in:
parent
da8ce7bbf3
commit
3139e92696
@ -122,15 +122,25 @@ class SwissPublicTransportSensor(
|
||||
entry_type=DeviceEntryType.SERVICE,
|
||||
)
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Prepare the extra attributes at start."""
|
||||
self._async_update_attrs()
|
||||
await super().async_added_to_hass()
|
||||
|
||||
@callback
|
||||
def _handle_coordinator_update(self) -> None:
|
||||
"""Handle the state update and prepare the extra state attributes."""
|
||||
self._async_update_attrs()
|
||||
return super()._handle_coordinator_update()
|
||||
|
||||
@callback
|
||||
def _async_update_attrs(self) -> None:
|
||||
"""Update the extra state attributes based on the coordinator data."""
|
||||
self._attr_extra_state_attributes = {
|
||||
key: value
|
||||
for key, value in self.coordinator.data.items()
|
||||
if key not in {"departure"}
|
||||
}
|
||||
return super()._handle_coordinator_update()
|
||||
|
||||
@property
|
||||
def native_value(self) -> str:
|
||||
|
Loading…
Reference in New Issue
Block a user