Skip to content

Commit

Permalink
Rename MP1S state parameters (#783)
Browse files Browse the repository at this point in the history
* Rename MP1S state parameters

* Rename get_status to get_state
  • Loading branch information
felipediel committed Apr 9, 2024
1 parent c6bf96d commit cacebe7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions broadlink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
0x60C8: ("LB1", "Broadlink"),
0x6112: ("LB1", "Broadlink"),
0x644B: ("LB1", "Broadlink"),
0x644C: ("LB27 R1", "Broadlink"),
0x644C: ("LB27 R1", "Broadlink"),
0x644E: ("LB26 R1", "Broadlink"),
},
lb2: {
Expand All @@ -170,9 +170,9 @@
S1C: {
0x2722: ("S2KIT", "Broadlink"),
},
s3: {
0xA59C:("S3", "Broadlink"),
0xA64D:("S3", "Broadlink"),
s3: {
0xA59C: ("S3", "Broadlink"),
0xA64D: ("S3", "Broadlink"),
},
hysen: {
0x4EAD: ("HY02/HY03", "Hysen"),
Expand Down
24 changes: 12 additions & 12 deletions broadlink/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ class mp1s(mp1):

TYPE = "MP1S"

def get_status(self) -> dict:
"""
Return the power state of the device.
def get_state(self) -> dict:
"""Return the power state of the device.
voltage in V.
current in A.
power in W.
Expand All @@ -392,15 +392,15 @@ def get_status(self) -> dict:
payload_str = payload.hex()[4:-6]

def get_value(start, end, factors):
value = sum(int(payload_str[i-2:i]) * factor for i,
factor in zip(range(start, end, -2), factors))
value = sum(
int(payload_str[i - 2 : i]) * factor
for i, factor in zip(range(start, end, -2), factors)
)
return value

return {
'voltage': get_value(34, 30, [10, 0.1]),
'current': get_value(40, 34, [1, 0.01, 0.0001]),
'power': get_value(46, 40, [100, 1, 0.01]),
'power_consumption': get_value(54, 46, [10000, 100, 1, 0.01])
"volt": get_value(34, 30, [10, 0.1]),
"current": get_value(40, 34, [1, 0.01, 0.0001]),
"power": get_value(46, 40, [100, 1, 0.01]),
"totalconsum": get_value(54, 46, [10000, 100, 1, 0.01]),
}


0 comments on commit cacebe7

Please sign in to comment.