From 5ce356d5f2573ebc1ef93b237706b0966499ac86 Mon Sep 17 00:00:00 2001 From: SukramJ Date: Tue, 28 Dec 2021 19:55:55 +0100 Subject: [PATCH] Climate IP: use calendar for duration away (#105) * climate IP; use calendar for duration away * update changelog --- changelog.txt | 1 + hahomematic/devices/climate.py | 50 +++++++++++++++++++--------------- setup.py | 2 +- 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/changelog.txt b/changelog.txt index e4262b64..fee6ce7f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,7 @@ Version 0.6.2 (2021-12-28) - Remove deleted entities from device and central collections - use datetime for last_events +- Climate IP: use calendar for duration away Version 0.6.1 (2021-12-27) - Display profiles only when hvac_mode auto is enabled diff --git a/hahomematic/devices/climate.py b/hahomematic/devices/climate.py index 2c22d39b..86361f66 100644 --- a/hahomematic/devices/climate.py +++ b/hahomematic/devices/climate.py @@ -1,7 +1,7 @@ """Code to create the required entities for thermostat devices.""" from __future__ import annotations -from datetime import datetime +from datetime import datetime, timedelta import logging from typing import Any @@ -37,7 +37,6 @@ HMIP_SET_POINT_MODE_MANU = 1 HMIP_SET_POINT_MODE_AWAY = 2 -AWAY_DURATION_UNIT_HOURS = 2 ATTR_TEMPERATURE = "temperature" HVAC_MODE_OFF = "off" HVAC_MODE_HEAT = "heat" @@ -186,6 +185,22 @@ async def set_preset_mode(self, preset_mode: str) -> None: """Set new preset mode.""" return None + async def enable_away_mode_by_calendar( + self, start: datetime, end: datetime, away_temperature: float + ) -> None: + """Enable the away mode by calendar on thermostat.""" + return None + + async def enable_away_mode_by_duration( + self, hours: int, away_temperature: float + ) -> None: + """Enable the away mode by duration on thermostat.""" + return None + + async def disable_away_mode(self) -> None: + """Disable the away mode on thermostat.""" + return None + def _get_entity_attribute( self, field_name: str, attr_name: str, default: float ) -> float: @@ -383,33 +398,16 @@ async def set_preset_mode(self, preset_mode: str) -> None: await self._send_value(FIELD_BOOST_MODE, False) await self._send_value(FIELD_ACTIVE_PROFILE, profile_idx) - async def enable_away_mode_by_duration( - self, hours: int, away_temperature: float - ) -> None: - """Set the away mode by duration on thermostat.""" - await self.put_paramset( - paramset="VALUES", - value={ - "CONTROL_MODE": HMIP_SET_POINT_MODE_AWAY, - "SET_POINT_TEMPERATURE": away_temperature, - "DURATION_UNIT": AWAY_DURATION_UNIT_HOURS, - "DURATION_VALUE": hours, - "PARTY_TIME_START": PARTY_INIT_DATE, - "PARTY_TIME_END": PARTY_INIT_DATE, - }, - ) - async def enable_away_mode_by_calendar( self, start: datetime, end: datetime, away_temperature: float ) -> None: - """Set the away mode by calendar on thermostat.""" + """Enable the away mode by calendar on thermostat.""" await self.put_paramset( paramset="VALUES", value={ "CONTROL_MODE": HMIP_SET_POINT_MODE_AWAY, "PARTY_TIME_END": end.strftime(PARTY_DATE_FORMAT), "PARTY_TIME_START": start.strftime(PARTY_DATE_FORMAT), - "DURATION_VALUE": 0, }, ) await self.put_paramset( @@ -419,15 +417,23 @@ async def enable_away_mode_by_calendar( }, ) + async def enable_away_mode_by_duration( + self, hours: int, away_temperature: float + ) -> None: + """Enable the away mode by duration on thermostat.""" + start = datetime.now() - timedelta(minutes=10) + end = datetime.now() + timedelta(hours=hours) + await self.enable_away_mode_by_calendar(start=start, end=end, away_temperature=away_temperature) + + async def disable_away_mode(self) -> None: - """Set the away mode on thermostat.""" + """Disable the away mode on thermostat.""" await self.put_paramset( paramset="VALUES", value={ "CONTROL_MODE": HMIP_SET_POINT_MODE_AUTO, "PARTY_TIME_START": PARTY_INIT_DATE, "PARTY_TIME_END": PARTY_INIT_DATE, - "DURATION_VALUE": 0, }, ) diff --git a/setup.py b/setup.py index 35941ba6..c081276c 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ def readme(): }, PACKAGE_NAME = "hahomematic" HERE = os.path.abspath(os.path.dirname(__file__)) -VERSION = "0.6.2" +VERSION = "0.7.0" PACKAGES = find_packages(exclude=["tests", "tests.*", "dist", "build"])