Skip to content

Commit

Permalink
Fixed checking for valid values
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberjunky committed Feb 3, 2022
1 parent 7ec986c commit ce5c833
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions custom_components/toon_boilerstatus/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,23 +240,23 @@ async def async_update(self):
boiler = self._data.latest_data

if boiler:
if "sampleTime" in boiler and boiler["sampleTime"]:
if "sampleTime" in boiler and boiler["sampleTime"] is not None:
self._last_updated = boiler["sampleTime"]

if self._type == "boilersetpoint":
if "boilerSetpoint" in boiler and boiler["boilerSetpoint"]:
if "boilerSetpoint" in boiler and boiler["boilerSetpoint"] is not None:
self._state = float(boiler["boilerSetpoint"])

elif self._type == "boilerintemp":
if "boilerInTemp" in boiler and boiler["boilerInTemp"]:
if "boilerInTemp" in boiler and boiler["boilerInTemp"] is not None:
self._state = float(boiler["boilerInTemp"])

elif self._type == "boilerouttemp":
if "boilerOutTemp" in boiler and boiler["boilerOutTemp"]:
if "boilerOutTemp" in boiler and boiler["boilerOutTemp"] is not None:
self._state = float(boiler["boilerOutTemp"])

elif self._type == "boilerpressure":
if "boilerPressure" in boiler and boiler["boilerPressure"]:
if "boilerPressure" in boiler and boiler["boilerPressure"] is not None:
self._state = float(boiler["boilerPressure"])

elif self._type == "boilermodulationlevel":
Expand All @@ -267,11 +267,14 @@ async def async_update(self):
self._state = float(boiler["boilerModulationLevel"])

elif self._type == "roomtemp":
if "roomTemp" in boiler and boiler["roomTemp"]:
if "roomTemp" in boiler and boiler["roomTemp"] is not None:
self._state = float(boiler["roomTemp"])

elif self._type == "roomtempsetpoint":
if "roomTempSetpoint" in boiler and boiler["roomTempSetpoint"]:
if (
"roomTempSetpoint" in boiler
and boiler["roomTempSetpoint"] is not None
):
self._state = float(boiler["roomTempSetpoint"])

_LOGGER.debug("Device: %s State: %s", self._type, self._state)

0 comments on commit ce5c833

Please sign in to comment.