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

Rename MP1S state parameters #783

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
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
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]),
}


Loading