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

Ha 2022.4 compatibility #127

Merged
merged 5 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions custom_components/multimatic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_SCAN_INTERVAL, EVENT_HOMEASSISTANT_STOP
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType

from .const import (
COORDINATOR_LIST,
Expand All @@ -21,12 +22,12 @@
_LOGGER = logging.getLogger(__name__)


async def async_setup(hass: HomeAssistant, config: dict):
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the multimatic integration."""
return True


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up multimatic from a config entry."""

api: MultimaticApi = MultimaticApi(hass, entry)
Expand Down Expand Up @@ -90,7 +91,7 @@ async def async_unload_services(hass):
hass.services.async_remove(DOMAIN, service_name)


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
Expand Down
71 changes: 35 additions & 36 deletions custom_components/multimatic/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
BinarySensorDeviceClass,
BinarySensorEntity,
)
from homeassistant.const import ENTITY_CATEGORY_DIAGNOSTIC
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
from homeassistant.helpers.entity import EntityCategory
from homeassistant.util import slugify

from .const import (
Expand Down Expand Up @@ -110,12 +110,12 @@ def name(self) -> str:
return self.coordinator.data.circulation.name

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

@property
def device_class(self):
def device_class(self) -> BinarySensorDeviceClass | str | None:
"""Return the class of this device, from component DEVICE_CLASSES."""
return BinarySensorDeviceClass.RUNNING

Expand All @@ -141,7 +141,7 @@ def available(self):
return super().available and self.room

@property
def device_class(self):
def device_class(self) -> BinarySensorDeviceClass | str | None:
"""Return the class of this device, from component DEVICE_CLASSES."""
return BinarySensorDeviceClass.WINDOW

Expand All @@ -156,9 +156,9 @@ def room(self) -> Room:
return self.coordinator.find_component(self._room_id)

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


class RoomDeviceEntity(MultimaticEntity, BinarySensorEntity):
Expand Down Expand Up @@ -244,14 +244,14 @@ def room(self) -> Room:
return self.coordinator.find_component(self._room_id)

@property
def device_class(self):
def device_class(self) -> BinarySensorDeviceClass | str | None:
"""Return the class of this device, from component DEVICE_CLASSES."""
return BinarySensorDeviceClass.LOCK

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


class RoomDeviceBattery(RoomDeviceEntity):
Expand All @@ -267,14 +267,14 @@ def is_on(self):
return self.device.battery_low

@property
def device_class(self):
def device_class(self) -> BinarySensorDeviceClass | str | None:
"""Return the class of this device, from component DEVICE_CLASSES."""
return BinarySensorDeviceClass.BATTERY

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


class RoomDeviceConnectivity(RoomDeviceEntity):
Expand All @@ -290,14 +290,14 @@ def is_on(self):
return not self.device.radio_out_of_reach

@property
def device_class(self):
def device_class(self) -> BinarySensorDeviceClass | str | None:
"""Return the class of this device, from component DEVICE_CLASSES."""
return BinarySensorDeviceClass.CONNECTIVITY

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


class VRBoxEntity(MultimaticEntity, BinarySensorEntity):
Expand Down Expand Up @@ -358,12 +358,12 @@ def name(self) -> str | None:
return "Multimatic system update"

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

@property
def device_class(self):
def device_class(self) -> BinarySensorDeviceClass | str | None:
"""Return the class of this device, from component DEVICE_CLASSES."""
return BinarySensorDeviceClass.UPDATE

Expand Down Expand Up @@ -391,14 +391,14 @@ def name(self):
return "Multimatic system Online"

@property
def device_class(self):
def device_class(self) -> BinarySensorDeviceClass | str | None:
"""Return the class of this device, from component DEVICE_CLASSES."""
return BinarySensorDeviceClass.CONNECTIVITY

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


class BoilerStatus(MultimaticEntity, BinarySensorEntity):
Expand Down Expand Up @@ -463,14 +463,14 @@ def boiler_status(self):
return self.coordinator.data.boiler_status if self.coordinator.data else None

@property
def device_class(self):
def device_class(self) -> BinarySensorDeviceClass | str | None:
"""Return the class of this device, from component DEVICE_CLASSES."""
return BinarySensorDeviceClass.PROBLEM

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


class MultimaticErrors(MultimaticEntity, BinarySensorEntity):
Expand All @@ -489,8 +489,7 @@ def is_on(self):
"""Return true if the binary sensor is on."""
if self.coordinator.data.errors:
return len(self.coordinator.data.errors) > 0
else:
return False
return False

@property
def state_attributes(self):
Expand All @@ -512,7 +511,7 @@ def state_attributes(self):
return state_attributes

@property
def device_class(self):
def device_class(self) -> BinarySensorDeviceClass | str | None:
"""Return the class of this device, from component DEVICE_CLASSES."""
return BinarySensorDeviceClass.PROBLEM

Expand All @@ -522,9 +521,9 @@ def name(self):
return "Multimatic Errors"

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


class HolidayModeSensor(MultimaticEntity, BinarySensorEntity):
Expand Down Expand Up @@ -560,12 +559,12 @@ def available(self) -> bool:
return self.coordinator.last_update_success

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

@property
def device_class(self):
def device_class(self) -> BinarySensorDeviceClass | str | None:
"""Return the class of this device, from component DEVICE_CLASSES."""
return BinarySensorDeviceClass.OCCUPANCY

Expand Down Expand Up @@ -603,11 +602,11 @@ def available(self) -> bool:
return self.coordinator.last_update_success

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

@property
def device_class(self):
def device_class(self) -> BinarySensorDeviceClass | str | None:
"""Return the class of this device, from component DEVICE_CLASSES."""
return BinarySensorDeviceClass.RUNNING
3 changes: 1 addition & 2 deletions custom_components/multimatic/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,7 @@ async def _first_fetch_data(self):
exc_info=True,
)
return None
else:
raise
raise

async def _safe_logout(self):
try:
Expand Down
12 changes: 2 additions & 10 deletions custom_components/multimatic/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@

from pymultimatic.model import OperatingModes, QuickModes

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

from .const import ATTR_LEVEL, VENTILATION
Expand Down Expand Up @@ -87,16 +82,13 @@ async def async_set_preset_mode(self, preset_mode: str) -> None:

async def async_turn_on(
self,
speed: str | None = None,
percentage: int | None = None,
preset_mode: str | None = None,
**kwargs,
) -> None:
"""Turn on the fan."""
if preset_mode:
mode = OperatingModes.get(preset_mode.upper())
elif speed:
mode = OperatingModes.get(speed.upper())
else:
mode = OperatingModes.AUTO
return await self.coordinator.api.set_fan_operating_mode(self, mode)
Expand Down Expand Up @@ -153,4 +145,4 @@ async def set_ventilation_night_level(self, **kwargs):
@property
def extra_state_attributes(self) -> Mapping[str, Any] | None:
"""Return entity specific state attributes."""
return {ATTR_SPEED: self.active_mode.target}
return {"speed": self.active_mode.target}
2 changes: 1 addition & 1 deletion custom_components/multimatic/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"codeowners": [
"@thomasgermain"
],
"version": "1.12.3",
"version": "1.12.4",
"iot_class": "cloud_polling"
}
28 changes: 12 additions & 16 deletions custom_components/multimatic/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@

from homeassistant.components.sensor import (
DOMAIN,
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL_INCREASING,
SensorDeviceClass,
SensorEntity,
SensorStateClass,
)
from homeassistant.const import (
ENERGY_WATT_HOUR,
ENTITY_CATEGORY_DIAGNOSTIC,
TEMP_CELSIUS,
)
from homeassistant.const import ENERGY_WATT_HOUR, TEMP_CELSIUS
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.typing import StateType

from .const import EMF_REPORTS, OUTDOOR_TEMP, REPORTS
Expand Down Expand Up @@ -94,12 +90,12 @@ def device_class(self) -> str:
@property
def state_class(self) -> str | None:
"""Return the state class of this entity."""
return STATE_CLASS_MEASUREMENT
return SensorStateClass.MEASUREMENT

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


class ReportSensor(MultimaticEntity, SensorEntity):
Expand Down Expand Up @@ -155,7 +151,7 @@ def device_info(self):
@property
def state_class(self) -> str | None:
"""Return the state class of this entity, from STATE_CLASSES, if any."""
return STATE_CLASS_MEASUREMENT
return SensorStateClass.MEASUREMENT

@property
def device_class(self) -> str | None:
Expand All @@ -168,9 +164,9 @@ def name(self) -> str | None:
return self._name

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


class EmfReportSensor(MultimaticEntity, SensorEntity):
Expand Down Expand Up @@ -233,9 +229,9 @@ def name(self) -> str | None:
@property
def state_class(self) -> str:
"""Return the state class of this entity."""
return STATE_CLASS_TOTAL_INCREASING
return SensorStateClass.TOTAL_INCREASING

@property
def entity_category(self) -> str | None:
def entity_category(self) -> EntityCategory | None:
"""Return the category of the entity, if any."""
return ENTITY_CATEGORY_DIAGNOSTIC
return EntityCategory.DIAGNOSTIC
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": "2022.02.0"
"homeassistant": "2022.04.0"
}