Skip to content

Commit

Permalink
Merge branch 'main' into 125-weatherget_forecasts-sensorattribute-issue
Browse files Browse the repository at this point in the history
  • Loading branch information
golles authored Mar 17, 2024
2 parents 39172a3 + 25b7489 commit 3ee5f9e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
body: |
If you like this integration, please star this repo to show your appreciation - it makes me very happy!
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 1 addition & 4 deletions custom_components/knmi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,7 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
_LOGGER.debug("Migrating from version %s", config_entry.version)

if config_entry.version == 1:
# Replace with the following line after 2024.3.
# hass.config_entries.async_update_entry(config_entry, version=2)
# See https://developers.home-assistant.io/blog/2024/02/12/async_update_entry/
config_entry.version = 2
hass.config_entries.async_update_entry(config_entry, version=2)

entity_registry = er.async_get(hass)
existing_entries = er.async_entries_for_config_entry(
Expand Down
8 changes: 7 additions & 1 deletion custom_components/knmi/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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(
Expand Down
19 changes: 12 additions & 7 deletions tests/test_weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -179,7 +184,7 @@ async def test_async_forecast_hourly(hass: HomeAssistant, mocked_data):
assert forecast[0][ATTR_FORECAST_TIME] == "2024-02-14T23: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
Expand All @@ -188,7 +193,7 @@ async def test_async_forecast_hourly(hass: HomeAssistant, mocked_data):
assert forecast[3][ATTR_FORECAST_TIME] == "2024-02-15T02: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
Expand All @@ -197,7 +202,7 @@ async def test_async_forecast_hourly(hass: HomeAssistant, mocked_data):
assert forecast[5][ATTR_FORECAST_TIME] == "2024-02-15T04: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
Expand All @@ -206,7 +211,7 @@ async def test_async_forecast_hourly(hass: HomeAssistant, mocked_data):
assert forecast[8][ATTR_FORECAST_TIME] == "2024-02-15T07: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
Expand All @@ -215,7 +220,7 @@ async def test_async_forecast_hourly(hass: HomeAssistant, mocked_data):
assert forecast[13][ATTR_FORECAST_TIME] == "2024-02-15T12: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
Expand All @@ -224,7 +229,7 @@ async def test_async_forecast_hourly(hass: HomeAssistant, mocked_data):
assert forecast[18][ATTR_FORECAST_TIME] == "2024-02-15T17: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
Expand All @@ -233,7 +238,7 @@ async def test_async_forecast_hourly(hass: HomeAssistant, mocked_data):
assert forecast[23][ATTR_FORECAST_TIME] == "2024-02-15T22: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
Expand Down

0 comments on commit 3ee5f9e

Please sign in to comment.