1
0
Fork 0

Rename MP1S state parameters (#783)

* Rename MP1S state parameters

* Rename get_status to get_state
This commit is contained in:
Felipe Martins Diel 2024-04-09 19:43:29 -03:00 committed by GitHub
parent c6bf96da47
commit cacebe7f3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 17 deletions

View File

@ -160,7 +160,7 @@ SUPPORTED_TYPES = {
0x60C8: ("LB1", "Broadlink"),
0x6112: ("LB1", "Broadlink"),
0x644B: ("LB1", "Broadlink"),
0x644C: ("LB27 R1", "Broadlink"),
0x644C: ("LB27 R1", "Broadlink"),
0x644E: ("LB26 R1", "Broadlink"),
},
lb2: {
@ -170,9 +170,9 @@ SUPPORTED_TYPES = {
S1C: {
0x2722: ("S2KIT", "Broadlink"),
},
s3: {
0xA59C:("S3", "Broadlink"),
0xA64D:("S3", "Broadlink"),
s3: {
0xA59C: ("S3", "Broadlink"),
0xA64D: ("S3", "Broadlink"),
},
hysen: {
0x4EAD: ("HY02/HY03", "Hysen"),

View File

@ -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.
@ -392,15 +392,15 @@ class mp1s(mp1):
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])
}
return {
"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]),
}