Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
scottyphillips committed Feb 21, 2022
1 parent 35be02f commit cf9692e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 30 deletions.
2 changes: 1 addition & 1 deletion custom_components/echonetlite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ async def async_update(self, **kwargs):
# polling succeded.
if retry > 1:
_LOGGER.debug(f"polling ECHONET Instance host {self._host} succeeded - Retry {retry} of 3")
self._update_data = update_data
self._update_data.update(update_data)
return self._update_data
else:
_LOGGER.debug(f"polling ECHONET Instance host {self._host} timed out - Retry {retry} of 3")
Expand Down
9 changes: 5 additions & 4 deletions custom_components/echonetlite/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,11 @@ def hvac_action(self):
elif (self._connector._update_data[ENL_HVAC_MODE] == HVAC_MODE_HEAT_COOL or
self._connector._update_data[ENL_HVAC_MODE] == "auto"):
if ENL_HVAC_ROOM_TEMP in self._connector._update_data:
if self._connector._update_data[ENL_HVAC_SET_TEMP] < self._connector._update_data[ENL_HVAC_ROOM_TEMP]:
return CURRENT_HVAC_COOL
elif self._connector._update_data[ENL_HVAC_SET_TEMP] > self._connector._update_data[ENL_HVAC_ROOM_TEMP]:
return CURRENT_HVAC_HEAT
if ENL_HVAC_ROOM_TEMP is not None:
if self._connector._update_data[ENL_HVAC_SET_TEMP] < self._connector._update_data[ENL_HVAC_ROOM_TEMP]:
return CURRENT_HVAC_COOL
elif self._connector._update_data[ENL_HVAC_SET_TEMP] > self._connector._update_data[ENL_HVAC_ROOM_TEMP]:
return CURRENT_HVAC_HEAT
return CURRENT_HVAC_IDLE
else:
_LOGGER.warning(f"Unknown HVAC mode {self._connector._update_data[ENL_HVAC_MODE]}")
Expand Down
2 changes: 1 addition & 1 deletion custom_components/echonetlite/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"codeowners": [
"@scottyphillips"
],
"version": "3.3.0",
"version": "3.3.1",
"iot_class": "local_polling"
}
49 changes: 25 additions & 24 deletions custom_components/echonetlite/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,34 +142,35 @@ def device_info(self):
@property
def native_value(self) -> StateType:
"""Return the state of the sensor."""
if self._instance._update_data[self._op_code] is None:
return STATE_UNAVAILABLE
elif self._sensor_attributes[CONF_TYPE] in [
DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_HUMIDITY
]:
if self._op_code in self._instance._update_data:
if self._instance._update_data[self._op_code] in [126, 253]:
if self._op_code in self._instance._update_data:
if self._instance._update_data[self._op_code] is None:
return STATE_UNAVAILABLE
elif self._sensor_attributes[CONF_TYPE] in [
DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_HUMIDITY
]:
if self._op_code in self._instance._update_data:
if self._instance._update_data[self._op_code] in [126, 253]:
return STATE_UNAVAILABLE
else:
return self._instance._update_data[self._op_code]
else:
return STATE_UNAVAILABLE
elif self._sensor_attributes[CONF_TYPE] == DEVICE_CLASS_POWER:
if self._op_code in self._instance._update_data:
# Underflow (less than 1 W)
if self._instance._update_data[self._op_code] == 65534:
return 1
else:
return self._instance._update_data[self._op_code]
else:
return STATE_UNAVAILABLE
elif self._op_code in self._instance._update_data:
if isinstance(self._instance._update_data[self._op_code], (int, float)):
return self._instance._update_data[self._op_code]
else:
return STATE_UNAVAILABLE
elif self._sensor_attributes[CONF_TYPE] == DEVICE_CLASS_POWER:
if self._op_code in self._instance._update_data:
# Underflow (less than 1 W)
if self._instance._update_data[self._op_code] == 65534:
return 1
else:
if len(self._instance._update_data[self._op_code]) < 255:
return self._instance._update_data[self._op_code]
else:
return STATE_UNAVAILABLE
elif self._op_code in self._instance._update_data:
if isinstance(self._instance._update_data[self._op_code], (int, float)):
return self._instance._update_data[self._op_code]
if len(self._instance._update_data[self._op_code]) < 255:
return self._instance._update_data[self._op_code]
else:
return STATE_UNAVAILABLE
else:
return STATE_UNAVAILABLE
return None

@property
Expand Down

0 comments on commit cf9692e

Please sign in to comment.