From e001b1243086202e5e5206b5875ec172a49e9b43 Mon Sep 17 00:00:00 2001 From: SukramJ Date: Sat, 3 Aug 2019 18:49:34 +0200 Subject: [PATCH] Add PRESET_AWAY to HomematicIP Cloud climate (#25641) * enable climate away_mode and home.refresh * Add Party eco modes --- .../components/homematicip_cloud/climate.py | 17 ++++++++++++++--- .../components/homematicip_cloud/hap.py | 11 ++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/homematicip_cloud/climate.py b/homeassistant/components/homematicip_cloud/climate.py index 53e7403ce56..794a8b44cbc 100644 --- a/homeassistant/components/homematicip_cloud/climate.py +++ b/homeassistant/components/homematicip_cloud/climate.py @@ -5,16 +5,19 @@ from typing import Awaitable 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 @@ class HomematicipHeatingGroup(HomematicipGenericDevice, ClimateDevice): if self._device.boostMode: return PRESET_BOOST if self._device.controlMode == HMIP_ECO_CM: - return PRESET_ECO + 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 None + 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 7418aa94d89..23973efb07b 100644 --- a/homeassistant/components/homematicip_cloud/hap.py +++ b/homeassistant/components/homematicip_cloud/hap.py @@ -110,10 +110,13 @@ class HomematicipHAP: 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 @@ class HomematicipHAP: 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."""