diff --git a/homeassistant/components/homematicip_cloud/climate.py b/homeassistant/components/homematicip_cloud/climate.py index 53e7403ce56ab5..794a8b44cbcdd5 100644 --- a/homeassistant/components/homematicip_cloud/climate.py +++ b/homeassistant/components/homematicip_cloud/climate.py @@ -5,16 +5,19 @@ from homematicip.aio.device import AsyncHeatingThermostat, AsyncHeatingThermostatCompact from homematicip.aio.group import AsyncHeatingGroup from homematicip.aio.home import AsyncHome +from homematicip.base.enums import AbsenceType +from homematicip.functionalHomes import IndoorClimateHome from homeassistant.components.climate import ClimateDevice from homeassistant.components.climate.const import ( HVAC_MODE_AUTO, HVAC_MODE_HEAT, + PRESET_AWAY, PRESET_BOOST, PRESET_ECO, + PRESET_NONE, SUPPORT_PRESET_MODE, SUPPORT_TARGET_TEMPERATURE, - PRESET_NONE, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS @@ -116,9 +119,17 @@ def preset_mode(self): if self._device.boostMode: return PRESET_BOOST if self._device.controlMode == HMIP_ECO_CM: - return PRESET_ECO - - return None + absence_type = self._home.get_functionalHome(IndoorClimateHome).absenceType + if absence_type == AbsenceType.VACATION: + return PRESET_AWAY + if absence_type in [ + AbsenceType.PERIOD, + AbsenceType.PERMANENT, + AbsenceType.PARTY, + ]: + return PRESET_ECO + + return PRESET_NONE @property def preset_modes(self): diff --git a/homeassistant/components/homematicip_cloud/hap.py b/homeassistant/components/homematicip_cloud/hap.py index 7418aa94d89666..23973efb07b1c7 100644 --- a/homeassistant/components/homematicip_cloud/hap.py +++ b/homeassistant/components/homematicip_cloud/hap.py @@ -110,10 +110,13 @@ def async_update(self, *args, **kwargs): Triggered when the HMIP HOME_CHANGED event has fired. There are several occasions for this event to happen. - We are only interested to check whether the access point + 1. We are interested to check whether the access point is still connected. If not, device state changes cannot be forwarded to hass. So if access point is disconnected all devices are set to unavailable. + 2. We need to update home including devices and groups after a reconnect. + 3. We need to update home without devices and groups in all other cases. + """ if not self.home.connected: _LOGGER.error("HMIP access point has lost connection with the cloud") @@ -127,6 +130,12 @@ def async_update(self, *args, **kwargs): job = self.hass.async_create_task(self.get_state()) job.add_done_callback(self.get_state_finished) + self._accesspoint_connected = True + else: + # Update home with the given json from arg[0], + # without devices and groups. + + self.home.update_home_only(args[0]) async def get_state(self): """Update HMIP state and tell Home Assistant."""