mirror of
https://github.com/mjg59/python-broadlink.git
synced 2024-11-22 23:17:47 +01:00
Allow negative temperatures
This commit is contained in:
parent
8e7e118f73
commit
96f1a9f6ad
@ -58,7 +58,9 @@ class rm(device):
|
||||
def check_sensors(self) -> dict:
|
||||
"""Return the state of the sensors."""
|
||||
resp = self._send(0x1)
|
||||
return {"temperature": resp[0x0] + resp[0x1] / 10.0}
|
||||
temperature = struct.unpack("<bb", resp[:0x2])
|
||||
temperature = temperature[0x0] + temperature[0x1] / 10.0
|
||||
return {"temperature": temperature}
|
||||
|
||||
|
||||
class rm4(rm):
|
||||
@ -85,7 +87,7 @@ class rm4(rm):
|
||||
def check_sensors(self) -> dict:
|
||||
"""Return the state of the sensors."""
|
||||
resp = self._send(0x24)
|
||||
return {
|
||||
"temperature": resp[0x0] + resp[0x1] / 100.0,
|
||||
"humidity": resp[0x2] + resp[0x3] / 100.0,
|
||||
}
|
||||
temperature = struct.unpack("<bb", resp[:0x2])
|
||||
temperature = temperature[0x0] + temperature[0x1] / 100.0
|
||||
humidity = resp[0x2] + resp[0x3] / 100.0
|
||||
return {"temperature": temperature, "humidity": humidity}
|
||||
|
@ -1,4 +1,6 @@
|
||||
"""Support for sensors."""
|
||||
import struct
|
||||
|
||||
from .device import device
|
||||
from .exceptions import check_error
|
||||
|
||||
@ -33,10 +35,15 @@ class a1(device):
|
||||
response = self.send_packet(0x6A, packet)
|
||||
check_error(response[0x22:0x24])
|
||||
payload = self.decrypt(response[0x38:])
|
||||
data = bytearray(payload[0x4:])
|
||||
data = payload[0x4:]
|
||||
|
||||
temperature = struct.unpack("<bb", data[:0x2])
|
||||
temperature = temperature[0x0] + temperature[0x1] / 10.0
|
||||
humidity = data[0x2] + data[0x3] / 10.0
|
||||
|
||||
return {
|
||||
"temperature": data[0x0] + data[0x1] / 10.0,
|
||||
"humidity": data[0x2] + data[0x3] / 10.0,
|
||||
"temperature": temperature,
|
||||
"humidity": humidity,
|
||||
"light": data[0x4],
|
||||
"air_quality": data[0x6],
|
||||
"noise": data[0x8],
|
||||
|
Loading…
Reference in New Issue
Block a user