diff --git a/homeassistant/components/nina/__init__.py b/homeassistant/components/nina/__init__.py index c8756b1b49d..0555f175cfb 100644 --- a/homeassistant/components/nina/__init__.py +++ b/homeassistant/components/nina/__init__.py @@ -57,6 +57,7 @@ class NinaWarningData: description: str sender: str severity: str + recommended_actions: str sent: str start: str expires: str @@ -134,6 +135,7 @@ class NINADataUpdateCoordinator( raw_warn.description, raw_warn.sender, raw_warn.severity, + " ".join([str(action) for action in raw_warn.recommended_actions]), raw_warn.sent or "", raw_warn.start or "", raw_warn.expires or "", diff --git a/homeassistant/components/nina/binary_sensor.py b/homeassistant/components/nina/binary_sensor.py index bdc79c34d92..24d6d35d0e8 100644 --- a/homeassistant/components/nina/binary_sensor.py +++ b/homeassistant/components/nina/binary_sensor.py @@ -18,6 +18,7 @@ from .const import ( ATTR_EXPIRES, ATTR_HEADLINE, ATTR_ID, + ATTR_RECOMMENDED_ACTIONS, ATTR_SENDER, ATTR_SENT, ATTR_SEVERITY, @@ -92,6 +93,7 @@ class NINAMessage(CoordinatorEntity[NINADataUpdateCoordinator], BinarySensorEnti ATTR_DESCRIPTION: data.description, ATTR_SENDER: data.sender, ATTR_SEVERITY: data.severity, + ATTR_RECOMMENDED_ACTIONS: data.recommended_actions, ATTR_ID: data.id, ATTR_SENT: data.sent, ATTR_START: data.start, diff --git a/homeassistant/components/nina/const.py b/homeassistant/components/nina/const.py index 76881501894..8ba7c5ffaa6 100644 --- a/homeassistant/components/nina/const.py +++ b/homeassistant/components/nina/const.py @@ -19,6 +19,7 @@ ATTR_HEADLINE: str = "headline" ATTR_DESCRIPTION: str = "description" ATTR_SENDER: str = "sender" ATTR_SEVERITY: str = "severity" +ATTR_RECOMMENDED_ACTIONS: str = "recommended_actions" ATTR_ID: str = "id" ATTR_SENT: str = "sent" ATTR_START: str = "start" diff --git a/tests/components/nina/fixtures/sample_warning_details.json b/tests/components/nina/fixtures/sample_warning_details.json index 691fa44de7e..612885e9aba 100644 --- a/tests/components/nina/fixtures/sample_warning_details.json +++ b/tests/components/nina/fixtures/sample_warning_details.json @@ -43,7 +43,7 @@ }, { "valueName": "instructionCode", - "value": "BBK-ISC-132" + "value": "BBK-ISC-082" }, { "valueName": "sender_langname", diff --git a/tests/components/nina/test_binary_sensor.py b/tests/components/nina/test_binary_sensor.py index 210ebc66a60..855b733ef46 100644 --- a/tests/components/nina/test_binary_sensor.py +++ b/tests/components/nina/test_binary_sensor.py @@ -10,6 +10,7 @@ from homeassistant.components.nina.const import ( ATTR_EXPIRES, ATTR_HEADLINE, ATTR_ID, + ATTR_RECOMMENDED_ACTIONS, ATTR_SENDER, ATTR_SENT, ATTR_SEVERITY, @@ -69,6 +70,7 @@ async def test_sensors(hass: HomeAssistant) -> None: ) assert state_w1.attributes.get(ATTR_SENDER) == "Deutscher Wetterdienst" assert state_w1.attributes.get(ATTR_SEVERITY) == "Minor" + assert state_w1.attributes.get(ATTR_RECOMMENDED_ACTIONS) == "" assert state_w1.attributes.get(ATTR_ID) == "mow.DE-NW-BN-SE030-20201014-30-000" assert state_w1.attributes.get(ATTR_SENT) == "2021-10-11T05:20:00+01:00" assert state_w1.attributes.get(ATTR_START) == "2021-11-01T05:20:00+01:00" @@ -85,6 +87,7 @@ async def test_sensors(hass: HomeAssistant) -> None: assert state_w2.attributes.get(ATTR_DESCRIPTION) is None assert state_w2.attributes.get(ATTR_SENDER) is None assert state_w2.attributes.get(ATTR_SEVERITY) is None + assert state_w2.attributes.get(ATTR_RECOMMENDED_ACTIONS) is None assert state_w2.attributes.get(ATTR_ID) is None assert state_w2.attributes.get(ATTR_SENT) is None assert state_w2.attributes.get(ATTR_START) is None @@ -101,6 +104,7 @@ async def test_sensors(hass: HomeAssistant) -> None: assert state_w3.attributes.get(ATTR_DESCRIPTION) is None assert state_w3.attributes.get(ATTR_SENDER) is None assert state_w3.attributes.get(ATTR_SEVERITY) is None + assert state_w3.attributes.get(ATTR_RECOMMENDED_ACTIONS) is None assert state_w3.attributes.get(ATTR_ID) is None assert state_w3.attributes.get(ATTR_SENT) is None assert state_w3.attributes.get(ATTR_START) is None @@ -117,6 +121,7 @@ async def test_sensors(hass: HomeAssistant) -> None: assert state_w4.attributes.get(ATTR_DESCRIPTION) is None assert state_w4.attributes.get(ATTR_SENDER) is None assert state_w4.attributes.get(ATTR_SEVERITY) is None + assert state_w4.attributes.get(ATTR_RECOMMENDED_ACTIONS) is None assert state_w4.attributes.get(ATTR_ID) is None assert state_w4.attributes.get(ATTR_SENT) is None assert state_w4.attributes.get(ATTR_START) is None @@ -133,6 +138,7 @@ async def test_sensors(hass: HomeAssistant) -> None: assert state_w5.attributes.get(ATTR_DESCRIPTION) is None assert state_w5.attributes.get(ATTR_SENDER) is None assert state_w5.attributes.get(ATTR_SEVERITY) is None + assert state_w5.attributes.get(ATTR_RECOMMENDED_ACTIONS) is None assert state_w5.attributes.get(ATTR_ID) is None assert state_w5.attributes.get(ATTR_SENT) is None assert state_w5.attributes.get(ATTR_START) is None @@ -176,6 +182,10 @@ async def test_sensors_without_corona_filter(hass: HomeAssistant) -> None: ) assert state_w1.attributes.get(ATTR_SENDER) == "" assert state_w1.attributes.get(ATTR_SEVERITY) == "Minor" + assert ( + state_w1.attributes.get(ATTR_RECOMMENDED_ACTIONS) + == "Es besteht keine Gefahr." + ) assert state_w1.attributes.get(ATTR_ID) == "mow.DE-BW-S-SE018-20211102-18-001" assert state_w1.attributes.get(ATTR_SENT) == "2021-11-02T20:07:16+01:00" assert state_w1.attributes.get(ATTR_START) == "" @@ -195,6 +205,7 @@ async def test_sensors_without_corona_filter(hass: HomeAssistant) -> None: ) assert state_w2.attributes.get(ATTR_SENDER) == "Deutscher Wetterdienst" assert state_w2.attributes.get(ATTR_SEVERITY) == "Minor" + assert state_w2.attributes.get(ATTR_RECOMMENDED_ACTIONS) == "" assert state_w2.attributes.get(ATTR_ID) == "mow.DE-NW-BN-SE030-20201014-30-000" assert state_w2.attributes.get(ATTR_SENT) == "2021-10-11T05:20:00+01:00" assert state_w2.attributes.get(ATTR_START) == "2021-11-01T05:20:00+01:00" @@ -211,6 +222,7 @@ async def test_sensors_without_corona_filter(hass: HomeAssistant) -> None: assert state_w3.attributes.get(ATTR_DESCRIPTION) is None assert state_w3.attributes.get(ATTR_SENDER) is None assert state_w3.attributes.get(ATTR_SEVERITY) is None + assert state_w3.attributes.get(ATTR_RECOMMENDED_ACTIONS) is None assert state_w3.attributes.get(ATTR_ID) is None assert state_w3.attributes.get(ATTR_SENT) is None assert state_w3.attributes.get(ATTR_START) is None @@ -227,6 +239,7 @@ async def test_sensors_without_corona_filter(hass: HomeAssistant) -> None: assert state_w4.attributes.get(ATTR_DESCRIPTION) is None assert state_w4.attributes.get(ATTR_SENDER) is None assert state_w4.attributes.get(ATTR_SEVERITY) is None + assert state_w4.attributes.get(ATTR_RECOMMENDED_ACTIONS) is None assert state_w4.attributes.get(ATTR_ID) is None assert state_w4.attributes.get(ATTR_SENT) is None assert state_w4.attributes.get(ATTR_START) is None @@ -243,6 +256,7 @@ async def test_sensors_without_corona_filter(hass: HomeAssistant) -> None: assert state_w5.attributes.get(ATTR_DESCRIPTION) is None assert state_w5.attributes.get(ATTR_SENDER) is None assert state_w5.attributes.get(ATTR_SEVERITY) is None + assert state_w5.attributes.get(ATTR_RECOMMENDED_ACTIONS) is None assert state_w5.attributes.get(ATTR_ID) is None assert state_w5.attributes.get(ATTR_SENT) is None assert state_w5.attributes.get(ATTR_START) is None