Skip to content

Commit

Permalink
Notify all entities in the device with available notifications via pu…
Browse files Browse the repository at this point in the history
…sh notifications
  • Loading branch information
nao-pon committed Feb 6, 2024
1 parent cbf42be commit 3bdafa6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
8 changes: 8 additions & 0 deletions pychonet/HomeAirConditioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ class HomeAirConditioner(EchonetInstance):
0x58: "lc",
0x59: "lc-right",
0x5A: "lc-rc",
0x5B: "lc-rc-right",
0x5C: "lc-center",
0x5D: "lc-center-right",
0x5F: "lc-center-rc-right",
0x60: "left",
0x61: "left-right",
0x62: "left-rc",
Expand All @@ -238,6 +242,10 @@ class HomeAirConditioner(EchonetInstance):
0x67: "left-center-rc-right",
0x69: "left-lc-right",
0x6A: "left-lc-rc",
0x6C: "left-lc-center",
0x6D: "left-lc-center-right",
0x6E: "left-lc-center-rc",
0x6F: "left-lc-center-rc-right",
},
],
0xAA: [
Expand Down
19 changes: 14 additions & 5 deletions pychonet/echonetapiclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,24 @@ async def echonetMessageReceived(self, raw_data, addr):
self._state[host]["discovered"] = True

# Markup "available"
_to_available = False
if host in self._state:
if not self._state[host].get("available"):
updated = True
_to_available = True
self._state[host]["available"] = True

# Call update callback functions
if updated and key in self._update_callbacks:
for update_func in self._update_callbacks[key]:
await update_func(isPush)
if _to_available:
# Call update callback functions
# key is f"{host}-{deojgc}-{deojcc}-{deojci}"
for _key in self._update_callbacks:
if _key.startswith(host):
for update_func in self._update_callbacks[_key]:
await update_func(False)
else:
# Call update callback functions
if updated and key in self._update_callbacks:
for update_func in self._update_callbacks[key]:
await update_func(isPush)

# if we get duplicate packets that have already been processed then dont worry about the message list.
# but still process them regardless.
Expand Down

0 comments on commit 3bdafa6

Please sign in to comment.