Skip to content

Commit

Permalink
Added water heater time program & circulation pump time program servi…
Browse files Browse the repository at this point in the history
…ces, updated docs, changed pinning of dev requirements
  • Loading branch information
signalkraft committed Oct 29, 2023
1 parent 3a6497f commit 1d76b46
Show file tree
Hide file tree
Showing 11 changed files with 242 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ repos:
- aioresponses
- pytest
- types-requests
- myPyllant==0.5.11
- myPyllant==0.5.12
- polyfactory
- repo: local
hooks:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ because of this library.

* Supports climate & hot water controls, as well as sensor information
* Control operating modes, target temperature, and presets such as holiday more or quick veto
* Set the schedule for climate zones with a custom service
* Set the schedule for climate zones, water heaters, and circulation pumps with [a custom service](https://signalkraft.com/mypyllant-component/1-automations/#setting-a-time-program)
* Track sensor information of devices, such as temperature, humidity, operating mode, energy usage, or energy efficiency
* See diagnostic information, such as the current heating curve, flow temperature, firmware versions, or water pressure
* Custom services to set holiday mode or quick veto temperature overrides, and their duration
Expand Down
4 changes: 2 additions & 2 deletions custom_components/mypyllant/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
)
from myPyllant.models import (
System,
TimeProgramHeating,
Zone,
ZoneCurrentSpecialFunction,
ZoneHeatingOperatingMode,
ZoneTimeProgram,
)

from . import SystemCoordinator
Expand Down Expand Up @@ -249,7 +249,7 @@ async def cancel_holiday(self):
async def set_zone_time_program(self, **kwargs):
_LOGGER.debug("Canceling holiday on System %s", self.system.id)
program_type = kwargs.get("program_type")
time_program = TimeProgramHeating.from_api(**kwargs.get("time_program"))
time_program = ZoneTimeProgram.from_api(**kwargs.get("time_program"))
await self.coordinator.api.set_zone_time_program(
self.zone, program_type, time_program
)
Expand Down
2 changes: 2 additions & 0 deletions custom_components/mypyllant/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
SERVICE_SET_HOLIDAY = "set_holiday"
SERVICE_CANCEL_HOLIDAY = "cancel_holiday"
SERVICE_SET_ZONE_TIME_PROGRAM = "set_zone_time_program"
SERVICE_SET_DHW_TIME_PROGRAM = "set_dhw_time_program"
SERVICE_SET_DHW_CIRCULATION_TIME_PROGRAM = "set_dhw_circulation_time_program"
4 changes: 2 additions & 2 deletions custom_components/mypyllant/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"integration_type": "hub",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/signalkraft/issues",
"requirements": ["myPyllant==0.5.11"],
"version": "0.5.3"
"requirements": ["myPyllant==0.5.12"],
"version": "0.5.4"
}
69 changes: 68 additions & 1 deletion custom_components/mypyllant/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,71 @@ set_zone_time_program:
- start_time: 420
end_time: 1290
setpoint: 20
type: heating
set_dhw_time_program:
name: Set Water Heater Time Program
description: Updates the time program for a water heater
target:
entity:
integration: mypyllant
domain: water_heater
fields:
time_program:
name: Time Program
description: A dictionary of days with a list of start_time and end_time
example: >
monday:
- start_time: 330
end_time: 1260
tuesday:
- start_time: 330
end_time: 1260
wednesday:
- start_time: 330
end_time: 1260
thursday:
- start_time: 330
end_time: 1260
friday:
- start_time: 330
end_time: 1260
saturday:
- start_time: 450
end_time: 1260
sunday:
- start_time: 450
end_time: 1260
set_dhw_circulation_time_program:
name: Set Water Heater Circulation Time Program
description: Updates the time program for the circulation pump of a water heater
target:
entity:
integration: mypyllant
domain: water_heater
fields:
time_program:
name: Time Program
description: A dictionary of days with a list of start_time and end_time
example: >
monday:
- start_time: 330
end_time: 1260
tuesday:
- start_time: 330
end_time: 1260
wednesday:
- start_time: 330
end_time: 1260
thursday:
- start_time: 330
end_time: 1260
friday:
- start_time: 330
end_time: 1260
saturday:
- start_time: 450
end_time: 1260
sunday:
- start_time: 450
end_time: 1260
40 changes: 39 additions & 1 deletion custom_components/mypyllant/water_heater.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
import logging
from typing import Any

import voluptuous as vol
from homeassistant.components.water_heater import (
WaterHeaterEntity,
WaterHeaterEntityFeature,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_platform
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from myPyllant.models import (
DHWCurrentSpecialFunction,
DHWOperationMode,
DHWTimeProgram,
DomesticHotWater,
System,
)

from . import SystemCoordinator
from .const import DOMAIN
from .const import (
DOMAIN,
SERVICE_SET_DHW_CIRCULATION_TIME_PROGRAM,
SERVICE_SET_DHW_TIME_PROGRAM,
)

_LOGGER = logging.getLogger(__name__)

Expand All @@ -42,6 +49,23 @@ async def async_setup_entry(
dhws.append(DomesticHotWaterEntity(index, dhw_index, coordinator))

async_add_entities(dhws)
if len(dhws) > 0:
platform = entity_platform.async_get_current_platform()
_LOGGER.debug("Setting up water heater entity services for %s", platform)
platform.async_register_entity_service(
SERVICE_SET_DHW_TIME_PROGRAM,
{
vol.Required("time_program"): vol.All(dict),
},
"set_dhw_time_program",
)
platform.async_register_entity_service(
SERVICE_SET_DHW_CIRCULATION_TIME_PROGRAM,
{
vol.Required("time_program"): vol.All(dict),
},
"set_dhw_circulation_time_program",
)


class DomesticHotWaterEntity(CoordinatorEntity, WaterHeaterEntity):
Expand Down Expand Up @@ -154,3 +178,17 @@ async def async_set_operation_mode(
DHWOperationMode(enum_value),
)
await self.coordinator.async_request_refresh_delayed()

async def set_dhw_time_program(self, **kwargs):
time_program = DHWTimeProgram.from_api(**kwargs.get("time_program"))
await self.coordinator.api.set_domestic_hot_water_time_program(
self.domestic_hot_water, time_program
)
await self.coordinator.async_request_refresh_delayed()

async def set_dhw_circulation_time_program(self, **kwargs):
time_program = DHWTimeProgram.from_api(**kwargs.get("time_program"))
await self.coordinator.api.set_domestic_hot_water_circulation_time_program(
self.domestic_hot_water, time_program
)
await self.coordinator.async_request_refresh_delayed()
31 changes: 16 additions & 15 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
myPyllant==0.5.11
aioresponses==0.7.4
coverage>=6.3.1
croniter>=1.3.8
freezegun==1.2.2
watchdog>=2.0.3
mock-open==1.4.0
mypy>=0.991
pre-commit>=2.21.0
pytest>=7.0.1
pytest-cov>=2.9.0
aioresponses~=0.7.4
croniter~=1.3.8
freezegun~=1.2.2
watchdog~=2.0.3
mock-open~=1.4.0
mypy~=0.991
pre-commit~=2.21.0
pylint~=2.15.0
pylint-strict-informational~=0.1
polyfactory~=2.9.0
pytest-asyncio~=0.21.0

# Need specific versions
pytest==7.3.1
pytest-cov==4.1.0
pytest-homeassistant-custom-component==0.13.56
pylint>=2.15.0
pylint-strict-informational>=0.1
polyfactory==2.9.0
pytest-asyncio==0.21.0
myPyllant==0.5.12
144 changes: 105 additions & 39 deletions docs/docs/1-automations.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,45 +46,111 @@ mode: single
## Setting a Time Program
Call the [mypyllant.time_program_heating service](https://my.home-assistant.io/redirect/developer_services/) with a `program_type`
and a `time_program`.
Call the `mypyllant.set_zone_time_program` (for climate) `mypyllant.set_dhw_time_program` (for water heaters)
with a `program_type` (only on climate) and a `time_program`.

```yaml
service: mypyllant.set_zone_time_program
data:
program_type: heating
time_program:
monday:
- start_time: 420
end_time: 1290
setpoint: 20
tuesday:
- start_time: 420
end_time: 1290
setpoint: 20
wednesday:
- start_time: 420
end_time: 1290
setpoint: 20
thursday:
- start_time: 420
end_time: 1290
setpoint: 20
friday:
- start_time: 420
end_time: 1290
setpoint: 20
saturday:
- start_time: 420
end_time: 1290
setpoint: 20
sunday:
- start_time: 420
end_time: 1290
setpoint: 20
type: heating
target:
entity_id: climate.zone_0
```
=== "Climate"

```yaml
service: mypyllant.set_zone_time_program
data:
program_type: heating
time_program:
monday:
- start_time: 420
end_time: 1290
setpoint: 20
tuesday:
- start_time: 420
end_time: 1290
setpoint: 20
wednesday:
- start_time: 420
end_time: 1290
setpoint: 20
thursday:
- start_time: 420
end_time: 1290
setpoint: 20
friday:
- start_time: 420
end_time: 1290
setpoint: 20
saturday:
- start_time: 420
end_time: 1290
setpoint: 20
sunday:
- start_time: 420
end_time: 1290
setpoint: 20
type: heating
target:
entity_id: climate.zone_0
```

=== "Water Heater"

```yaml
service: mypyllant.set_dhw_time_program
data:
time_program:
monday:
- start_time: 420
end_time: 1290
tuesday:
- start_time: 420
end_time: 1290
wednesday:
- start_time: 420
end_time: 1290
thursday:
- start_time: 420
end_time: 1290
friday:
- start_time: 420
end_time: 1290
saturday:
- start_time: 420
end_time: 1290
sunday:
- start_time: 420
end_time: 1290
type: heating
target:
entity_id: water_heater.domestic_hot_water_0
```

=== "Circulation Pump"

```yaml
service: mypyllant.set_dhw_circulation_time_program
data:
time_program:
monday:
- start_time: 420
end_time: 1290
tuesday:
- start_time: 420
end_time: 1290
wednesday:
- start_time: 420
end_time: 1290
thursday:
- start_time: 420
end_time: 1290
friday:
- start_time: 420
end_time: 1290
saturday:
- start_time: 420
end_time: 1290
sunday:
- start_time: 420
end_time: 1290
type: heating
target:
entity_id: water_heater.domestic_hot_water_0
```

[^1]: Contributed by CommanderROR in the [Home Assistant Community](https://community.home-assistant.io/t/myvaillant-integration/542610/70)
3 changes: 2 additions & 1 deletion docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ Uses the [myPyllant library](https://github.com/signalkraft/mypyllant).

* Supports climate & hot water controls, as well as sensor information
* Control operating modes, target temperature, and presets such as holiday more or quick veto
* Set the schedule for climate zones, water heaters, and circulation pumps with [a custom service](https://signalkraft.com/mypyllant-component/1-automations/#setting-a-time-program)
* Track sensor information of devices, such as temperature, humidity, operating mode, energy usage, or energy efficiency
* See diagnostic information, such as the current heating curve, flow temperature, or water pressure
* See diagnostic information, such as the current heating curve, flow temperature, firmware versions, or water pressure
* Custom services to set holiday mode or quick veto temperature overrides, and their duration

## Options
Expand Down
Loading

0 comments on commit 1d76b46

Please sign in to comment.