Add recommended actions to NINA (#83775)

This commit is contained in:
Maximilian 2022-12-27 11:24:54 +01:00 committed by GitHub
parent d4f69a3652
commit 5990bd7ca3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 1 deletions

View File

@ -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 "",

View File

@ -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,

View File

@ -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"

View File

@ -43,7 +43,7 @@
},
{
"valueName": "instructionCode",
"value": "BBK-ISC-132"
"value": "BBK-ISC-082"
},
{
"valueName": "sender_langname",

View File

@ -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