Allow preset boost for Homematic IP Cloud power switches (#28713)

* Allow preset boost for Homematic IP Cloud  power switches

* Sort Imports

* Add test

* align test data
This commit is contained in:
SukramJ 2019-11-12 11:32:32 +01:00 committed by Martin Hjelmare
parent 4f11eec1a1
commit e8348221d4
3 changed files with 46 additions and 8 deletions

View file

@ -5,6 +5,7 @@ from typing import Awaitable
from homematicip.aio.device import AsyncHeatingThermostat, AsyncHeatingThermostatCompact
from homematicip.aio.group import AsyncHeatingGroup
from homematicip.base.enums import AbsenceType
from homematicip.device import Switch
from homematicip.functionalHomes import IndoorClimateHome
from homeassistant.components.climate import ClimateDevice
@ -116,7 +117,7 @@ class HomematicipHeatingGroup(HomematicipGenericDevice, ClimateDevice):
@property
def hvac_mode(self) -> str:
"""Return hvac operation ie."""
if self._disabled_by_cooling_mode:
if self._disabled_by_cooling_mode and not self._has_switch:
return HVAC_MODE_OFF
if self._device.boostMode:
return HVAC_MODE_HEAT
@ -128,7 +129,7 @@ class HomematicipHeatingGroup(HomematicipGenericDevice, ClimateDevice):
@property
def hvac_modes(self):
"""Return the list of available hvac operation modes."""
if self._disabled_by_cooling_mode:
if self._disabled_by_cooling_mode and not self._has_switch:
return [HVAC_MODE_OFF]
return (
@ -168,7 +169,9 @@ class HomematicipHeatingGroup(HomematicipGenericDevice, ClimateDevice):
profile_names = self._device_profile_names
presets = []
if self._heat_mode_enabled and self._has_radiator_thermostat:
if (
self._heat_mode_enabled and self._has_radiator_thermostat
) or self._has_switch:
if not profile_names:
presets.append(PRESET_NONE)
presets.append(PRESET_BOOST)
@ -290,6 +293,15 @@ class HomematicipHeatingGroup(HomematicipGenericDevice, ClimateDevice):
return HEATING_PROFILES if self._heat_mode_enabled else COOLING_PROFILES
@property
def _has_switch(self) -> bool:
"""Return, if a switch is in the hmip heating group."""
for device in self._device.devices:
if isinstance(device, Switch):
return True
return False
@property
def _has_radiator_thermostat(self) -> bool:
"""Return, if a radiator thermostat is in the hmip heating group."""