Skip to content

Commit

Permalink
fix: legacy timestamp on empty event list
Browse files Browse the repository at this point in the history
  • Loading branch information
andersevenrud committed May 21, 2024
1 parent 97a0fbd commit 8df0129
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion custom_components/nexa_bridge_x/nexa.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import logging
import async_timeout
import httpx
import datetime

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -83,8 +84,12 @@ def values_from_events(node: NexaNodeData, legacy: bool) -> list[NexaNodeValue]:
))
else:
if legacy and "capabilities" in node:
now_time = datetime.datetime.now().astimezone().replace(microsecond=0).isoformat()
_LOGGER.warning("Node '%s' contained no events, reverting to capabilities", node.name)

for key in node["capabilities"]:
values.append(NexaNodeValue(key, None, None, "0"))
if key not in ignores:
values.append(NexaNodeValue(key, None, None, now_time))

return values

Expand Down

0 comments on commit 8df0129

Please sign in to comment.