cantabile_edge, cantabile_modbus, cantabile_eebus 0.1.1789: full source

This commit is contained in:
Setti Solutions S.R.L committed 2026-11-12 06:28:42 +02:00
1 parent 94f46db8f8
commit b24675fe9c
25 files changed
+766 -40

No files matched your search

+3 -1
View File
@@ -55,12 +55,14 @@ class Collector:
def on_entities(self, ev: dict, now: float | None = None):
now = time.time() if now is None else now
for eid, s in (ev.get("a") or {}).items():
self.states[eid] = {"s": s.get("s"), "a": dict(s.get("a") or {}), "t": s.get("lc") or now}
self.states[eid] = {"s": s.get("s"), "a": dict(s.get("a") or {}), "t": s.get("lc") or now, "c": s.get("c")}
for eid, c in (ev.get("c") or {}).items():
cur = self.states.setdefault(eid, {"s": None, "a": {}, "t": now})
plus, minus = c.get("+") or {}, c.get("-") or {}
if "s" in plus:
cur["s"] = plus["s"]
# the change's context (HA: an id alone, or {"id", "user_id", "parent_id"}): who made it (guard.changed_by)
cur["c"] = plus.get("c")
cur["a"].update(plus.get("a") or {})
for k in minus.get("a") or []:
cur["a"].pop(k, None)