mirror of
https://github.com/mjg59/python-broadlink.git
synced 2024-11-11 02:10:12 +01:00
parent
dfd3372c36
commit
1ad468aefe
@ -212,16 +212,14 @@ class sp2(device):
|
|||||||
payload = self.decrypt(response[0x38:])
|
payload = self.decrypt(response[0x38:])
|
||||||
return bool(payload[0x4] == 2 or payload[0x4] == 3 or payload[0x4] == 0xFF)
|
return bool(payload[0x4] == 2 or payload[0x4] == 3 or payload[0x4] == 0xFF)
|
||||||
|
|
||||||
def get_energy(self) -> int:
|
def get_energy(self) -> float:
|
||||||
"""Return the energy state of the device."""
|
"""Return the power consumption in W."""
|
||||||
packet = bytearray([8, 0, 254, 1, 5, 1, 0, 0, 0, 45])
|
packet = bytearray([8, 0, 254, 1, 5, 1, 0, 0, 0, 45])
|
||||||
response = self.send_packet(0x6A, packet)
|
response = self.send_packet(0x6A, packet)
|
||||||
check_error(response[0x22:0x24])
|
check_error(response[0x22:0x24])
|
||||||
payload = self.decrypt(response[0x38:])
|
payload = self.decrypt(response[0x38:])
|
||||||
return (
|
energy = payload[0x7:0x4:-1].hex()
|
||||||
int(hex(payload[0x07] * 256 + payload[0x06])[2:])
|
return int(energy) / 100
|
||||||
+ int(hex(payload[0x05])[2:]) / 100.0
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class sp4(device):
|
class sp4(device):
|
||||||
|
Loading…
Reference in New Issue
Block a user