From f865b19b379de6c290433033e69ba4006114c43e Mon Sep 17 00:00:00 2001 From: MapoDan <42698485+MapoDan@users.noreply.github.com> Date: Sat, 12 Oct 2019 12:51:53 +0200 Subject: [PATCH] Update climate.py --- .../programmable_thermostat/climate.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/custom_components/programmable_thermostat/climate.py b/custom_components/programmable_thermostat/climate.py index ad6dbe9..45e5e60 100644 --- a/custom_components/programmable_thermostat/climate.py +++ b/custom_components/programmable_thermostat/climate.py @@ -22,7 +22,7 @@ _LOGGER = logging.getLogger(__name__) -__version__ = '2.2.0' +__version__ = '2.2.1' DEPENDENCIES = ['switch', 'sensor'] @@ -150,7 +150,7 @@ def _async_startup(event): # Check If we have an old state old_state = await self.async_get_last_state() - _LOGGER.error("old state: %s", old_state) + _LOGGER.info("old state: %s", old_state) if old_state is not None: # If we have no initial temperature, restore if self._target_temp is None: @@ -300,9 +300,9 @@ async def _async_set_hvac_action(self): Need to be one of CURRENT_HVAC_*. """ - if self.hass.states.is_state(self.cooler_entity_id, STATE_ON): + if self.cooler_entity_id is not None and self.hass.states.is_state(self.cooler_entity_id, STATE_ON): self._hvac_action = CURRENT_HVAC_COOL - elif self.hass.states.is_state(self.heater_entity_id, STATE_ON): + elif self.heater_entity_id is not None and self.hass.states.is_state(self.heater_entity_id, STATE_ON): self._hvac_action = CURRENT_HVAC_HEAT else: self._hvac_action = CURRENT_HVAC_OFF @@ -322,6 +322,7 @@ async def _async_control_heating(self): if not self._active or self._hvac_mode == HVAC_MODE_OFF or self._hvac_mode == HVAC_MODE_COOL: return + self._check_mode_type = "heat" if self._is_device_active: if (self._target_temp - self._cur_temp) <= 0: await self._async_heater_turn_off() @@ -343,6 +344,7 @@ async def _async_control_cooling(self): if not self._active or self._hvac_mode == HVAC_MODE_OFF or self._hvac_mode == HVAC_MODE_HEAT: return + self._check_mode_type = "cool" if self._is_device_active: if (self._cur_temp - self._target_temp) <= 0: _LOGGER.info("Turning off cooler %s", self.cooler_entity_id) @@ -444,9 +446,9 @@ def _is_device_active(self): elif self._hvac_mode == HVAC_MODE_COOL: return self.hass.states.is_state(self.cooler_entity_id, STATE_ON) elif self._hvac_mode == HVAC_MODE_HEAT_COOL: - if self.hass.states.is_state(self.cooler_entity_id, STATE_ON): + if self._check_mode_type == "cool": return self.hass.states.is_state(self.cooler_entity_id, STATE_ON) - elif self.hass.states.is_state(self.heater_entity_id, STATE_ON): + elif self._check_mode_type == "heat": return self.hass.states.is_state(self.heater_entity_id, STATE_ON) else: return False