Add attribute for storing one weather warning as a whole (#29005)
This commit is contained in:
parent
55bec20b02
commit
0db1fcca0f
1 changed files with 7 additions and 0 deletions
|
@ -138,6 +138,9 @@ class DwdWeatherWarningsSensor(Entity):
|
|||
for event in self._api.data[f"{prefix}_warnings"]:
|
||||
i = i + 1
|
||||
|
||||
# dictionary for the attribute containing the complete warning as json
|
||||
event_json = event.copy()
|
||||
|
||||
data[f"warning_{i}_name"] = event["event"]
|
||||
data[f"warning_{i}_level"] = event["level"]
|
||||
data[f"warning_{i}_type"] = event["type"]
|
||||
|
@ -152,11 +155,15 @@ class DwdWeatherWarningsSensor(Entity):
|
|||
data[f"warning_{i}_start"] = dt_util.as_local(
|
||||
dt_util.utc_from_timestamp(event["start"] / 1000)
|
||||
)
|
||||
event_json["start"] = data[f"warning_{i}_start"]
|
||||
|
||||
if event["end"] is not None:
|
||||
data[f"warning_{i}_end"] = dt_util.as_local(
|
||||
dt_util.utc_from_timestamp(event["end"] / 1000)
|
||||
)
|
||||
event_json["end"] = data[f"warning_{i}_end"]
|
||||
|
||||
data[f"warning_{i}"] = event_json
|
||||
|
||||
return data
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue