Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #21 from blademckain/master
Browse files Browse the repository at this point in the history
Merge Auto Mode changes from @blademckain
  • Loading branch information
daenny authored May 10, 2020
2 parents 18edd80 + 3579dfd commit db74d9e
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions custom_components/climate_group/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
),
}
)

SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE
#edit the supported_flags
SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE, SUPPORT_TARGET_TEMPERATURE_RANGE


# HVAC Action priority
Expand Down Expand Up @@ -110,6 +110,9 @@ def __init__(
self._max_temp = 0
self._current_temp = 0
self._target_temp = 0
#added the temp_low and temp_high
self._target_temp_high = None
self._target_temp_low = None
self._mode = None
self._action = None
self._mode_list = None
Expand Down Expand Up @@ -185,6 +188,15 @@ def current_temperature(self):
@property
def target_temperature(self):
return self._target_temp

#added the target_temperature_low and target_temperature_high
@property
def target_temperature_low(self):
return self._target_temp_low

@property
def target_temperature_high(self):
return self._target_temp_high

@property
def temperature_unit(self):
Expand All @@ -202,9 +214,17 @@ async def async_set_temperature(self, **kwargs):
if ATTR_HVAC_MODE in kwargs:
hvac_mode = kwargs.get(ATTR_HVAC_MODE)
await self.async_set_hvac_mode(hvac_mode)
elif ATTR_TEMPERATURE in kwargs:
temperature = kwargs.get(ATTR_TEMPERATURE)
data[ATTR_TEMPERATURE] = temperature
#start add
elif ATTR_TEMPERATURE in kwargs or ATTR_TARGET_TEMP_LOW in kwargs or ATTR_TARGET_TEMP_HIGH in kwargs:
if ATTR_TEMPERATURE in kwargs:
temperature = kwargs.get(ATTR_TEMPERATURE)
data[ATTR_TEMPERATURE] = temperature
elif ATTR_TARGET_TEMP_LOW in kwargs or ATTR_TARGET_TEMP_HIGH in kwargs:
temperature_low = kwargs.get(ATTR_TARGET_TEMP_LOW)
temperature_high = kwargs.get(ATTR_TARGET_TEMP_HIGH)
data[climate.ATTR_TARGET_TEMP_LOW] = temperature_low
data[climate.ATTR_TARGET_TEMP_HIGH] = temperature_high
#end add
await self.hass.services.async_call(
climate.DOMAIN, climate.SERVICE_SET_TEMPERATURE, data, blocking=True
)
Expand Down Expand Up @@ -283,12 +303,18 @@ async def async_update(self):
self._preset = Counter(itertools.chain(all_presets)).most_common(1)[0][0]

self._target_temp = _reduce_attribute(filtered_states, ATTR_TEMPERATURE)

#start add
self._target_temp_low = _reduce_attribute(filtered_states, ATTR_TARGET_TEMP_LOW)
self._target_temp_high = _reduce_attribute(filtered_states, ATTR_TARGET_TEMP_HIGH)
#end add

self._current_temp = _reduce_attribute(
filtered_states, ATTR_CURRENT_TEMPERATURE
)

_LOGGER.debug(
f"Target temp: {self._target_temp}; Current temp: {self._current_temp}"
f"Target temp: {self._target_temp}; Target temp low: {self._target_temp_low}; Target temp high: {self._target_temp_high}; Current temp: {self._current_temp}"
)

self._min_temp = _reduce_attribute(states, ATTR_MIN_TEMP, reduce=max)
Expand Down Expand Up @@ -319,7 +345,7 @@ async def async_update(self):
async def async_set_preset_mode(self, preset_mode: str):
"""Forward the preset_mode to all climate in the climate group."""
data = {ATTR_ENTITY_ID: self._entity_ids, ATTR_PRESET_MODE: preset_mode}

await self.hass.services.async_call(
climate.DOMAIN, climate.SERVICE_SET_PRESET_MODE, data, blocking=True
)
Expand Down

0 comments on commit db74d9e

Please sign in to comment.