Skip to content

Commit

Permalink
Add more robustness to checking values
Browse files Browse the repository at this point in the history
  • Loading branch information
PeteRager committed Oct 7, 2023
1 parent 26c6322 commit fc9064f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 3 additions & 4 deletions custom_components/lennoxs30/sensor_wt_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,10 @@ def native_unit_of_measurement(self):
@property
def available(self) -> bool:
attr_val = getattr(self._system, self._system_attr)
if attr_val is None:
if attr_val is None or attr_val == self._unavailable_value:
return False
if getattr(self._system, self._system_attr) == self._unavailable_value:
return False
if getattr(self._system, self._availability_attribute) is False:
attr_avail = getattr(self._system, self._availability_attribute)
if attr_avail is None or attr_avail is False:
return False
return super().available

Expand Down
4 changes: 4 additions & 0 deletions tests/test_sensor_wt_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ async def test_wt_env_sensor_humidity(hass, manager_system_04_furn_ac_zoning_ble
assert sensor.available is False
assert sensor.native_value is None

system.wt_env_humidity = "not an integer"
assert sensor.native_value is None
assert sensor.available is False

data = loadfile("weather.json", system.sysId)
manager.api.processMessage(data)

Expand Down

0 comments on commit fc9064f

Please sign in to comment.