Skip to content

Commit

Permalink
fix unknown and none status
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya committed May 15, 2020
1 parent 8ee9afc commit 53d3005
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion custom_components/qubino_wire_pilot/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
EVENT_HOMEASSISTANT_START,
ATTR_ENTITY_ID,
STATE_UNKNOWN,
STATE_UNAVAILABLE,
)
from homeassistant.core import callback

Expand Down Expand Up @@ -154,6 +155,8 @@ def preset_modes(self):
def preset_mode(self):
value = self.heater_value

if value is None:
return STATE_UNKNOWN
if value <= VALUE_OFF:
return PRESET_NONE
elif value <= VALUE_FROST:
Expand Down Expand Up @@ -195,6 +198,8 @@ async def async_set_hvac_mode(self, hvac_mode):
def hvac_mode(self):
value = self.heater_value

if value is None:
return STATE_UNKNOWN
if value <= VALUE_OFF:
return HVAC_MODE_OFF
else:
Expand All @@ -215,7 +220,8 @@ async def _async_temperature_changed(self, entity_id, old_state, new_state):
@callback
def _async_update_temperature(self, state):
try:
self._cur_temperature = float(state.state)
if (state.state != STATE_UNAVAILABLE):
self._cur_temperature = float(state.state)
except ValueError as ex:
_LOGGER.error("Unable to update from temperature sensor: %s", ex)

Expand Down

0 comments on commit 53d3005

Please sign in to comment.