Skip to content

Commit

Permalink
tread 0x2a as an 24bit signed int (#1799)
Browse files Browse the repository at this point in the history
  • Loading branch information
pipiche38 authored Nov 29, 2024
1 parent ce05264 commit f79c97d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Modules/readClusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,14 @@ def Cluster0702(self, Devices, MsgSQN, MsgSrcAddr, MsgSrcEp, MsgClusterId, MsgAt
# Report Line 3 on fake Ep "f3"

if MsgAttrID in ("2000", "2001", "2002"): # Lx phase Power

if MsgAttType == "2a":
# That is a signed 24bit
signed_int = struct.unpack("i", struct.pack("I", int("0" + MsgClusterData, 16)))[0]
if (signed_int & 0x00800000) != 0:
signed_int -= 0x01000000
value = signed_int

line = 1 + (int(MsgAttrID, 16) - 0x2000)
fake_ep = "f%s" % line
conso = compute_metering_conso(self, MsgSrcAddr, MsgSrcEp, MsgClusterId, MsgAttrID, value)
Expand All @@ -1767,6 +1775,13 @@ def Cluster0702(self, Devices, MsgSQN, MsgSrcAddr, MsgSrcEp, MsgClusterId, MsgAt
MajDomoDevice(self, Devices, MsgSrcAddr, fake_ep, MsgClusterId, str(conso))

elif MsgAttrID in ("2100", "2101", "2102"): # Reactive Power
if MsgAttType == "2a":
# That is a signed 24bit
signed_int = struct.unpack("i", struct.pack("I", int("0" + MsgClusterData, 16)))[0]
if (signed_int & 0x00800000) != 0:
signed_int -= 0x01000000
value = signed_int

line = 1 + (int(MsgAttrID, 16) - 0x2100)
fake_ep = "f%s" % line
conso = compute_metering_conso(self, MsgSrcAddr, MsgSrcEp, MsgClusterId, "0400", value)
Expand Down

0 comments on commit f79c97d

Please sign in to comment.