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

Commit

Permalink
ha 2022.11 compatibility +set_datetime service (#162)
Browse files Browse the repository at this point in the history
ha 2022.11 compatibility +set_datetime service
  • Loading branch information
thomasgermain authored Nov 6, 2022
1 parent fd0d430 commit ad986b0
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ For the `binary_sensor.multimtic_holiday`, when on, you have the start date, end
- `multimatic.request_hvac_update` to tell multimatic API to fetch data from your installation and made them available in the API
- `multimatic.set_ventilation_day_level` to set ventilation day level
- `multimatic.set_ventilation_night_level` to set ventilation night level
- `multimatic.set_datetime` to set the current date time of the system

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

Expand Down
3 changes: 2 additions & 1 deletion custom_components/multimatic/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
ATTR_TEMPERATURE = "temperature"
ATTR_DURATION = "duration"
ATTR_LEVEL = "level"
ATTR_DATE_TIME = "datetime"

SERVICES_HANDLER = "services_handler"

Expand Down Expand Up @@ -73,5 +74,5 @@
HVAC_STATUS: None,
FACILITY_DETAIL: timedelta(days=1),
GATEWAY: timedelta(days=1),
EMF_REPORTS: timedelta(minutes=30),
EMF_REPORTS: None,
}
10 changes: 7 additions & 3 deletions custom_components/multimatic/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ async def set_fan_night_level(self, entity, level):
"""Set fan night level."""
await self._manager.set_ventilation_night_level(entity.component.id, level)

async def set_datetime(self, datetime):
"""Set datetime."""
await self._manager.set_datetime(datetime)

async def _remove_quick_mode_no_refresh(self, entity=None):
removed = False

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

async def _hard_set_quick_mode(
self, mode: str | QuickMode, duration: int = None
self, mode: str | QuickMode, duration: int | None = None
) -> QuickMode:
new_mode: QuickMode

Expand Down Expand Up @@ -489,8 +493,8 @@ def __init__(

def find_component(
self, comp_id
) -> Room | Zone | Ventilation | HotWater | Circulation:
"""Find component by it's id."""
) -> Room | Zone | Ventilation | HotWater | Circulation | None:
"""Find component by its id."""
for comp in self.data:
if comp.id == comp_id:
return comp
Expand Down
8 changes: 3 additions & 5 deletions custom_components/multimatic/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
"documentation": "https://github.com/thomasgermain/vaillant-component",
"issue_tracker": "https://github.com/thomasgermain/vaillant-component/issues",
"requirements": [
"pymultimatic==0.6.8"
"pymultimatic==0.6.10"
],
"ssdp": [],
"zeroconf": [],
"homekit": {},
"dependencies": [],
"codeowners": [
"@thomasgermain"
],
"version": "1.12.7",
"codeowners": ["@thomasgermain"],
"version": "1.12.9",
"iot_class": "cloud_polling"
}
6 changes: 3 additions & 3 deletions custom_components/multimatic/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
SensorEntity,
SensorStateClass,
)
from homeassistant.const import ENERGY_WATT_HOUR, TEMP_CELSIUS
from homeassistant.const import UnitOfEnergy, UnitOfTemperature
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.typing import StateType

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

@property
def name(self) -> str:
Expand Down Expand Up @@ -204,7 +204,7 @@ def available(self):
@property
def native_unit_of_measurement(self) -> str | None:
"""Return the unit of measurement of this entity, if any."""
return ENERGY_WATT_HOUR
return UnitOfEnergy.WATT_HOUR

@property
def device_info(self):
Expand Down
16 changes: 16 additions & 0 deletions custom_components/multimatic/service.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
"""multimatic services."""
import datetime
import logging

from pymultimatic.model import QuickMode, QuickModes
import voluptuous as vol

from homeassistant.const import ATTR_ENTITY_ID
import homeassistant.helpers.config_validation as cv
from homeassistant.util.dt import parse_date

from .const import (
ATTR_DATE_TIME,
ATTR_DURATION,
ATTR_END_DATE,
ATTR_LEVEL,
Expand All @@ -32,6 +35,7 @@
SERVICE_REQUEST_HVAC_UPDATE = "request_hvac_update"
SERVICE_SET_VENTILATION_DAY_LEVEL = "set_ventilation_day_level"
SERVICE_SET_VENTILATION_NIGHT_LEVEL = "set_ventilation_night_level"
SERVICE_SET_DATETIME = "set_datetime"

SERVICE_REMOVE_QUICK_MODE_SCHEMA = vol.Schema({})
SERVICE_REMOVE_HOLIDAY_MODE_SCHEMA = vol.Schema({})
Expand Down Expand Up @@ -77,6 +81,12 @@

SERVICE_SET_VENTILATION_NIGHT_LEVEL_SCHEMA = SERVICE_SET_VENTILATION_DAY_LEVEL_SCHEMA

SERVICE_SET_DATETIME_SCHEMA = vol.Schema(
{
vol.Optional(ATTR_DATE_TIME): cv.datetime,
}
)

SERVICES = {
SERVICE_REMOVE_QUICK_MODE: {
"schema": SERVICE_REMOVE_QUICK_MODE_SCHEMA,
Expand Down Expand Up @@ -106,6 +116,7 @@
"schema": SERVICE_SET_VENTILATION_DAY_LEVEL_SCHEMA,
"entity": True,
},
SERVICE_SET_DATETIME: {"schema": SERVICE_SET_DATETIME_SCHEMA},
}


Expand Down Expand Up @@ -151,3 +162,8 @@ async def set_quick_mode(self, data):
async def request_hvac_update(self, data):
"""Ask multimatic API to get data from the installation."""
await self.api.request_hvac_update()

async def set_datetime(self, data):
"""Set date time."""
date_t: datetime = data.get(ATTR_DATE_TIME, datetime.datetime.now())
await self.api.set_datetime(date_t)
70 changes: 69 additions & 1 deletion custom_components/multimatic/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,83 @@ set_quick_mode:
quick_mode:
description: Name of the quick mode (required)
example: QM_HOTWATER_BOOST, QM_VENTILATION_BOOST, QM_ONE_DAY_AWAY, QM_SYSTEM_OFF, QM_ONE_DAY_AT_HOME, QM_PARTY
selector:
select:
options:
- QM_HOTWATER_BOOST
- QM_VENTILATION_BOOST
- QM_ONE_DAY_AWAY
- QM_SYSTEM_OFF
- QM_ONE_DAY_AT_HOME
- QM_PARTY
duration:
description: (int) number of days the quick mode should last
example: 3
selector:
number:
min: 0
max: 7
mode: box

set_holiday_mode:
description: Set holiday mode
fields:
start_date:
description: Start date of the holiday mode YYYY-MM-DD format (required)
example: "2019-11-25"
selector:
date:
end_date:
description: End date of the holiday mode, YYYY-MM-DD format (required)
example: "2019-11-26"
selector:
date:
temperature:
description: temperature to maintin while holiday mode is active (required)
example: 15
selector:
number:
min: 5
max: 30
mode: box

set_quick_veto:
description: Set a quick veto for a climate entity
fields:
entity_id:
description: Entity id from where to set a quick veto
example: climate.bathroom
selector:
entity:
integration: multimatic
domain: climate
temperature:
description: Target temperature to be applied while quick veto is running on
example: 25
selector:
number:
min: 5
max: 30
mode: box
duration:
description: Duration (in minutes) of the quick veto. Min 30min, max 1440 (24 hours). If not specified, the default (configured) duration is applied.
example: "60"
example: 60
selector:
number:
min: 30
max: 1440
mode: box

remove_quick_veto:
description: Remove a quick veto for a climate entity
fields:
entity_id:
description: Entity id from where to remove quick veto
example: climate.bathroom
selector:
entity:
integration: multimatic
domain: climate

request_hvac_update:
description: Ask multimatic API to get data from your installation.
Expand All @@ -56,16 +97,43 @@ set_ventilation_day_level:
entity_id:
description: Entity id of the fan
example: fan.bathroom
selector:
entity:
integration: multimatic
domain: fan
level:
description: Level to set (required)
example: 1
selector:
number:
min: 1
max: 7
mode: box

set_ventilation_night_level:
description: Set night level ventilation
fields:
entity_id:
description: Entity id of the fan
example: fan.bathroom
selector:
entity:
integration: multimatic
domain: fan
level:
description: Level to set (required)
example: 2
selector:
number:
min: 1
max: 7
mode: box

set_datetime:
description: Set multimatic system datetime
fields:
datetime:
description: datetime to set
example: 2022-11-06T11:11:38
selector:
datetime:
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "multimatic",
"render_readme": true,
"homeassistant": "2022.5.0"
"homeassistant": "2022.11.0"
}

0 comments on commit ad986b0

Please sign in to comment.