Update Stookwijzer diagnostics and description (#141041)

Update diagnostics and description
This commit is contained in:
fwestenberg 2025-03-21 11:20:15 +01:00 committed by GitHub
parent 3101d9099b
commit 1fafe81d20
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 55 additions and 1 deletions

View File

@ -18,4 +18,5 @@ async def async_get_config_entry_diagnostics(
"advice": client.advice,
"air_quality_index": client.lki,
"windspeed_ms": client.windspeed_ms,
"forecast": await client.async_get_forecast(),
}

View File

@ -29,7 +29,7 @@
},
"issues": {
"location_migration_failed": {
"description": "The Stookwijzer integration was unable to automatically migrate your location to a new format the updated integrations uses.\n\nMake sure you are connected to the internet and restart Home Assistant to try again.\n\nIf this doesn't resolve the error, remove and re-add the integration.",
"description": "The Stookwijzer integration was unable to automatically migrate your location to a new format the updated integration uses.\n\nMake sure you are connected to the Internet and restart Home Assistant to try again.\n\nIf this doesn't resolve the error, remove and re-add the integration.",
"title": "Migration of your location failed"
}
},

View File

@ -1,6 +1,7 @@
"""Fixtures for Stookwijzer integration tests."""
from collections.abc import Generator
from typing import Required, TypedDict
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
@ -12,6 +13,14 @@ from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry
class Forecast(TypedDict):
"""Typed Stookwijzer forecast dict."""
datetime: Required[str]
advice: str | None
final: bool | None
@pytest.fixture
def mock_config_entry() -> MockConfigEntry:
"""Return the default mocked config entry."""
@ -80,6 +89,28 @@ def mock_stookwijzer() -> Generator[MagicMock]:
client.windspeed_ms = 2.5
client.windspeed_bft = 2
client.advice = "code_yellow"
client.async_get_forecast.return_value = (
Forecast(
datetime="2025-02-12T17:00:00+01:00",
advice="code_yellow",
final=True,
),
Forecast(
datetime="2025-02-12T23:00:00+01:00",
advice="code_yellow",
final=True,
),
Forecast(
datetime="2025-02-13T05:00:00+01:00",
advice="code_orange",
final=False,
),
Forecast(
datetime="2025-02-13T11:00:00+01:00",
advice="code_orange",
final=False,
),
)
yield stookwijzer_mock

View File

@ -3,6 +3,28 @@
dict({
'advice': 'code_yellow',
'air_quality_index': 2,
'forecast': list([
dict({
'advice': 'code_yellow',
'datetime': '2025-02-12T17:00:00+01:00',
'final': True,
}),
dict({
'advice': 'code_yellow',
'datetime': '2025-02-12T23:00:00+01:00',
'final': True,
}),
dict({
'advice': 'code_orange',
'datetime': '2025-02-13T05:00:00+01:00',
'final': False,
}),
dict({
'advice': 'code_orange',
'datetime': '2025-02-13T11:00:00+01:00',
'final': False,
}),
]),
'windspeed_ms': 2.5,
})
# ---