Skip to content

Commit

Permalink
Fix sub-devices retrieve the wrong device status. #194 #180
Browse files Browse the repository at this point in the history
  • Loading branch information
xZetsubou committed May 5, 2024
1 parent 5d8dced commit 842778d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions custom_components/localtuya/core/pytuya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,12 +1059,13 @@ async def status(self, cid=None):
"""Return device status."""
status: dict = await self.exchange(command=DP_QUERY, nodeID=cid, delay=False)

if status:
if cid and "dps" in status:
self.dps_cache.update({cid: status["dps"]})
elif "dps" in status:
self.dps_cache.update({"parent": status["dps"]})

self.dps_cache.setdefault("parent", {})
if status and "dps" in status:
if "cid" in status:
self.error(f"Yes found status: requested is {cid} and status cid is: {status["cid"]}")
self.dps_cache.update({status["cid"]: status["dps"]})
else:
self.dps_cache["parent"].update(status["dps"])
return self.dps_cache.get(cid, {}) if cid else self.dps_cache.get("parent", {})

async def heartbeat(self):
Expand Down

0 comments on commit 842778d

Please sign in to comment.