1
0
mirror of https://github.com/mjg59/python-broadlink.git synced 2024-11-22 07:00:12 +01:00

Add support for Broadlink MP1 with power meter (#631)

This commit is contained in:
Felipe Martins Diel 2021-10-18 15:59:47 -03:00 committed by GitHub
parent 9873af9bc4
commit f2a582b8f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -12,7 +12,7 @@ from .device import Device, ping, scan
from .light import lb1, lb2 from .light import lb1, lb2
from .remote import rm, rm4, rm4mini, rm4pro, rmmini, rmminib, rmpro from .remote import rm, rm4, rm4mini, rm4pro, rmmini, rmminib, rmpro
from .sensor import a1 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 = { SUPPORTED_TYPES = {
sp1: { sp1: {
@ -133,10 +133,12 @@ SUPPORTED_TYPES = {
}, },
mp1: { mp1: {
0x4EB5: ("MP1-1K4S", "Broadlink"), 0x4EB5: ("MP1-1K4S", "Broadlink"),
0x4EF7: ("MP1-1K4S", "Broadlink (OEM)"),
0x4F1B: ("MP1-1K3S2U", "Broadlink (OEM)"), 0x4F1B: ("MP1-1K3S2U", "Broadlink (OEM)"),
0x4F65: ("MP1-1K3S2U", "Broadlink"), 0x4F65: ("MP1-1K3S2U", "Broadlink"),
}, },
mp1s: {
0x4EF7: ("MP1-1K4S", "Broadlink (OEM)"),
},
lb1: { lb1: {
0x5043: ("SB800TD", "Broadlink (OEM)"), 0x5043: ("SB800TD", "Broadlink (OEM)"),
0x504E: ("LB1", "Broadlink"), 0x504E: ("LB1", "Broadlink"),

View File

@ -360,3 +360,18 @@ class mp1(Device):
"s3": bool(data & 4), "s3": bool(data & 4),
"s4": bool(data & 8), "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