def _async_control_heating(self): """Check if we need to turn heating on or off.""" if not self._active and None not in (self._cur_temp, self._target_temp): self._active = True _LOGGER.info('Obtained current and target temperature. ' 'Generic thermostat active.') if not self._active: return if not self._enabled: return if self.min_cycle_duration: if self._is_device_active: current_state = STATE_ON else: current_state = STATE_OFF long_enough = condition.state(self.hass, self.heater_entity_id, current_state, self.min_cycle_duration) if not long_enough: return if self.ac_mode: is_cooling = self._is_device_active if is_cooling: too_cold = self._target_temp - self._cur_temp >= \ self._cold_tolerance if too_cold: _LOGGER.info('Turning off AC %s', self.heater_entity_id) switch.async_turn_off(self.hass, self.heater_entity_id) else: too_hot = self._cur_temp - self._target_temp >= \ self._hot_tolerance if too_hot: _LOGGER.info('Turning on AC %s', self.heater_entity_id) switch.async_turn_on(self.hass, self.heater_entity_id) else: is_heating = self._is_device_active if is_heating: too_hot = self._cur_temp - self._target_temp >= \ self._hot_tolerance if too_hot: _LOGGER.info('Turning off heater %s', self.heater_entity_id) switch.async_turn_off(self.hass, self.heater_entity_id) else: too_cold = self._target_temp - self._cur_temp >= \ self._cold_tolerance if too_cold: _LOGGER.info('Turning on heater %s', self.heater_entity_id) switch.async_turn_on(self.hass, self.heater_entity_id)
def _async_control_heating(self): """Check if we need to turn heating on or off.""" if not self._active and None not in (self._cur_temp, self._target_temp): self._active = True _LOGGER.info('Obtained current and target temperature. ' 'Generic thermostat active.') if not self._active: return if not self._enabled: return if self.min_cycle_duration: if self._is_device_active: current_state = STATE_ON else: current_state = STATE_OFF long_enough = condition.state( self.hass, self.heater_entity_id, current_state, self.min_cycle_duration) if not long_enough: return if self.ac_mode: is_cooling = self._is_device_active if is_cooling: too_cold = self._target_temp - self._cur_temp >= \ self._cold_tolerance if too_cold: _LOGGER.info('Turning off AC %s', self.heater_entity_id) switch.async_turn_off(self.hass, self.heater_entity_id) else: too_hot = self._cur_temp - self._target_temp >= \ self._hot_tolerance if too_hot: _LOGGER.info('Turning on AC %s', self.heater_entity_id) switch.async_turn_on(self.hass, self.heater_entity_id) else: is_heating = self._is_device_active if is_heating: too_hot = self._cur_temp - self._target_temp >= \ self._hot_tolerance if too_hot: _LOGGER.info('Turning off heater %s', self.heater_entity_id) switch.async_turn_off(self.hass, self.heater_entity_id) else: too_cold = self._target_temp - self._cur_temp >= \ self._cold_tolerance if too_cold: _LOGGER.info('Turning on heater %s', self.heater_entity_id) switch.async_turn_on(self.hass, self.heater_entity_id)
def _async_keep_alive(self, time): """Called at constant intervals for keep-alive purposes.""" if self.current_operation in [STATE_COOL, STATE_HEAT]: switch.async_turn_on(self.hass, self.heater_entity_id) else: switch.async_turn_off(self.hass, self.heater_entity_id)
def _async_keep_alive(self, time): """Call at constant intervals for keep-alive purposes.""" if self.current_operation in [STATE_COOL, STATE_HEAT]: switch.async_turn_on(self.hass, self.heater_entity_id) else: switch.async_turn_off(self.hass, self.heater_entity_id)
def _async_keep_alive(self, time): """Call at constant intervals for keep-alive purposes.""" if self._active and self._is_device_active: switch.async_turn_on(self.hass, self.heater_entity_id) else: switch.async_turn_off(self.hass, self.heater_entity_id)