mirror of
https://github.com/mjg59/python-broadlink.git
synced 2024-11-21 22:51:41 +01:00
Rename MP1S state parameters (#783)
* Rename MP1S state parameters * Rename get_status to get_state
This commit is contained in:
parent
c6bf96da47
commit
cacebe7f3c
@ -171,8 +171,8 @@ SUPPORTED_TYPES = {
|
|||||||
0x2722: ("S2KIT", "Broadlink"),
|
0x2722: ("S2KIT", "Broadlink"),
|
||||||
},
|
},
|
||||||
s3: {
|
s3: {
|
||||||
0xA59C:("S3", "Broadlink"),
|
0xA59C: ("S3", "Broadlink"),
|
||||||
0xA64D:("S3", "Broadlink"),
|
0xA64D: ("S3", "Broadlink"),
|
||||||
},
|
},
|
||||||
hysen: {
|
hysen: {
|
||||||
0x4EAD: ("HY02/HY03", "Hysen"),
|
0x4EAD: ("HY02/HY03", "Hysen"),
|
||||||
|
@ -367,9 +367,9 @@ class mp1s(mp1):
|
|||||||
|
|
||||||
TYPE = "MP1S"
|
TYPE = "MP1S"
|
||||||
|
|
||||||
def get_status(self) -> dict:
|
def get_state(self) -> dict:
|
||||||
"""
|
"""Return the power state of the device.
|
||||||
Return the power state of the device.
|
|
||||||
voltage in V.
|
voltage in V.
|
||||||
current in A.
|
current in A.
|
||||||
power in W.
|
power in W.
|
||||||
@ -392,15 +392,15 @@ class mp1s(mp1):
|
|||||||
payload_str = payload.hex()[4:-6]
|
payload_str = payload.hex()[4:-6]
|
||||||
|
|
||||||
def get_value(start, end, factors):
|
def get_value(start, end, factors):
|
||||||
value = sum(int(payload_str[i-2:i]) * factor for i,
|
value = sum(
|
||||||
factor in zip(range(start, end, -2), factors))
|
int(payload_str[i - 2 : i]) * factor
|
||||||
|
for i, factor in zip(range(start, end, -2), factors)
|
||||||
|
)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'voltage': get_value(34, 30, [10, 0.1]),
|
"volt": get_value(34, 30, [10, 0.1]),
|
||||||
'current': get_value(40, 34, [1, 0.01, 0.0001]),
|
"current": get_value(40, 34, [1, 0.01, 0.0001]),
|
||||||
'power': get_value(46, 40, [100, 1, 0.01]),
|
"power": get_value(46, 40, [100, 1, 0.01]),
|
||||||
'power_consumption': get_value(54, 46, [10000, 100, 1, 0.01])
|
"totalconsum": get_value(54, 46, [10000, 100, 1, 0.01]),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user