Skip to content

Commit

Permalink
Climate IP: use calendar for duration away (#105)
Browse files Browse the repository at this point in the history
* climate IP; use calendar for duration away

* update changelog
  • Loading branch information
SukramJ authored Dec 28, 2021
1 parent fe3a6ba commit 5ce356d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 23 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
50 changes: 28 additions & 22 deletions hahomematic/devices/climate.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand All @@ -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,
},
)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down

0 comments on commit 5ce356d

Please sign in to comment.