mirror of
https://github.com/mjg59/python-broadlink.git
synced 2024-11-13 03:00:11 +01:00
Add support for Broadlink MP1 with power meter (#631)
This commit is contained in:
parent
9873af9bc4
commit
f2a582b8f9
@ -12,7 +12,7 @@ from .device import Device, ping, scan
|
||||
from .light import lb1, lb2
|
||||
from .remote import rm, rm4, rm4mini, rm4pro, rmmini, rmminib, rmpro
|
||||
from .sensor import a1
|
||||
from .switch import bg1, mp1, sp1, sp2, sp2s, sp3, sp3s, sp4, sp4b
|
||||
from .switch import bg1, mp1, mp1s, sp1, sp2, sp2s, sp3, sp3s, sp4, sp4b
|
||||
|
||||
SUPPORTED_TYPES = {
|
||||
sp1: {
|
||||
@ -133,10 +133,12 @@ SUPPORTED_TYPES = {
|
||||
},
|
||||
mp1: {
|
||||
0x4EB5: ("MP1-1K4S", "Broadlink"),
|
||||
0x4EF7: ("MP1-1K4S", "Broadlink (OEM)"),
|
||||
0x4F1B: ("MP1-1K3S2U", "Broadlink (OEM)"),
|
||||
0x4F65: ("MP1-1K3S2U", "Broadlink"),
|
||||
},
|
||||
mp1s: {
|
||||
0x4EF7: ("MP1-1K4S", "Broadlink (OEM)"),
|
||||
},
|
||||
lb1: {
|
||||
0x5043: ("SB800TD", "Broadlink (OEM)"),
|
||||
0x504E: ("LB1", "Broadlink"),
|
||||
|
@ -360,3 +360,18 @@ class mp1(Device):
|
||||
"s3": bool(data & 4),
|
||||
"s4": bool(data & 8),
|
||||
}
|
||||
|
||||
|
||||
class mp1s(mp1):
|
||||
"""Controls a Broadlink MP1S."""
|
||||
|
||||
TYPE = "MP1S"
|
||||
|
||||
def get_energy(self) -> float:
|
||||
"""Return the power consumption in W."""
|
||||
packet = bytearray([8, 0, 254, 1, 5, 1, 0, 0, 0, 45])
|
||||
response = self.send_packet(0x6A, packet)
|
||||
e.check_error(response[0x22:0x24])
|
||||
payload = self.decrypt(response[0x38:])
|
||||
energy = payload[0x7:0x4:-1].hex()
|
||||
return int(energy) / 100
|
||||
|
Loading…
Reference in New Issue
Block a user