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

Commit

Permalink
1 11 (#106)
Browse files Browse the repository at this point in the history
1.11.0
  • Loading branch information
thomasgermain committed Nov 12, 2021
1 parent fc29941 commit 2cffd08
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 8 deletions.
56 changes: 56 additions & 0 deletions custom_components/multimatic/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
DOMAIN,
BinarySensorEntity,
)
from homeassistant.const import ENTITY_CATEGORY_DIAGNOSTIC
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
from homeassistant.util import slugify

Expand Down Expand Up @@ -112,6 +113,11 @@ def name(self) -> str:
"""Return the name of the entity."""
return self.coordinator.data.circulation.name

@property
def entity_category(self) -> str | None:
"""Return the category of the entity, if any."""
return ENTITY_CATEGORY_DIAGNOSTIC


class RoomWindow(MultimaticEntity, BinarySensorEntity):
"""multimatic window binary sensor."""
Expand Down Expand Up @@ -146,6 +152,11 @@ def room(self) -> Room:
"""Return the room."""
return self.coordinator.find_component(self._room_id)

@property
def entity_category(self) -> str | None:
"""Return the category of the entity, if any."""
return ENTITY_CATEGORY_DIAGNOSTIC


class RoomDeviceEntity(MultimaticEntity, BinarySensorEntity):
"""Base class for ambisense device."""
Expand Down Expand Up @@ -234,6 +245,11 @@ def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
return DEVICE_CLASS_LOCK

@property
def entity_category(self) -> str | None:
"""Return the category of the entity, if any."""
return ENTITY_CATEGORY_DIAGNOSTIC


class RoomDeviceBattery(RoomDeviceEntity):
"""Represent a device battery."""
Expand All @@ -252,6 +268,11 @@ def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
return DEVICE_CLASS_BATTERY

@property
def entity_category(self) -> str | None:
"""Return the category of the entity, if any."""
return ENTITY_CATEGORY_DIAGNOSTIC


class RoomDeviceConnectivity(RoomDeviceEntity):
"""Device in room is out of reach or not."""
Expand All @@ -270,6 +291,11 @@ def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
return DEVICE_CLASS_CONNECTIVITY

@property
def entity_category(self) -> str | None:
"""Return the category of the entity, if any."""
return ENTITY_CATEGORY_DIAGNOSTIC


class VRBoxEntity(MultimaticEntity, BinarySensorEntity):
"""multimatic gateway device (ex: VR920)."""
Expand Down Expand Up @@ -328,6 +354,11 @@ def name(self) -> str | None:
"""Return the name of the entity."""
return "Multimatic system update"

@property
def entity_category(self) -> str | None:
"""Return the category of the entity, if any."""
return ENTITY_CATEGORY_DIAGNOSTIC


class BoxOnline(VRBoxEntity):
"""Check if box is online."""
Expand Down Expand Up @@ -356,6 +387,11 @@ def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
return DEVICE_CLASS_CONNECTIVITY

@property
def entity_category(self) -> str | None:
"""Return the category of the entity, if any."""
return ENTITY_CATEGORY_DIAGNOSTIC


class BoilerStatus(MultimaticEntity, BinarySensorEntity):
"""Check if there is some error."""
Expand Down Expand Up @@ -423,6 +459,11 @@ def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
return DEVICE_CLASS_PROBLEM

@property
def entity_category(self) -> str | None:
"""Return the category of the entity, if any."""
return ENTITY_CATEGORY_DIAGNOSTIC


class MultimaticErrors(MultimaticEntity, BinarySensorEntity):
"""Check if there is any error message from system."""
Expand Down Expand Up @@ -469,6 +510,11 @@ def name(self):
"""Return the name of the entity."""
return "Multimatic Errors"

@property
def entity_category(self) -> str | None:
"""Return the category of the entity, if any."""
return ENTITY_CATEGORY_DIAGNOSTIC


class HolidayModeSensor(MultimaticEntity, BinarySensorEntity):
"""Binary sensor for holiday mode."""
Expand Down Expand Up @@ -502,6 +548,11 @@ def available(self) -> bool:
"""Return if entity is available."""
return self.coordinator.last_update_success

@property
def entity_category(self) -> str | None:
"""Return the category of the entity, if any."""
return ENTITY_CATEGORY_DIAGNOSTIC


class QuickModeSensor(MultimaticEntity, BinarySensorEntity):
"""Binary sensor for holiday mode."""
Expand Down Expand Up @@ -534,3 +585,8 @@ def name(self):
def available(self) -> bool:
"""Return if entity is available."""
return self.coordinator.last_update_success

@property
def entity_category(self) -> str | None:
"""Return the category of the entity, if any."""
return ENTITY_CATEGORY_DIAGNOSTIC
23 changes: 19 additions & 4 deletions custom_components/multimatic/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from . import SERVICES
from .const import (
DEFAULT_QUICK_VETO_DURATION,
DOMAIN as MULTIMATIC,
PRESET_COOLING_FOR_X_DAYS,
PRESET_COOLING_ON,
PRESET_DAY,
Expand Down Expand Up @@ -247,7 +248,20 @@ def __init__(
self._zone_coo = zone_coo

@property
def component(self) -> Component:
def device_info(self):
"""Return device specific attributes."""
devices = self.component.devices
if len(devices) == 1: # Can't link an entity to multiple devices
return {
"identifiers": {(MULTIMATIC, devices[0].sgtin)},
"name": devices[0].name,
"manufacturer": "Vaillant",
"model": devices[0].device_type,
}
return {}

@property
def component(self) -> Room:
"""Get the component."""
return self.coordinator.find_component(self._room_id)

Expand Down Expand Up @@ -344,7 +358,8 @@ def hvac_action(self) -> str | None:
@property
def current_humidity(self) -> int | None:
"""Return the current humidity."""
return self.component.humidity
humidity = self.component.humidity
return int(humidity) if humidity is not None else None


class ZoneClimate(MultimaticClimate):
Expand Down Expand Up @@ -415,8 +430,8 @@ def extra_state_attributes(self) -> Mapping[str, Any] | None:
return attr

@property
def component(self) -> Component:
"""Return the room."""
def component(self) -> Zone:
"""Return the zone."""
return self.coordinator.find_component(self._zone_id)

@property
Expand Down
1 change: 1 addition & 0 deletions custom_components/multimatic/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
ATTR_END_DATE = "end_date"
ATTR_TEMPERATURE = "temperature"
ATTR_DURATION = "duration"
ATTR_LEVEL = "level"

SERVICES_HANDLER = "services_handler"

Expand Down
8 changes: 8 additions & 0 deletions custom_components/multimatic/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,14 @@ async def set_fan_operating_mode(self, entity, mode: Mode):
entity.component.operating_mode = mode
await self._refresh(touch_system, entity)

async def set_fan_day_level(self, level):
"""Set fan day level."""
await self._manager.set_ventilation_day_level(level)

async def set_fan_night_level(self, level):
"""Set fan night level."""
await self._manager.set_ventilation_night_level(level)

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

Expand Down
19 changes: 19 additions & 0 deletions custom_components/multimatic/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@
from pymultimatic.model import OperatingModes, QuickModes

from homeassistant.components.fan import DOMAIN, SUPPORT_PRESET_MODE, FanEntity
from homeassistant.helpers import entity_platform

from .const import VENTILATION
from .coordinator import MultimaticCoordinator
from .entities import MultimaticEntity
from .service import (
SERVICE_SET_VENTILATION_DAY_LEVEL,
SERVICE_SET_VENTILATION_NIGHT_LEVEL,
SERVICES,
)
from .utils import get_coordinator

_LOGGER = logging.getLogger(__name__)
Expand All @@ -26,6 +32,19 @@ async def async_setup_entry(hass, entry, async_add_entities):
_LOGGER.debug("Adding fan entity")
async_add_entities([MultimaticFan(coordinator)])

_LOGGER.debug("Adding fan services")
platform = entity_platform.current_platform.get()
platform.async_register_entity_service(
SERVICE_SET_VENTILATION_DAY_LEVEL,
SERVICES[SERVICE_SET_VENTILATION_DAY_LEVEL]["schema"],
SERVICE_SET_VENTILATION_DAY_LEVEL,
)
platform.async_register_entity_service(
SERVICE_SET_VENTILATION_NIGHT_LEVEL,
SERVICES[SERVICE_SET_VENTILATION_NIGHT_LEVEL]["schema"],
SERVICE_SET_VENTILATION_NIGHT_LEVEL,
)


class MultimaticFan(MultimaticEntity, FanEntity):
"""Representation of a multimatic fan."""
Expand Down
4 changes: 2 additions & 2 deletions custom_components/multimatic/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"documentation": "https://github.com/thomasgermain/vaillant-component",
"issue_tracker": "https://github.com/thomasgermain/vaillant-component/issues",
"requirements": [
"pymultimatic==0.6.2"
"pymultimatic==0.6.5"
],
"ssdp": [],
"zeroconf": [],
Expand All @@ -14,6 +14,6 @@
"codeowners": [
"@thomasgermain"
],
"version": "1.10.1",
"version": "1.11.0",
"iot_class": "cloud_polling"
}
21 changes: 20 additions & 1 deletion custom_components/multimatic/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
STATE_CLASS_TOTAL_INCREASING,
SensorEntity,
)
from homeassistant.const import ENERGY_WATT_HOUR, TEMP_CELSIUS
from homeassistant.const import (
ENERGY_WATT_HOUR,
ENTITY_CATEGORY_DIAGNOSTIC,
TEMP_CELSIUS,
)
from homeassistant.helpers.typing import StateType
from homeassistant.util.dt import utc_from_timestamp

Expand Down Expand Up @@ -95,6 +99,11 @@ def state_class(self) -> str | None:
"""Return the state class of this entity."""
return STATE_CLASS_MEASUREMENT

@property
def entity_category(self) -> str | None:
"""Return the category of the entity, if any."""
return ENTITY_CATEGORY_DIAGNOSTIC


class ReportSensor(MultimaticEntity, SensorEntity):
"""Report sensor."""
Expand Down Expand Up @@ -161,6 +170,11 @@ def name(self) -> str | None:
"""Return the name of the entity."""
return self._name

@property
def entity_category(self) -> str | None:
"""Return the category of the entity, if any."""
return ENTITY_CATEGORY_DIAGNOSTIC


class EmfReportSensor(MultimaticEntity, SensorEntity):
"""Emf Report sensor."""
Expand Down Expand Up @@ -228,3 +242,8 @@ def last_reset(self) -> datetime.datetime:
def state_class(self) -> str:
"""Return the state class of this entity."""
return STATE_CLASS_TOTAL_INCREASING

@property
def entity_category(self) -> str | None:
"""Return the category of the entity, if any."""
return ENTITY_CATEGORY_DIAGNOSTIC
25 changes: 25 additions & 0 deletions custom_components/multimatic/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .const import (
ATTR_DURATION,
ATTR_END_DATE,
ATTR_LEVEL,
ATTR_QUICK_MODE,
ATTR_START_DATE,
ATTR_TEMPERATURE,
Expand All @@ -29,6 +30,8 @@
SERVICE_SET_QUICK_VETO = "set_quick_veto"
SERVICE_REMOVE_QUICK_VETO = "remove_quick_veto"
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_REMOVE_QUICK_MODE_SCHEMA = vol.Schema({})
SERVICE_REMOVE_HOLIDAY_MODE_SCHEMA = vol.Schema({})
Expand Down Expand Up @@ -65,6 +68,14 @@
)
SERVICE_REQUEST_HVAC_UPDATE_SCHEMA = vol.Schema({})

SERVICE_SET_VENTILATION_DAY_LEVEL_SCHEMA = vol.Schema(
{
vol.Required(ATTR_LEVEL): vol.All(vol.Coerce(int), vol.Clamp(min=1, max=6)),
}
)

SERVICE_SET_VENTILATION_NIGHT_LEVEL_SCHEMA = SERVICE_SET_VENTILATION_DAY_LEVEL_SCHEMA

SERVICES = {
SERVICE_REMOVE_QUICK_MODE: {
"schema": SERVICE_REMOVE_QUICK_MODE_SCHEMA,
Expand All @@ -86,6 +97,12 @@
SERVICE_REQUEST_HVAC_UPDATE: {
"schema": SERVICE_REQUEST_HVAC_UPDATE_SCHEMA,
},
SERVICE_SET_VENTILATION_NIGHT_LEVEL: {
"schema": SERVICE_SET_VENTILATION_NIGHT_LEVEL_SCHEMA
},
SERVICE_SET_VENTILATION_DAY_LEVEL: {
"schema": SERVICE_SET_VENTILATION_DAY_LEVEL_SCHEMA
},
}


Expand Down Expand Up @@ -131,3 +148,11 @@ 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_ventilation_day_level(self, data):
"""Set ventilation day level."""
await self.api.set_fan_day_level(data.get(ATTR_LEVEL))

async def set_ventilation_night_level(self, data):
"""Set ventilation day level."""
await self.api.set_fan_night_level(data.get(ATTR_LEVEL))
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"name": "multimatic",
"domains": ["binary_sensor", "climate", "fan", "sensor", "water_heater"],
"render_readme": true,
"homeassistant": "2021.9.1"
"homeassistant": "2021.11.0"
}

0 comments on commit 2cffd08

Please sign in to comment.