Skip to content

Commit 8341be0

Browse files
committed
Fix: Warm snow bug
1 parent 02be2fd commit 8341be0

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

custom_components/knmi/weather.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,14 @@ def map_condition(self, value: str | None) -> str | None:
119119
@property
120120
def condition(self) -> str | None:
121121
"""Return the current condition."""
122-
return self.map_condition(self.coordinator.get_value(["liveweer", 0, "image"]))
122+
condition = self.map_condition(
123+
self.coordinator.get_value(["liveweer", 0, "image"])
124+
)
125+
126+
if condition == ATTR_CONDITION_SNOWY and self.native_temperature > 6:
127+
condition = ATTR_CONDITION_RAINY
128+
129+
return condition
123130

124131
@property
125132
def native_temperature(self) -> float | None:

tests/fixtures/warm_snow.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"liveweer": [
3+
{
4+
"temp": 10.5,
5+
"image": "sneeuw"
6+
}
7+
]
8+
}

tests/test_weather.py

+12
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,15 @@ async def test_async_forecast_twice_daily(hass: HomeAssistant, mocked_data):
259259

260260
assert await config_entry.async_unload(hass)
261261
await hass.async_block_till_done()
262+
263+
264+
@pytest.mark.fixture("warm_snow.json")
265+
async def test_warm_snow_fix(hass: HomeAssistant, mocked_data):
266+
"""Test if we return rainy if the API returns snowy and a temp higher than 6."""
267+
config_entry = await setup_component(hass)
268+
269+
state = hass.states.get("weather.knmi_home")
270+
assert state.state == ATTR_CONDITION_RAINY
271+
272+
assert await config_entry.async_unload(hass)
273+
await hass.async_block_till_done()

0 commit comments

Comments
 (0)