Remove auxiliary functions from hysen class (#780)
This commit is contained in:
parent
d7ed9855b9
commit
06c91ae394
|
@ -43,28 +43,22 @@ class hysen(Device):
|
|||
|
||||
return payload[0x02:p_len]
|
||||
|
||||
def _room_or_ext_temp_logic(self, payload, base_index):
|
||||
def _decode_temp(self, payload, base_index):
|
||||
base_temp = payload[base_index] / 2.0
|
||||
add_offset = (payload[4] >> 3) & 1 # should offset be added?
|
||||
offset_raw_value = (payload[17] >> 4) & 3 # offset value
|
||||
offset = (offset_raw_value + 1) / 10 if add_offset else 0.0
|
||||
return base_temp + offset
|
||||
|
||||
def _room_temp_logic(self, payload):
|
||||
return self._room_or_ext_temp_logic(payload, 5)
|
||||
|
||||
def _ext_temp_logic(self, payload):
|
||||
return self._room_or_ext_temp_logic(payload, 18)
|
||||
|
||||
def get_temp(self) -> float:
|
||||
"""Return the room temperature in degrees celsius."""
|
||||
payload = self.send_request([0x01, 0x03, 0x00, 0x00, 0x00, 0x08])
|
||||
return self._room_temp_logic(payload)
|
||||
return self._decode_temp(payload, 5)
|
||||
|
||||
def get_external_temp(self) -> float:
|
||||
"""Return the external temperature in degrees celsius."""
|
||||
payload = self.send_request([0x01, 0x03, 0x00, 0x00, 0x00, 0x08])
|
||||
return self._ext_temp_logic(payload)
|
||||
return self._decode_temp(payload, 18)
|
||||
|
||||
def get_full_status(self) -> dict:
|
||||
"""Return the state of the device.
|
||||
|
@ -78,7 +72,7 @@ class hysen(Device):
|
|||
data["active"] = (payload[4] >> 4) & 1
|
||||
data["temp_manual"] = (payload[4] >> 6) & 1
|
||||
data["heating_cooling"] = (payload[4] >> 7) & 1
|
||||
data["room_temp"] = self._room_temp_logic(payload)
|
||||
data["room_temp"] = self._decode_temp(payload, 5)
|
||||
data["thermostat_temp"] = payload[6] / 2.0
|
||||
data["auto_mode"] = payload[7] & 0xF
|
||||
data["loop_mode"] = payload[7] >> 4
|
||||
|
@ -93,7 +87,7 @@ class hysen(Device):
|
|||
data["fre"] = payload[15]
|
||||
data["poweron"] = payload[16]
|
||||
data["unknown"] = payload[17]
|
||||
data["external_temp"] = self._ext_temp_logic(payload)
|
||||
data["external_temp"] = self._decode_temp(payload, 18)
|
||||
data["hour"] = payload[19]
|
||||
data["min"] = payload[20]
|
||||
data["sec"] = payload[21]
|
||||
|
|
Loading…
Reference in New Issue