Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit ad986b0

Browse files
ha 2022.11 compatibility +set_datetime service (#162)
ha 2022.11 compatibility +set_datetime service
1 parent fd0d430 commit ad986b0

File tree

8 files changed

+102
-14
lines changed

8 files changed

+102
-14
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ For the `binary_sensor.multimtic_holiday`, when on, you have the start date, end
7575
- `multimatic.request_hvac_update` to tell multimatic API to fetch data from your installation and made them available in the API
7676
- `multimatic.set_ventilation_day_level` to set ventilation day level
7777
- `multimatic.set_ventilation_night_level` to set ventilation night level
78+
- `multimatic.set_datetime` to set the current date time of the system
7879

7980
This will allow you to create some buttons in UI to activate/deactivate quick mode or holiday mode with a single click
8081

custom_components/multimatic/const.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
ATTR_TEMPERATURE = "temperature"
4343
ATTR_DURATION = "duration"
4444
ATTR_LEVEL = "level"
45+
ATTR_DATE_TIME = "datetime"
4546

4647
SERVICES_HANDLER = "services_handler"
4748

@@ -73,5 +74,5 @@
7374
HVAC_STATUS: None,
7475
FACILITY_DETAIL: timedelta(days=1),
7576
GATEWAY: timedelta(days=1),
76-
EMF_REPORTS: timedelta(minutes=30),
77+
EMF_REPORTS: None,
7778
}

custom_components/multimatic/coordinator.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,10 @@ async def set_fan_night_level(self, entity, level):
394394
"""Set fan night level."""
395395
await self._manager.set_ventilation_night_level(entity.component.id, level)
396396

397+
async def set_datetime(self, datetime):
398+
"""Set datetime."""
399+
await self._manager.set_datetime(datetime)
400+
397401
async def _remove_quick_mode_no_refresh(self, entity=None):
398402
removed = False
399403

@@ -413,7 +417,7 @@ async def _hard_remove_quick_mode(self):
413417
self._quick_mode = None
414418

415419
async def _hard_set_quick_mode(
416-
self, mode: str | QuickMode, duration: int = None
420+
self, mode: str | QuickMode, duration: int | None = None
417421
) -> QuickMode:
418422
new_mode: QuickMode
419423

@@ -489,8 +493,8 @@ def __init__(
489493

490494
def find_component(
491495
self, comp_id
492-
) -> Room | Zone | Ventilation | HotWater | Circulation:
493-
"""Find component by it's id."""
496+
) -> Room | Zone | Ventilation | HotWater | Circulation | None:
497+
"""Find component by its id."""
494498
for comp in self.data:
495499
if comp.id == comp_id:
496500
return comp

custom_components/multimatic/manifest.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
"documentation": "https://github.com/thomasgermain/vaillant-component",
66
"issue_tracker": "https://github.com/thomasgermain/vaillant-component/issues",
77
"requirements": [
8-
"pymultimatic==0.6.8"
8+
"pymultimatic==0.6.10"
99
],
1010
"ssdp": [],
1111
"zeroconf": [],
1212
"homekit": {},
1313
"dependencies": [],
14-
"codeowners": [
15-
"@thomasgermain"
16-
],
17-
"version": "1.12.7",
14+
"codeowners": ["@thomasgermain"],
15+
"version": "1.12.9",
1816
"iot_class": "cloud_polling"
1917
}

custom_components/multimatic/sensor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
SensorEntity,
1313
SensorStateClass,
1414
)
15-
from homeassistant.const import ENERGY_WATT_HOUR, TEMP_CELSIUS
15+
from homeassistant.const import UnitOfEnergy, UnitOfTemperature
1616
from homeassistant.helpers.entity import EntityCategory
1717
from homeassistant.helpers.typing import StateType
1818

@@ -75,7 +75,7 @@ def available(self):
7575
@property
7676
def native_unit_of_measurement(self) -> str | None:
7777
"""Return the unit of measurement of this entity, if any."""
78-
return TEMP_CELSIUS
78+
return UnitOfTemperature.CELSIUS
7979

8080
@property
8181
def name(self) -> str:
@@ -204,7 +204,7 @@ def available(self):
204204
@property
205205
def native_unit_of_measurement(self) -> str | None:
206206
"""Return the unit of measurement of this entity, if any."""
207-
return ENERGY_WATT_HOUR
207+
return UnitOfEnergy.WATT_HOUR
208208

209209
@property
210210
def device_info(self):

custom_components/multimatic/service.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
"""multimatic services."""
2+
import datetime
23
import logging
34

45
from pymultimatic.model import QuickMode, QuickModes
56
import voluptuous as vol
67

78
from homeassistant.const import ATTR_ENTITY_ID
9+
import homeassistant.helpers.config_validation as cv
810
from homeassistant.util.dt import parse_date
911

1012
from .const import (
13+
ATTR_DATE_TIME,
1114
ATTR_DURATION,
1215
ATTR_END_DATE,
1316
ATTR_LEVEL,
@@ -32,6 +35,7 @@
3235
SERVICE_REQUEST_HVAC_UPDATE = "request_hvac_update"
3336
SERVICE_SET_VENTILATION_DAY_LEVEL = "set_ventilation_day_level"
3437
SERVICE_SET_VENTILATION_NIGHT_LEVEL = "set_ventilation_night_level"
38+
SERVICE_SET_DATETIME = "set_datetime"
3539

3640
SERVICE_REMOVE_QUICK_MODE_SCHEMA = vol.Schema({})
3741
SERVICE_REMOVE_HOLIDAY_MODE_SCHEMA = vol.Schema({})
@@ -77,6 +81,12 @@
7781

7882
SERVICE_SET_VENTILATION_NIGHT_LEVEL_SCHEMA = SERVICE_SET_VENTILATION_DAY_LEVEL_SCHEMA
7983

84+
SERVICE_SET_DATETIME_SCHEMA = vol.Schema(
85+
{
86+
vol.Optional(ATTR_DATE_TIME): cv.datetime,
87+
}
88+
)
89+
8090
SERVICES = {
8191
SERVICE_REMOVE_QUICK_MODE: {
8292
"schema": SERVICE_REMOVE_QUICK_MODE_SCHEMA,
@@ -106,6 +116,7 @@
106116
"schema": SERVICE_SET_VENTILATION_DAY_LEVEL_SCHEMA,
107117
"entity": True,
108118
},
119+
SERVICE_SET_DATETIME: {"schema": SERVICE_SET_DATETIME_SCHEMA},
109120
}
110121

111122

@@ -151,3 +162,8 @@ async def set_quick_mode(self, data):
151162
async def request_hvac_update(self, data):
152163
"""Ask multimatic API to get data from the installation."""
153164
await self.api.request_hvac_update()
165+
166+
async def set_datetime(self, data):
167+
"""Set date time."""
168+
date_t: datetime = data.get(ATTR_DATE_TIME, datetime.datetime.now())
169+
await self.api.set_datetime(date_t)

custom_components/multimatic/services.yaml

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,83 @@ set_quick_mode:
1010
quick_mode:
1111
description: Name of the quick mode (required)
1212
example: QM_HOTWATER_BOOST, QM_VENTILATION_BOOST, QM_ONE_DAY_AWAY, QM_SYSTEM_OFF, QM_ONE_DAY_AT_HOME, QM_PARTY
13+
selector:
14+
select:
15+
options:
16+
- QM_HOTWATER_BOOST
17+
- QM_VENTILATION_BOOST
18+
- QM_ONE_DAY_AWAY
19+
- QM_SYSTEM_OFF
20+
- QM_ONE_DAY_AT_HOME
21+
- QM_PARTY
1322
duration:
1423
description: (int) number of days the quick mode should last
1524
example: 3
25+
selector:
26+
number:
27+
min: 0
28+
max: 7
29+
mode: box
1630

1731
set_holiday_mode:
1832
description: Set holiday mode
1933
fields:
2034
start_date:
2135
description: Start date of the holiday mode YYYY-MM-DD format (required)
2236
example: "2019-11-25"
37+
selector:
38+
date:
2339
end_date:
2440
description: End date of the holiday mode, YYYY-MM-DD format (required)
2541
example: "2019-11-26"
42+
selector:
43+
date:
2644
temperature:
2745
description: temperature to maintin while holiday mode is active (required)
2846
example: 15
47+
selector:
48+
number:
49+
min: 5
50+
max: 30
51+
mode: box
2952

3053
set_quick_veto:
3154
description: Set a quick veto for a climate entity
3255
fields:
3356
entity_id:
3457
description: Entity id from where to set a quick veto
3558
example: climate.bathroom
59+
selector:
60+
entity:
61+
integration: multimatic
62+
domain: climate
3663
temperature:
3764
description: Target temperature to be applied while quick veto is running on
3865
example: 25
66+
selector:
67+
number:
68+
min: 5
69+
max: 30
70+
mode: box
3971
duration:
4072
description: Duration (in minutes) of the quick veto. Min 30min, max 1440 (24 hours). If not specified, the default (configured) duration is applied.
41-
example: "60"
73+
example: 60
74+
selector:
75+
number:
76+
min: 30
77+
max: 1440
78+
mode: box
4279

4380
remove_quick_veto:
4481
description: Remove a quick veto for a climate entity
4582
fields:
4683
entity_id:
4784
description: Entity id from where to remove quick veto
4885
example: climate.bathroom
86+
selector:
87+
entity:
88+
integration: multimatic
89+
domain: climate
4990

5091
request_hvac_update:
5192
description: Ask multimatic API to get data from your installation.
@@ -56,16 +97,43 @@ set_ventilation_day_level:
5697
entity_id:
5798
description: Entity id of the fan
5899
example: fan.bathroom
100+
selector:
101+
entity:
102+
integration: multimatic
103+
domain: fan
59104
level:
60105
description: Level to set (required)
61106
example: 1
107+
selector:
108+
number:
109+
min: 1
110+
max: 7
111+
mode: box
62112

63113
set_ventilation_night_level:
64114
description: Set night level ventilation
65115
fields:
66116
entity_id:
67117
description: Entity id of the fan
68118
example: fan.bathroom
119+
selector:
120+
entity:
121+
integration: multimatic
122+
domain: fan
69123
level:
70124
description: Level to set (required)
71125
example: 2
126+
selector:
127+
number:
128+
min: 1
129+
max: 7
130+
mode: box
131+
132+
set_datetime:
133+
description: Set multimatic system datetime
134+
fields:
135+
datetime:
136+
description: datetime to set
137+
example: 2022-11-06T11:11:38
138+
selector:
139+
datetime:

hacs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "multimatic",
33
"render_readme": true,
4-
"homeassistant": "2022.5.0"
4+
"homeassistant": "2022.11.0"
55
}

0 commit comments

Comments
 (0)