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

Commit 11bec7a

Browse files
ha 2023.1 compatibility (#179)
1 parent 8c59687 commit 11bec7a

File tree

9 files changed

+193
-165
lines changed

9 files changed

+193
-165
lines changed

custom_components/multimatic/binary_sensor.py

Lines changed: 73 additions & 64 deletions
Large diffs are not rendered by default.

custom_components/multimatic/climate.py

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,23 @@
1818
)
1919

2020
from homeassistant.components.climate import (
21-
ClimateEntity,
22-
ClimateEntityFeature,
23-
HVACAction,
24-
HVACMode,
25-
)
26-
from homeassistant.components.climate.const import (
2721
DOMAIN,
2822
PRESET_AWAY,
2923
PRESET_COMFORT,
3024
PRESET_HOME,
3125
PRESET_NONE,
3226
PRESET_SLEEP,
27+
ClimateEntity,
28+
ClimateEntityFeature,
29+
HVACAction,
30+
HVACMode,
3331
)
34-
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
32+
from homeassistant.config_entries import ConfigEntry
33+
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
34+
from homeassistant.core import HomeAssistant
3535
from homeassistant.helpers import entity_platform
36+
from homeassistant.helpers.entity import DeviceInfo
37+
from homeassistant.helpers.entity_platform import AddEntitiesCallback
3638

3739
from . import SERVICES
3840
from .const import (
@@ -64,9 +66,11 @@
6466
}
6567

6668

67-
async def async_setup_entry(hass, entry, async_add_entities):
69+
async def async_setup_entry(
70+
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
71+
) -> None:
6872
"""Set up the multimatic climate platform."""
69-
climates = []
73+
climates: list[MultimaticClimate] = []
7074
zones_coo = get_coordinator(hass, ZONES, entry.unique_id)
7175
rooms_coo = get_coordinator(hass, ROOMS, entry.unique_id)
7276
ventilation_coo = get_coordinator(hass, VENTILATION, entry.unique_id)
@@ -86,7 +90,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
8690
async_add_entities(climates)
8791

8892
if len(climates) > 0:
89-
platform = entity_platform.current_platform.get()
93+
platform = entity_platform.async_get_current_platform()
9094
platform.async_register_entity_service(
9195
SERVICE_REMOVE_QUICK_VETO,
9296
SERVICES[SERVICE_REMOVE_QUICK_VETO]["schema"],
@@ -98,8 +102,6 @@ async def async_setup_entry(hass, entry, async_add_entities):
98102
SERVICE_SET_QUICK_VETO,
99103
)
100104

101-
return True
102-
103105

104106
class MultimaticClimate(MultimaticEntity, ClimateEntity, abc.ABC):
105107
"""Base class for climate."""
@@ -134,22 +136,22 @@ def component(self) -> Component:
134136
"""Return the room or the zone."""
135137

136138
@property
137-
def available(self):
139+
def available(self) -> bool:
138140
"""Return True if entity is available."""
139141
return super().available and self.component
140142

141143
@property
142-
def temperature_unit(self):
144+
def temperature_unit(self) -> str:
143145
"""Return the unit of measurement used by the platform."""
144-
return TEMP_CELSIUS
146+
return UnitOfTemperature.CELSIUS
145147

146148
@property
147-
def target_temperature(self):
149+
def target_temperature(self) -> float:
148150
"""Return the temperature we try to reach."""
149151
return self.active_mode.target
150152

151153
@property
152-
def current_temperature(self):
154+
def current_temperature(self) -> float:
153155
"""Return the current temperature."""
154156
return self.component.temperature
155157

@@ -244,17 +246,17 @@ def __init__(
244246
self._zone_coo = zone_coo
245247

246248
@property
247-
def device_info(self):
249+
def device_info(self) -> DeviceInfo | None:
248250
"""Return device specific attributes."""
249251
devices = self.component.devices
250252
if len(devices) == 1: # Can't link an entity to multiple devices
251-
return {
252-
"identifiers": {(MULTIMATIC, devices[0].sgtin)},
253-
"name": devices[0].name,
254-
"manufacturer": "Vaillant",
255-
"model": devices[0].device_type,
256-
}
257-
return {}
253+
return DeviceInfo(
254+
identifiers={(MULTIMATIC, devices[0].sgtin)},
255+
name=devices[0].name,
256+
manufacturer="Vaillant",
257+
model=devices[0].device_type,
258+
)
259+
return None
258260

259261
@property
260262
def component(self) -> Room:
@@ -280,19 +282,19 @@ def hvac_modes(self) -> list[HVACMode]:
280282
return self._supported_hvac
281283

282284
@property
283-
def supported_features(self):
285+
def supported_features(self) -> ClimateEntityFeature:
284286
"""Return the list of supported features."""
285287
return (
286288
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
287289
)
288290

289291
@property
290-
def min_temp(self):
292+
def min_temp(self) -> float:
291293
"""Return the minimum temperature."""
292294
return Room.MIN_TARGET_TEMP
293295

294296
@property
295-
def max_temp(self):
297+
def max_temp(self) -> float:
296298
"""Return the maximum temperature."""
297299
return Room.MAX_TARGET_TEMP
298300

@@ -305,10 +307,10 @@ def zone(self):
305307
)
306308
return None
307309

308-
async def async_set_temperature(self, **kwargs):
310+
async def async_set_temperature(self, **kwargs: Any) -> None:
309311
"""Set new target temperature."""
310312
await self.coordinator.api.set_room_target_temperature(
311-
self, float(kwargs.get(ATTR_TEMPERATURE))
313+
self, kwargs.get(ATTR_TEMPERATURE)
312314
)
313315

314316
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
@@ -433,7 +435,7 @@ def component(self) -> Zone:
433435
return self.coordinator.find_component(self._zone_id)
434436

435437
@property
436-
def hvac_mode(self):
438+
def hvac_mode(self) -> HVACMode:
437439
"""Get the hvac mode based on multimatic mode."""
438440
current_mode = self.active_mode.current
439441
hvac_mode = ZoneClimate._MULTIMATIC_TO_HA[current_mode][0]
@@ -462,28 +464,28 @@ def hvac_modes(self) -> list[HVACMode]:
462464
return self._supported_hvac
463465

464466
@property
465-
def supported_features(self):
467+
def supported_features(self) -> ClimateEntityFeature:
466468
"""Return the list of supported features."""
467469
return (
468470
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
469471
)
470472

471473
@property
472-
def min_temp(self):
474+
def min_temp(self) -> float:
473475
"""Return the minimum temperature."""
474476
return Zone.MIN_TARGET_HEATING_TEMP
475477

476478
@property
477-
def max_temp(self):
479+
def max_temp(self) -> float:
478480
"""Return the maximum temperature."""
479481
return Zone.MAX_TARGET_TEMP
480482

481483
@property
482-
def target_temperature(self):
484+
def target_temperature(self) -> float:
483485
"""Return the temperature we try to reach."""
484486
return self.active_mode.target
485487

486-
async def async_set_temperature(self, **kwargs):
488+
async def async_set_temperature(self, **kwargs: Any) -> None:
487489
"""Set new target temperature."""
488490
temp = kwargs.get(ATTR_TEMPERATURE)
489491

@@ -493,7 +495,7 @@ async def async_set_temperature(self, **kwargs):
493495
else:
494496
_LOGGER.debug("Nothing to do")
495497

496-
async def async_set_hvac_mode(self, hvac_mode):
498+
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
497499
"""Set new target hvac mode."""
498500
mode = ZoneClimate._HA_MODE_TO_MULTIMATIC[hvac_mode]
499501
await self.coordinator.api.set_zone_operating_mode(self, mode)

custom_components/multimatic/config_flow.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
import voluptuous as vol
77

88
from homeassistant import config_entries, core, exceptions
9+
from homeassistant.config_entries import ConfigEntry, OptionsFlow
910
from homeassistant.const import CONF_PASSWORD, CONF_SCAN_INTERVAL, CONF_USERNAME
1011
from homeassistant.core import callback
12+
from homeassistant.data_entry_flow import FlowResult
1113
from homeassistant.helpers.aiohttp_client import async_create_clientsession
1214
import homeassistant.helpers.config_validation as cv
1315

@@ -60,11 +62,11 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
6062

6163
@staticmethod
6264
@callback
63-
def async_get_options_flow(config_entry):
65+
def async_get_options_flow(config_entry: ConfigEntry) -> OptionsFlow:
6466
"""Get the options flow for this handler."""
6567
return MultimaticOptionsFlowHandler(config_entry)
6668

67-
async def async_step_user(self, user_input=None):
69+
async def async_step_user(self, user_input=None) -> FlowResult:
6870
"""Handle the initial step."""
6971
errors = {}
7072
if user_input is not None:
@@ -92,7 +94,7 @@ def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
9294
"""Initialize options flow."""
9395
self.config_entry = config_entry
9496

95-
async def async_step_init(self, user_input=None):
97+
async def async_step_init(self, user_input=None) -> FlowResult:
9698
"""Handle options flow."""
9799
if user_input is not None:
98100
return self.async_create_entry(title="", data=user_input)

custom_components/multimatic/fan.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
from pymultimatic.model import OperatingModes, QuickModes
1010

1111
from homeassistant.components.fan import DOMAIN, FanEntity, FanEntityFeature
12+
from homeassistant.config_entries import ConfigEntry
13+
from homeassistant.core import HomeAssistant
1214
from homeassistant.helpers import entity_platform
15+
from homeassistant.helpers.entity_platform import AddEntitiesCallback
1316

1417
from .const import ATTR_LEVEL, VENTILATION
1518
from .coordinator import MultimaticCoordinator
@@ -24,7 +27,9 @@
2427
_LOGGER = logging.getLogger(__name__)
2528

2629

27-
async def async_setup_entry(hass, entry, async_add_entities):
30+
async def async_setup_entry(
31+
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
32+
) -> None:
2833
"""Set up the multimatic fan platform."""
2934

3035
coordinator = get_coordinator(hass, VENTILATION, entry.unique_id)
@@ -34,7 +39,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
3439
async_add_entities([MultimaticFan(coordinator)])
3540

3641
_LOGGER.debug("Adding fan services")
37-
platform = entity_platform.current_platform.get()
42+
platform = entity_platform.async_get_current_platform()
3843
platform.async_register_entity_service(
3944
SERVICE_SET_VENTILATION_DAY_LEVEL,
4045
SERVICES[SERVICE_SET_VENTILATION_DAY_LEVEL]["schema"],
@@ -85,7 +90,7 @@ async def async_turn_on(
8590
self,
8691
percentage: int | None = None,
8792
preset_mode: str | None = None,
88-
**kwargs,
93+
**kwargs: Any,
8994
) -> None:
9095
"""Turn on the fan."""
9196
if preset_mode:
@@ -94,19 +99,19 @@ async def async_turn_on(
9499
mode = OperatingModes.AUTO
95100
return await self.coordinator.api.set_fan_operating_mode(self, mode)
96101

97-
async def async_turn_off(self, **kwargs: Any):
102+
async def async_turn_off(self, **kwargs: Any) -> None:
98103
"""Turn on the fan."""
99104
return await self.coordinator.api.set_fan_operating_mode(
100105
self, OperatingModes.NIGHT
101106
)
102107

103108
@property
104-
def is_on(self):
109+
def is_on(self) -> bool:
105110
"""Return true if the entity is on."""
106111
return self.active_mode.current != OperatingModes.NIGHT
107112

108113
@property
109-
def supported_features(self) -> int:
114+
def supported_features(self) -> FanEntityFeature:
110115
"""Flag supported features."""
111116
return FanEntityFeature.PRESET_MODE
112117

@@ -126,7 +131,7 @@ def preset_modes(self) -> list[str] | None:
126131
return self._preset_modes
127132

128133
@property
129-
def available(self):
134+
def available(self) -> bool:
130135
"""Return True if entity is available."""
131136
return super().available and self.component
132137

custom_components/multimatic/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +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.11"
8+
"pymultimatic==0.6.12"
99
],
1010
"ssdp": [],
1111
"zeroconf": [],
1212
"homekit": {},
1313
"dependencies": [],
1414
"codeowners": ["@thomasgermain"],
15-
"version": "1.12.11",
15+
"version": "1.12.12",
1616
"iot_class": "cloud_polling"
1717
}

0 commit comments

Comments
 (0)