Vicare: Avoid invalid temperature values (#26485)

The PyVicare API can return the string "error" in case of connection
or authentication errors.
The current_temperature value could be set to "error" instead of a
nueric value or None which breaks the climate component.

This commit sets the current_temperature to None instead.
This commit is contained in:
Hans Oischinger 2019-09-07 02:41:34 +02:00 committed by Andrew Sayre
parent 078a72d102
commit 5b3004c7b0

View file

@ -96,10 +96,13 @@ class ViCareClimate(ClimateDevice):
def update(self):
"""Let HA know there has been an update from the ViCare API."""
_room_temperature = self._api.getRoomTemperature()
if _room_temperature is not None and _room_temperature != "error":
_supply_temperature = self._api.getSupplyTemperature()
if _room_temperature is not None and _room_temperature != PYVICARE_ERROR:
self._current_temperature = _room_temperature
elif _supply_temperature != PYVICARE_ERROR:
self._current_temperature = _supply_temperature
else:
self._current_temperature = self._api.getSupplyTemperature()
self._current_temperature = None
self._current_program = self._api.getActiveProgram()
# The getCurrentDesiredTemperature call can yield 'error' (str) when the system is in standby