6161 ),
6262 }
6363)
64- #edit the supported_flags
65- SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE , SUPPORT_TARGET_TEMPERATURE_RANGE
64+ # edit the supported_flags
65+ SUPPORT_FLAGS = (
66+ SUPPORT_TARGET_TEMPERATURE | SUPPORT_TARGET_TEMPERATURE_RANGE | SUPPORT_PRESET_MODE
67+ )
6668
6769
6870# HVAC Action priority
@@ -110,7 +112,7 @@ def __init__(
110112 self ._max_temp = 0
111113 self ._current_temp = 0
112114 self ._target_temp = 0
113- #added the temp_low and temp_high
115+ # added the temp_low and temp_high
114116 self ._target_temp_high = None
115117 self ._target_temp_low = None
116118 self ._mode = None
@@ -188,8 +190,8 @@ def current_temperature(self):
188190 @property
189191 def target_temperature (self ):
190192 return self ._target_temp
191-
192- #added the target_temperature_low and target_temperature_high
193+
194+ # added the target_temperature_low and target_temperature_high
193195 @property
194196 def target_temperature_low (self ):
195197 return self ._target_temp_low
@@ -214,8 +216,12 @@ async def async_set_temperature(self, **kwargs):
214216 if ATTR_HVAC_MODE in kwargs :
215217 hvac_mode = kwargs .get (ATTR_HVAC_MODE )
216218 await self .async_set_hvac_mode (hvac_mode )
217- #start add
218- elif ATTR_TEMPERATURE in kwargs or ATTR_TARGET_TEMP_LOW in kwargs or ATTR_TARGET_TEMP_HIGH in kwargs :
219+ # start add
220+ elif (
221+ ATTR_TEMPERATURE in kwargs
222+ or ATTR_TARGET_TEMP_LOW in kwargs
223+ or ATTR_TARGET_TEMP_HIGH in kwargs
224+ ):
219225 if ATTR_TEMPERATURE in kwargs :
220226 temperature = kwargs .get (ATTR_TEMPERATURE )
221227 data [ATTR_TEMPERATURE ] = temperature
@@ -224,7 +230,7 @@ async def async_set_temperature(self, **kwargs):
224230 temperature_high = kwargs .get (ATTR_TARGET_TEMP_HIGH )
225231 data [climate .ATTR_TARGET_TEMP_LOW ] = temperature_low
226232 data [climate .ATTR_TARGET_TEMP_HIGH ] = temperature_high
227- # end add
233+ # end add
228234 await self .hass .services .async_call (
229235 climate .DOMAIN , climate .SERVICE_SET_TEMPERATURE , data , blocking = True
230236 )
@@ -305,20 +311,21 @@ async def async_update(self):
305311 self ._preset = Counter (itertools .chain (all_presets )).most_common (1 )[0 ][0 ]
306312
307313 self ._target_temp = _reduce_attribute (filtered_states , ATTR_TEMPERATURE )
308-
309- #start add
314+
315+ # start add
310316 self ._target_temp_low = _reduce_attribute (filtered_states , ATTR_TARGET_TEMP_LOW )
311- self ._target_temp_high = _reduce_attribute (filtered_states , ATTR_TARGET_TEMP_HIGH )
312- #end add
313-
317+ self ._target_temp_high = _reduce_attribute (
318+ filtered_states , ATTR_TARGET_TEMP_HIGH
319+ )
320+ # end add
321+
314322 self ._current_temp = _reduce_attribute (
315323 filtered_states , ATTR_CURRENT_TEMPERATURE
316324 )
317325
318326 _LOGGER .debug (
319- 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 } "
327+ 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 } "
320328 )
321-
322329 self ._min_temp = _reduce_attribute (states , ATTR_MIN_TEMP , reduce = max )
323330 self ._max_temp = _reduce_attribute (states , ATTR_MAX_TEMP , reduce = min )
324331
@@ -334,6 +341,9 @@ async def async_update(self):
334341 # Merge supported features by emulating support for every feature
335342 # we find.
336343 self ._supported_features |= support
344+ # Bitwise-and the supported features with the Grouped climate's features
345+ # so that we don't break in the future when a new feature is added.
346+ self ._supported_features &= SUPPORT_FLAGS
337347
338348 self ._preset_modes = None
339349 presets = []
@@ -342,12 +352,14 @@ async def async_update(self):
342352
343353 if len (presets ):
344354 self ._preset_modes = set (presets )
345- _LOGGER .debug ("State update complete" )
355+ _LOGGER .debug (
356+ f"State update complete. Supported: { self ._supported_features } , mode: { self ._mode } "
357+ )
346358
347359 async def async_set_preset_mode (self , preset_mode : str ):
348360 """Forward the preset_mode to all climate in the climate group."""
349361 data = {ATTR_ENTITY_ID : self ._entity_ids , ATTR_PRESET_MODE : preset_mode }
350-
362+
351363 await self .hass .services .async_call (
352364 climate .DOMAIN , climate .SERVICE_SET_PRESET_MODE , data , blocking = True
353365 )
0 commit comments