Skip to content

Commit

Permalink
feat: new climate presets
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasgermain committed Dec 16, 2023
1 parent bcdebfe commit 326ddf5
Show file tree
Hide file tree
Showing 12 changed files with 393 additions and 231 deletions.
27 changes: 26 additions & 1 deletion homeassistant/components/multimatic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@
import logging

from pymultimatic.api import ApiError, defaults
import voluptuous as vol

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_SCAN_INTERVAL, EVENT_HOMEASSISTANT_STOP
from homeassistant.const import (
CONF_PASSWORD,
CONF_SCAN_INTERVAL,
CONF_USERNAME,
EVENT_HOMEASSISTANT_STOP,
)
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.typing import ConfigType

Expand All @@ -19,15 +26,33 @@
DEFAULT_SCAN_INTERVAL,
DOMAIN,
FORCE_RELOGIN_TIMEDELTA,
MULTIMATIC,
PLATFORMS,
RELOGIN_TASK_CLEAN,
SENSO,
SERVICES_HANDLER,
)
from .coordinator import MultimaticApi, MultimaticCoordinator
from .service import SERVICES, MultimaticServiceHandler

_LOGGER = logging.getLogger(__name__)

DATA_SCHEMA = vol.Schema(
{
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
vol.Optional(CONF_SERIAL_NUMBER): cv.string,
vol.Required(CONF_APPLICATION, default=MULTIMATIC): cv.ensure_list(
[MULTIMATIC, SENSO]
),
}
)

CONFIG_SCHEMA = vol.Schema(
{DOMAIN: DATA_SCHEMA},
extra=vol.ALLOW_EXTRA,
)


async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the multimatic integration."""
Expand Down
27 changes: 19 additions & 8 deletions homeassistant/components/multimatic/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
DEFAULT_QUICK_VETO_DURATION,
DHW,
DOMAIN as MULTIMATIC,
PRESET_COOLING_ON,
PRESET_QUICK_VETO,
PRESET_SYSTEM_OFF,
ROOMS,
Expand All @@ -65,6 +64,12 @@
ActiveFunction.STANDBY: HVACAction.IDLE,
}

_FUNCTION_TO_HVAC_MODE: dict[ActiveFunction, HVACMode] = {
ActiveFunction.COOLING: HVACMode.COOL,
ActiveFunction.HEATING: HVACMode.HEAT,
ActiveFunction.STANDBY: HVACMode.OFF,
}


async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
Expand Down Expand Up @@ -432,7 +437,10 @@ def component(self) -> Zone:
@property
def hvac_mode(self) -> HVACMode:
"""Get the hvac mode based on multimatic mode."""
return self._multimatic_mode()[self.active_mode.current][0]
hvac_mode = self._multimatic_mode()[self.active_mode.current][0]
if not hvac_mode: # if no hvac mode defined, guess it from zone function
return _FUNCTION_TO_HVAC_MODE[self.component.active_function]
return hvac_mode

@property
def min_temp(self) -> float:
Expand Down Expand Up @@ -482,7 +490,10 @@ class ZoneClimate(AbstractZoneClimate):
OperatingModes.DAY: [HVACMode.HEAT, PRESET_HOME],
OperatingModes.NIGHT: [HVACMode.OFF, PRESET_SLEEP],
OperatingModes.OFF: [HVACMode.OFF, PRESET_NONE],
OperatingModes.ON: [HVACMode.COOL, PRESET_COOLING_ON],
OperatingModes.ON: [
None,
PRESET_NONE,
], # can be heating or cooling, this is determined at runtime
OperatingModes.QUICK_VETO: [HVACMode.HEAT, PRESET_QUICK_VETO],
QuickModes.ONE_DAY_AT_HOME: [HVACMode.AUTO, PRESET_HOME],
QuickModes.PARTY: [HVACMode.OFF, PRESET_HOME],
Expand Down Expand Up @@ -524,11 +535,10 @@ class ZoneClimateSenso(AbstractZoneClimate):
OperatingModes.DAY: [HVACMode.HEAT, PRESET_HOME],
OperatingModes.NIGHT: [HVACMode.OFF, PRESET_SLEEP],
OperatingModes.OFF: [HVACMode.OFF, PRESET_NONE],
OperatingModes.MANUAL: [HVACMode.COOL, PRESET_COOLING_ON],
OperatingModes.QUICK_VETO: [HVACMode.HEAT, PRESET_QUICK_VETO],
QuickModes.ONE_DAY_AT_HOME: [HVACMode.AUTO, PRESET_HOME],
QuickModes.PARTY: [HVACMode.OFF, PRESET_HOME],
QuickModes.VENTILATION_BOOST: [HVACMode.FAN_ONLY, PRESET_NONE],
OperatingModes.MANUAL: [
None,
PRESET_NONE,
], # can be heating or cooling, this is determined at runtime
QuickModes.ONE_DAY_AWAY: [HVACMode.OFF, PRESET_AWAY],
QuickModes.SYSTEM_OFF: [HVACMode.OFF, PRESET_SYSTEM_OFF],
QuickModes.HOLIDAY: [HVACMode.OFF, PRESET_AWAY],
Expand Down Expand Up @@ -579,6 +589,7 @@ class DHWClimate(MultimaticClimate):
QuickModes.HOTWATER_BOOST: [HVACMode.HEAT, PRESET_BOOST],
QuickModes.PARTY: [HVACMode.OFF, PRESET_HOME],
OperatingModes.ON: [HVACMode.HEAT, PRESET_NONE],
OperatingModes.MANUAL: [HVACMode.HEAT, PRESET_NONE],
OperatingModes.AUTO: [HVACMode.AUTO, PRESET_COMFORT],
OperatingModes.TIME_CONTROLLED: [HVACMode.AUTO, PRESET_COMFORT],
}
Expand Down
19 changes: 2 additions & 17 deletions homeassistant/components/multimatic/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,11 @@
from homeassistant.helpers.aiohttp_client import async_create_clientsession
import homeassistant.helpers.config_validation as cv

from .const import (
CONF_APPLICATION,
CONF_SERIAL_NUMBER,
DEFAULT_SCAN_INTERVAL,
DOMAIN,
MULTIMATIC,
SENSO,
)
from . import DATA_SCHEMA
from .const import CONF_APPLICATION, DEFAULT_SCAN_INTERVAL, DOMAIN, SENSO

_LOGGER = logging.getLogger(__name__)

DATA_SCHEMA = vol.Schema(
{
vol.Required(CONF_USERNAME): str,
vol.Required(CONF_PASSWORD): str,
vol.Optional(CONF_SERIAL_NUMBER): str,
vol.Required(CONF_APPLICATION, default=MULTIMATIC): vol.In([MULTIMATIC, SENSO]),
}
)


async def validate_input(hass: core.HomeAssistant, data):
"""Validate the user input allows us to connect.
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/multimatic/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
PLATFORMS = ["binary_sensor", "sensor", "climate", "fan"]

# climate custom presets
PRESET_COOLING_ON = "cooling_on"
PRESET_SYSTEM_OFF = "system_off"
PRESET_QUICK_VETO = "quick_veto"
PRESET_SYSTEM_OFF = "System off"
PRESET_QUICK_VETO = "Quick Veto"


# default values for configuration
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/multimatic/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"dependencies": [],
"documentation": "https://github.com/thomasgermain/vaillant-component",
"homekit": {},
"integration_type": "hub",
"iot_class": "cloud_polling",
"requirements": ["pymultimatic==0.7.0"],
"requirements": ["pymultimatic==0.7.3"],
"ssdp": [],
"zeroconf": []
}
24 changes: 0 additions & 24 deletions homeassistant/components/multimatic/services.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
remove_quick_mode:
description: Remove quick mode

remove_holiday_mode:
description: Remove holiday mode

set_quick_mode:
description: Set a quick mode to multimatic system.
fields:
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:
Expand All @@ -20,7 +16,6 @@ set_quick_mode:
- QM_ONE_DAY_AT_HOME
- QM_PARTY
duration:
description: (int) number of days the quick mode should last
example: 3
selector:
number:
Expand All @@ -29,20 +24,16 @@ set_quick_mode:
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:
Expand All @@ -51,25 +42,21 @@ set_holiday_mode:
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
selector:
number:
Expand All @@ -78,31 +65,25 @@ set_quick_veto:
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.

set_ventilation_day_level:
description: Set day 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: 1
selector:
number:
Expand All @@ -111,17 +92,14 @@ set_ventilation_day_level:
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:
Expand All @@ -130,10 +108,8 @@ set_ventilation_night_level:
mode: box

set_datetime:
description: Set multimatic system datetime
fields:
datetime:
description: datetime to set
example: 2022-11-06T11:11:38
selector:
datetime:
Loading

0 comments on commit 326ddf5

Please sign in to comment.