Skip to content

Commit 842778d

Browse files
committed
Fix sub-devices retrieve the wrong device status. rospogrigio#194 rospogrigio#180
1 parent 5d8dced commit 842778d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

custom_components/localtuya/core/pytuya/__init__.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -1059,12 +1059,13 @@ async def status(self, cid=None):
10591059
"""Return device status."""
10601060
status: dict = await self.exchange(command=DP_QUERY, nodeID=cid, delay=False)
10611061

1062-
if status:
1063-
if cid and "dps" in status:
1064-
self.dps_cache.update({cid: status["dps"]})
1065-
elif "dps" in status:
1066-
self.dps_cache.update({"parent": status["dps"]})
1067-
1062+
self.dps_cache.setdefault("parent", {})
1063+
if status and "dps" in status:
1064+
if "cid" in status:
1065+
self.error(f"Yes found status: requested is {cid} and status cid is: {status["cid"]}")
1066+
self.dps_cache.update({status["cid"]: status["dps"]})
1067+
else:
1068+
self.dps_cache["parent"].update(status["dps"])
10681069
return self.dps_cache.get(cid, {}) if cid else self.dps_cache.get("parent", {})
10691070

10701071
async def heartbeat(self):

0 commit comments

Comments
 (0)