Skip to content

Commit

Permalink
Update climate.py
Browse files Browse the repository at this point in the history
  • Loading branch information
MapoDan authored Jan 9, 2021
1 parent f8548e1 commit 5b941be
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions custom_components/programmable_thermostat/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ def __init__(self, hass, config):
self._hvac_mode = HVAC_MODE_OFF
self._support_flags = SUPPORT_FLAGS

""" Check if heaters and coolers are the same """
if self.heaters_entity_ids == self.coolers_entity_ids:
self._are_entities_same = True
else:
self._are_entities_same = False

async def async_added_to_hass(self):
"""Run when entity about to be added."""
await super().async_added_to_hass()
Expand Down Expand Up @@ -226,14 +232,14 @@ async def control_system_mode(self):
_LOGGER.debug("set to heat")
await self._async_control_thermo(mode="heat")
for opmod in self._hvac_list:
if opmod is HVAC_MODE_COOL:
if opmod is HVAC_MODE_COOL and not self._are_entities_same:
await self._async_turn_off(mode="cool", forced=True)
return
elif self._hvac_mode == HVAC_MODE_COOL:
_LOGGER.debug("set to cool")
await self._async_control_thermo(mode="cool")
for opmod in self._hvac_list:
if opmod is HVAC_MODE_HEAT:
if opmod is HVAC_MODE_HEAT and not self._are_entities_same:
await self._async_turn_off(mode="heat", forced=True)
return
else:
Expand Down Expand Up @@ -264,6 +270,7 @@ async def _async_turn_on(self, mode=None):
await self.hass.services.async_call(HA_DOMAIN, SERVICE_TURN_ON, data)
await self.async_update_ha_state()


async def _async_turn_off(self, mode=None, forced=False):
"""Turn heater toggleable device off."""
if self._related_climate is not None:
Expand Down Expand Up @@ -411,7 +418,10 @@ def _set_hvac_action_off(self, mode=None):
if abs(delta) >= self._tolerance and entities != None:
self._set_hvac_action_on(mode=mode_2)
else:
_LOGGER.error("climate.%s - Error during set of HVAC_ACTION", self._name)
if self._are_entities_same and not self._is_device_active_function(forced=False):
self._hvac_action = CURRENT_HVAC_OFF
else:
_LOGGER.error("climate.%s - Error during set of HVAC_ACTION", self._name)

def _set_hvac_action_on(self, mode=None):
"""This is used to set CURRENT_HVAC_* according to the mode that is running."""
Expand Down

0 comments on commit 5b941be

Please sign in to comment.