diff --git a/README.md b/README.md index b57e964..b7a5dfd 100644 --- a/README.md +++ b/README.md @@ -109,16 +109,16 @@ Daily forecast attributes: Hourly forecast attributes: -| Attribute | Notes | -| ------------------------- | ------------------------------------------------------------- | -| datetime | Times in UTC, frontend will convert this into your local time | -| condition | | -| temperature | | -| precipitation_probability | in millimeters | -| wind_bearing | | -| wind_speed | | -| wind_speed_bft | Not officially supported, but nice addition | -| solar_irradiance | Not officially supported, but nice addition | +| Attribute | Notes | +| ---------------- | ------------------------------------------------------------- | +| datetime | Times in UTC, frontend will convert this into your local time | +| condition | | +| temperature | | +| precipitation | in millimeters | +| wind_bearing | | +| wind_speed | | +| wind_speed_bft | Not officially supported, but nice addition | +| solar_irradiance | Not officially supported, but nice addition | ## Examples diff --git a/custom_components/knmi/weather.py b/custom_components/knmi/weather.py index 9ac763e..c9665ac 100644 --- a/custom_components/knmi/weather.py +++ b/custom_components/knmi/weather.py @@ -14,6 +14,7 @@ ATTR_CONDITION_SNOWY, ATTR_CONDITION_SUNNY, ATTR_FORECAST_CONDITION, + ATTR_FORECAST_PRECIPITATION, ATTR_FORECAST_PRECIPITATION_PROBABILITY, ATTR_FORECAST_TEMP, ATTR_FORECAST_TEMP_LOW, @@ -125,6 +126,11 @@ def native_temperature(self) -> float | None: """Return the temperature in native units.""" return self.coordinator.get_value(["liveweer", 0, "temp"]) + @property + def native_apparent_temperature(self) -> float | None: + """Return the apparent temperature in native units.""" + return self.coordinator.get_value(["liveweer", 0, "gtemp"]) + @property def native_dew_point(self) -> float | None: """Return the dew point temperature in native units.""" @@ -205,7 +211,7 @@ async def async_forecast_hourly(self) -> list[Forecast] | None: self.coordinator.get_value(["uur_verw", i, "image"]) ), ATTR_FORECAST_TEMP: self.coordinator.get_value(["uur_verw", i, "temp"]), - ATTR_FORECAST_PRECIPITATION_PROBABILITY: self.coordinator.get_value( + ATTR_FORECAST_PRECIPITATION: self.coordinator.get_value( ["uur_verw", i, "neersl"] # Millimeter. ), ATTR_FORECAST_WIND_BEARING: self.coordinator.get_value( diff --git a/tests/test_weather.py b/tests/test_weather.py index 17daa8e..3ee6351 100644 --- a/tests/test_weather.py +++ b/tests/test_weather.py @@ -14,12 +14,14 @@ ATTR_CONDITION_SNOWY, ATTR_CONDITION_SUNNY, ATTR_FORECAST_CONDITION, + ATTR_FORECAST_PRECIPITATION, ATTR_FORECAST_PRECIPITATION_PROBABILITY, ATTR_FORECAST_TEMP, ATTR_FORECAST_TEMP_LOW, ATTR_FORECAST_TIME, ATTR_FORECAST_WIND_BEARING, ATTR_FORECAST_WIND_SPEED, + ATTR_WEATHER_APPARENT_TEMPERATURE, ATTR_WEATHER_DEW_POINT, ATTR_WEATHER_HUMIDITY, ATTR_WEATHER_PRESSURE, @@ -97,6 +99,9 @@ async def test_state(hass: HomeAssistant, mocked_data): assert Decimal(state.attributes.get(ATTR_WEATHER_WIND_BEARING)) == 226 assert Decimal(state.attributes.get(ATTR_WEATHER_WIND_SPEED)) == Decimal(29.1) assert Decimal(state.attributes.get(ATTR_WEATHER_DEW_POINT)) == Decimal(10.1) + assert Decimal(state.attributes.get(ATTR_WEATHER_APPARENT_TEMPERATURE)) == Decimal( + 6.8 + ) assert await config_entry.async_unload(hass) await hass.async_block_till_done() @@ -179,7 +184,7 @@ async def test_async_forecast_hourly(hass: HomeAssistant, mocked_data): assert str(forecast[0][ATTR_FORECAST_TIME]) == "2024-02-14 23:00:00+01:00" assert forecast[0][ATTR_FORECAST_CONDITION] == "cloudy" assert forecast[0][ATTR_FORECAST_TEMP] == 10 - assert forecast[0][ATTR_FORECAST_PRECIPITATION_PROBABILITY] == 0 + assert forecast[0][ATTR_FORECAST_PRECIPITATION] == 0 assert forecast[0][ATTR_FORECAST_WIND_BEARING] == 231 assert forecast[0][ATTR_FORECAST_WIND_SPEED] == 21 assert forecast[0]["wind_speed_bft"] == 4 @@ -188,7 +193,7 @@ async def test_async_forecast_hourly(hass: HomeAssistant, mocked_data): assert str(forecast[3][ATTR_FORECAST_TIME]) == "2024-02-15 02:00:00+01:00" assert forecast[3][ATTR_FORECAST_CONDITION] == "cloudy" assert forecast[3][ATTR_FORECAST_TEMP] == 10 - assert forecast[3][ATTR_FORECAST_PRECIPITATION_PROBABILITY] == 0 + assert forecast[3][ATTR_FORECAST_PRECIPITATION] == 0 assert forecast[3][ATTR_FORECAST_WIND_BEARING] == 226 assert forecast[3][ATTR_FORECAST_WIND_SPEED] == 18 assert forecast[3]["wind_speed_bft"] == 3 @@ -197,7 +202,7 @@ async def test_async_forecast_hourly(hass: HomeAssistant, mocked_data): assert str(forecast[5][ATTR_FORECAST_TIME]) == "2024-02-15 04:00:00+01:00" assert forecast[5][ATTR_FORECAST_CONDITION] == "cloudy" assert forecast[5][ATTR_FORECAST_TEMP] == 10 - assert forecast[5][ATTR_FORECAST_PRECIPITATION_PROBABILITY] == 0 + assert forecast[5][ATTR_FORECAST_PRECIPITATION] == 0 assert forecast[5][ATTR_FORECAST_WIND_BEARING] == 219 assert forecast[5][ATTR_FORECAST_WIND_SPEED] == 18 assert forecast[5]["wind_speed_bft"] == 3 @@ -206,7 +211,7 @@ async def test_async_forecast_hourly(hass: HomeAssistant, mocked_data): assert str(forecast[8][ATTR_FORECAST_TIME]) == "2024-02-15 07:00:00+01:00" assert forecast[8][ATTR_FORECAST_CONDITION] == "pouring" assert forecast[8][ATTR_FORECAST_TEMP] == 10 - assert Decimal(forecast[8][ATTR_FORECAST_PRECIPITATION_PROBABILITY]) == Decimal(0.9) + assert Decimal(forecast[8][ATTR_FORECAST_PRECIPITATION]) == Decimal(0.9) assert forecast[8][ATTR_FORECAST_WIND_BEARING] == 196 assert forecast[8][ATTR_FORECAST_WIND_SPEED] == 14 assert forecast[8]["wind_speed_bft"] == 3 @@ -215,7 +220,7 @@ async def test_async_forecast_hourly(hass: HomeAssistant, mocked_data): assert str(forecast[13][ATTR_FORECAST_TIME]) == "2024-02-15 12:00:00+01:00" assert forecast[13][ATTR_FORECAST_CONDITION] == "cloudy" assert forecast[13][ATTR_FORECAST_TEMP] == 12 - assert forecast[13][ATTR_FORECAST_PRECIPITATION_PROBABILITY] == 0 + assert forecast[13][ATTR_FORECAST_PRECIPITATION] == 0 assert forecast[13][ATTR_FORECAST_WIND_BEARING] == 206 assert forecast[13][ATTR_FORECAST_WIND_SPEED] == 14 assert forecast[13]["wind_speed_bft"] == 3 @@ -224,7 +229,7 @@ async def test_async_forecast_hourly(hass: HomeAssistant, mocked_data): assert str(forecast[18][ATTR_FORECAST_TIME]) == "2024-02-15 17:00:00+01:00" assert forecast[18][ATTR_FORECAST_CONDITION] == "cloudy" assert forecast[18][ATTR_FORECAST_TEMP] == 14 - assert forecast[18][ATTR_FORECAST_PRECIPITATION_PROBABILITY] == 0 + assert forecast[18][ATTR_FORECAST_PRECIPITATION] == 0 assert forecast[18][ATTR_FORECAST_WIND_BEARING] == 168 assert forecast[18][ATTR_FORECAST_WIND_SPEED] == 14 assert forecast[18]["wind_speed_bft"] == 3 @@ -233,7 +238,7 @@ async def test_async_forecast_hourly(hass: HomeAssistant, mocked_data): assert str(forecast[23][ATTR_FORECAST_TIME]) == "2024-02-15 22:00:00+01:00" assert forecast[23][ATTR_FORECAST_CONDITION] == "cloudy" assert forecast[23][ATTR_FORECAST_TEMP] == 12 - assert forecast[23][ATTR_FORECAST_PRECIPITATION_PROBABILITY] == 0 + assert forecast[23][ATTR_FORECAST_PRECIPITATION] == 0 assert forecast[23][ATTR_FORECAST_WIND_BEARING] == 162 assert forecast[23][ATTR_FORECAST_WIND_SPEED] == 18 assert forecast[23]["wind_speed_bft"] == 3