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

fix weather state attributes: 'wind_gust_speed', 'apparent_temperature' #25

Merged
merged 1 commit into from
Oct 4, 2024
Merged
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
26 changes: 10 additions & 16 deletions custom_components/yandex_pogoda/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,24 +137,17 @@ async def async_added_to_hass(self) -> None:
state.attributes.get("wind_speed")
)
self._attr_native_wind_gust_speed = ws_converter(
state.attributes.get("windGust")
state.attributes.get("wind_gust_speed")
)
self._attr_native_apparent_temperature = temp_converter(
state.attributes.get("feelsLike")
state.attributes.get("apparent_temperature")
)
self._attr_wind_bearing = state.attributes.get("wind_bearing")
self._attr_entity_picture = state.attributes.get("entity_picture")
self._hourly_forecast = state.attributes.get(ATTR_FORECAST_DATA, [])

self._attr_extra_state_attributes = {
ATTR_FORECAST_DATA: self._hourly_forecast,
}
for attribute in [
ATTR_API_FEELS_LIKE_TEMPERATURE,
ATTR_API_WIND_GUST,
"yandex_condition",
"forecast_icons",
]:
self._attr_extra_state_attributes = {}
for attribute in [ATTR_API_YA_CONDITION, ATTR_API_FORECAST_ICONS]:
value = state.attributes.get(attribute)
if value is not None:
self._attr_extra_state_attributes[attribute] = value
Expand Down Expand Up @@ -185,15 +178,16 @@ def _handle_coordinator_update(self) -> None:
self._attr_native_temperature = self.coordinator.data.get(ATTR_API_TEMPERATURE)
self._attr_native_wind_speed = self.coordinator.data.get(ATTR_API_WIND_SPEED)
self._attr_wind_bearing = self.coordinator.data.get(ATTR_API_WIND_BEARING)
self._attr_native_wind_gust_speed = self.coordinator.data.get(
ATTR_API_WIND_GUST
)
self._attr_native_apparent_temperature = self.coordinator.data.get(
ATTR_API_FEELS_LIKE_TEMPERATURE
)
_LOGGER.debug(f"_handle_coordinator_update: {self._hourly_forecast=}")
self._attr_extra_state_attributes = {
ATTR_API_FEELS_LIKE_TEMPERATURE: self.coordinator.data.get(
ATTR_API_FEELS_LIKE_TEMPERATURE
),
ATTR_API_WIND_GUST: self.coordinator.data.get(ATTR_API_WIND_GUST),
ATTR_API_YA_CONDITION: self.coordinator.data.get(ATTR_API_YA_CONDITION),
ATTR_API_FORECAST_ICONS: self.coordinator.data.get(ATTR_API_FORECAST_ICONS),
ATTR_FORECAST_DATA: self.__forecast_hourly(),
}
self.async_write_ha_state()

Expand Down
Loading