Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix negative power calculation for Owon Clamp device #1799

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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