1 """Types for the ViCare integration."""
3 from collections.abc
import Callable
4 from contextlib
import suppress
5 from dataclasses
import dataclass
9 from PyViCare.PyViCareDevice
import Device
as PyViCareDevice
10 from PyViCare.PyViCareDeviceConfig
import PyViCareDeviceConfig
21 """ViCare preset heating programs.
23 As listed in https://github.com/somm15/PyViCare/blob/63f9f7fea505fdf9a26c77c6cd0bff889abcdb05/PyViCare/PyViCareHeatingDevice.py#L606
27 COMFORT_HEATING =
"comfortHeating"
28 COMFORT_COOLING =
"comfortCooling"
31 NORMAL_HEATING =
"normalHeating"
32 NORMAL_COOLING =
"normalCooling"
34 REDUCED_HEATING =
"reducedHeating"
35 REDUCED_COOLING =
"reducedCooling"
40 """Return the mapped Home Assistant preset for the ViCare heating program."""
47 return VICARE_TO_HA_PRESET_HEATING.get(heating_program)
if program
else None
51 ha_preset: str, supported_heating_programs: list[str]
53 """Return the mapped ViCare heating program for the Home Assistant preset."""
54 for program
in supported_heating_programs:
55 with suppress(ValueError):
64 VICARE_TO_HA_PRESET_HEATING = {
65 HeatingProgram.COMFORT: PRESET_COMFORT,
66 HeatingProgram.COMFORT_HEATING: PRESET_COMFORT,
67 HeatingProgram.ECO: PRESET_ECO,
68 HeatingProgram.NORMAL: PRESET_HOME,
69 HeatingProgram.NORMAL_HEATING: PRESET_HOME,
70 HeatingProgram.REDUCED: PRESET_SLEEP,
71 HeatingProgram.REDUCED_HEATING: PRESET_SLEEP,
75 @dataclass(frozen=True)
77 """Dataclass holding the device api and config."""
79 config: PyViCareDeviceConfig
83 @dataclass(frozen=True)
85 """Mixin for required keys."""
87 value_getter: Callable[[PyViCareDevice], Any]
90 @dataclass(frozen=True)
92 """Mixin for required keys with setter."""
94 value_setter: Callable[[PyViCareDevice], bool]
str|None from_ha_preset(str ha_preset, list[str] supported_heating_programs)
str|None to_ha_preset(str program)