diff --git a/broadlink/__init__.py b/broadlink/__init__.py index 596a8ec1..a2bd5eac 100644 --- a/broadlink/__init__.py +++ b/broadlink/__init__.py @@ -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: { @@ -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"), diff --git a/broadlink/switch.py b/broadlink/switch.py index e60f124a..1a94de6b 100644 --- a/broadlink/switch.py +++ b/broadlink/switch.py @@ -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 @@ 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]), } - -