Skip to content

Commit

Permalink
Ensure modules for platforms are loaded / Use local dicts for device …
Browse files Browse the repository at this point in the history
…lists (SukramJ#960)

* Fix property types

* Ensure modules for platforms are loaded

* Use local dicts for device lists
  • Loading branch information
SukramJ authored Feb 13, 2023
1 parent ca4739a commit 629395a
Show file tree
Hide file tree
Showing 9 changed files with 291 additions and 278 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Version 2023.2. (2023-02-11)

- Fix property types
- Ensure modules for platforms are loaded
- Use local dicts for device lists

# Version 2023.2.8 (2023-02-11)

- Add project setup script
Expand Down
14 changes: 14 additions & 0 deletions hahomematic/platforms/custom/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Module for HaHomematic custom platforms."""
from __future__ import annotations

import importlib
import logging

from hahomematic.platforms import device as hmd
Expand Down Expand Up @@ -37,3 +38,16 @@ def create_custom_entity_and_append_to_device(
else:
for entity_config in entity_configs:
entity_config.func(device, entity_config.channels, entity_config.extended)


def _importlibs() -> None:
"""Ensure that all platforms are loaded."""
importlib.import_module("hahomematic.platforms.custom.climate")
importlib.import_module("hahomematic.platforms.custom.cover")
importlib.import_module("hahomematic.platforms.custom.light")
importlib.import_module("hahomematic.platforms.custom.lock")
importlib.import_module("hahomematic.platforms.custom.siren")
importlib.import_module("hahomematic.platforms.custom.switch")


_importlibs()
57 changes: 28 additions & 29 deletions hahomematic/platforms/custom/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from hahomematic.platforms.generic.select import HmSelect
from hahomematic.platforms.generic.sensor import HmSensor
from hahomematic.platforms.generic.switch import HmSwitch
from hahomematic.platforms.support import value_property
from hahomematic.platforms.support import config_property, value_property

CLOSED_LEVEL: Final = 0.0

Expand Down Expand Up @@ -131,7 +131,7 @@ def _init_entity_fields(self) -> None:
field_name=FIELD_TEMPERATURE_MINIMUM, entity_type=HmFloat
)

@value_property
@config_property
def temperature_unit(self) -> str:
"""Return temperature unit."""
return TEMP_CELSIUS
Expand Down Expand Up @@ -170,7 +170,7 @@ def target_temperature(self) -> float | None:
"""Return target temperature."""
return self._e_setpoint.value

@value_property
@config_property
def target_temperature_step(self) -> float:
"""Return the supported step of target temperature."""
return 0.5
Expand Down Expand Up @@ -200,7 +200,7 @@ def hvac_modes(self) -> list[HmHvacMode]:
"""Return the list of available hvac operation modes."""
return [HmHvacMode.HEAT]

@value_property
@config_property
def supports_preset(self) -> bool:
"""Flag if climate supports preset."""
return False
Expand Down Expand Up @@ -341,7 +341,7 @@ def preset_modes(self) -> list[HmPresetMode]:
HmPresetMode.NONE,
]

@value_property
@config_property
def supports_preset(self) -> bool:
"""Flag if climate supports preset."""
return True
Expand Down Expand Up @@ -470,7 +470,7 @@ def preset_modes(self) -> list[HmPresetMode]:
presets.extend(self._profile_names)
return presets

@value_property
@config_property
def supports_preset(self) -> bool:
"""Flag if climate supports preset."""
return True
Expand Down Expand Up @@ -657,26 +657,25 @@ def make_ip_thermostat_group(


# Case for device model is not relevant
hmed.ALL_DEVICES.append(
{
"ALPHA-IP-RBG": CustomConfig(func=make_ip_thermostat, channels=(1,)),
"BC-RT-TRX-CyG": CustomConfig(func=make_thermostat, channels=(1,)),
"BC-RT-TRX-CyN": CustomConfig(func=make_thermostat, channels=(1,)),
"BC-TC-C-WM": CustomConfig(func=make_thermostat, channels=(1,)),
"HM-CC-RT-DN": CustomConfig(func=make_thermostat, channels=(4,)),
"HM-CC-TC": CustomConfig(func=make_simple_thermostat, channels=(1,)),
"HM-CC-VG-1": CustomConfig(func=make_thermostat_group, channels=(1,)),
"HM-TC-IT-WM-W-EU": CustomConfig(func=make_thermostat, channels=(2,)),
"HmIP-BWTH": CustomConfig(func=make_ip_thermostat, channels=(1,)),
"HmIP-HEATING": CustomConfig(func=make_ip_thermostat_group, channels=(1,)),
"HmIP-STH": CustomConfig(func=make_ip_thermostat, channels=(1,)),
"HmIP-WTH": CustomConfig(func=make_ip_thermostat, channels=(1,)),
"HmIP-eTRV": CustomConfig(func=make_ip_thermostat, channels=(1,)),
"HmIPW-STH": CustomConfig(func=make_ip_thermostat, channels=(1,)),
"HmIPW-WTH": CustomConfig(func=make_ip_thermostat, channels=(1,)),
"Thermostat AA": CustomConfig(func=make_ip_thermostat, channels=(1,)),
"ZEL STG RM FWT": CustomConfig(func=make_simple_thermostat, channels=(1,)),
}
)

hmed.BLACKLISTED_DEVICES.append(("HmIP-STHO",))
DEVICES: dict[str, CustomConfig | tuple[CustomConfig, ...]] = {
"ALPHA-IP-RBG": CustomConfig(func=make_ip_thermostat, channels=(1,)),
"BC-RT-TRX-CyG": CustomConfig(func=make_thermostat, channels=(1,)),
"BC-RT-TRX-CyN": CustomConfig(func=make_thermostat, channels=(1,)),
"BC-TC-C-WM": CustomConfig(func=make_thermostat, channels=(1,)),
"HM-CC-RT-DN": CustomConfig(func=make_thermostat, channels=(4,)),
"HM-CC-TC": CustomConfig(func=make_simple_thermostat, channels=(1,)),
"HM-CC-VG-1": CustomConfig(func=make_thermostat_group, channels=(1,)),
"HM-TC-IT-WM-W-EU": CustomConfig(func=make_thermostat, channels=(2,)),
"HmIP-BWTH": CustomConfig(func=make_ip_thermostat, channels=(1,)),
"HmIP-HEATING": CustomConfig(func=make_ip_thermostat_group, channels=(1,)),
"HmIP-STH": CustomConfig(func=make_ip_thermostat, channels=(1,)),
"HmIP-WTH": CustomConfig(func=make_ip_thermostat, channels=(1,)),
"HmIP-eTRV": CustomConfig(func=make_ip_thermostat, channels=(1,)),
"HmIPW-STH": CustomConfig(func=make_ip_thermostat, channels=(1,)),
"HmIPW-WTH": CustomConfig(func=make_ip_thermostat, channels=(1,)),
"Thermostat AA": CustomConfig(func=make_ip_thermostat, channels=(1,)),
"ZEL STG RM FWT": CustomConfig(func=make_simple_thermostat, channels=(1,)),
}
hmed.ALL_DEVICES.append(DEVICES)
BLACKLISTED_DEVICES: tuple[str, ...] = ("HmIP-STHO",)
hmed.BLACKLISTED_DEVICES.append(BLACKLISTED_DEVICES)
111 changes: 55 additions & 56 deletions hahomematic/platforms/custom/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,62 +514,61 @@ def make_rf_window_drive(


# Case for device model is not relevant
hmed.ALL_DEVICES.append(
{
"263 146": CustomConfig(func=make_rf_cover, channels=(1,)),
"263 147": CustomConfig(func=make_rf_cover, channels=(1,)),
"HM-LC-Bl1-FM": CustomConfig(func=make_rf_cover, channels=(1,)),
"HM-LC-Bl1-FM-2": CustomConfig(func=make_rf_cover, channels=(1,)),
"HM-LC-Bl1-PB-FM": CustomConfig(func=make_rf_cover, channels=(1,)),
"HM-LC-Bl1-SM": CustomConfig(func=make_rf_cover, channels=(1,)),
"HM-LC-Bl1-SM-2": CustomConfig(func=make_rf_cover, channels=(1,)),
"HM-LC-Bl1PBU-FM": CustomConfig(func=make_rf_cover, channels=(1,)),
"HM-LC-BlX": CustomConfig(func=make_rf_cover, channels=(1,)),
"HM-LC-Ja1PBU-FM": CustomConfig(func=make_rf_blind, channels=(1,)),
"HM-LC-JaX": CustomConfig(func=make_rf_blind, channels=(1,)),
"HM-Sec-Win": CustomConfig(
func=make_rf_window_drive,
channels=(1,),
extended=ExtendedConfig(
additional_entities={
1: (
"DIRECTION",
"WORKING",
"ERROR",
),
2: (
"LEVEL",
"STATUS",
),
}
),
DEVICES: dict[str, CustomConfig | tuple[CustomConfig, ...]] = {
"263 146": CustomConfig(func=make_rf_cover, channels=(1,)),
"263 147": CustomConfig(func=make_rf_cover, channels=(1,)),
"HM-LC-Bl1-FM": CustomConfig(func=make_rf_cover, channels=(1,)),
"HM-LC-Bl1-FM-2": CustomConfig(func=make_rf_cover, channels=(1,)),
"HM-LC-Bl1-PB-FM": CustomConfig(func=make_rf_cover, channels=(1,)),
"HM-LC-Bl1-SM": CustomConfig(func=make_rf_cover, channels=(1,)),
"HM-LC-Bl1-SM-2": CustomConfig(func=make_rf_cover, channels=(1,)),
"HM-LC-Bl1PBU-FM": CustomConfig(func=make_rf_cover, channels=(1,)),
"HM-LC-BlX": CustomConfig(func=make_rf_cover, channels=(1,)),
"HM-LC-Ja1PBU-FM": CustomConfig(func=make_rf_blind, channels=(1,)),
"HM-LC-JaX": CustomConfig(func=make_rf_blind, channels=(1,)),
"HM-Sec-Win": CustomConfig(
func=make_rf_window_drive,
channels=(1,),
extended=ExtendedConfig(
additional_entities={
1: (
"DIRECTION",
"WORKING",
"ERROR",
),
2: (
"LEVEL",
"STATUS",
),
}
),
"HMW-LC-Bl1": CustomConfig(func=make_rf_cover, channels=(3,)),
"HmIP-BBL": CustomConfig(func=make_ip_blind, channels=(3,)),
"HmIP-BROLL": CustomConfig(func=make_ip_cover, channels=(3,)),
"HmIP-DRBLI4": CustomConfig(
func=make_ip_blind,
channels=(9, 13, 17, 21),
extended=ExtendedConfig(
additional_entities={
0: ("ACTUAL_TEMPERATURE",),
}
),
),
"HMW-LC-Bl1": CustomConfig(func=make_rf_cover, channels=(3,)),
"HmIP-BBL": CustomConfig(func=make_ip_blind, channels=(3,)),
"HmIP-BROLL": CustomConfig(func=make_ip_cover, channels=(3,)),
"HmIP-DRBLI4": CustomConfig(
func=make_ip_blind,
channels=(9, 13, 17, 21),
extended=ExtendedConfig(
additional_entities={
0: ("ACTUAL_TEMPERATURE",),
}
),
"HmIP-FBL": CustomConfig(func=make_ip_blind, channels=(3,)),
"HmIP-FROLL": CustomConfig(func=make_ip_cover, channels=(3,)),
"HmIP-HDM": CustomConfig(func=make_ip_blind, channels=(0,)),
"HmIP-MOD-HO": CustomConfig(func=make_ip_garage, channels=(1,)),
"HmIP-MOD-TM": CustomConfig(func=make_ip_garage, channels=(1,)),
"HmIPW-DRBL4": CustomConfig(
func=make_ip_blind,
channels=(1, 5, 9, 13),
extended=ExtendedConfig(
additional_entities={
0: ("ACTUAL_TEMPERATURE",),
}
),
),
"HmIP-FBL": CustomConfig(func=make_ip_blind, channels=(3,)),
"HmIP-FROLL": CustomConfig(func=make_ip_cover, channels=(3,)),
"HmIP-HDM": CustomConfig(func=make_ip_blind, channels=(0,)),
"HmIP-MOD-HO": CustomConfig(func=make_ip_garage, channels=(1,)),
"HmIP-MOD-TM": CustomConfig(func=make_ip_garage, channels=(1,)),
"HmIPW-DRBL4": CustomConfig(
func=make_ip_blind,
channels=(1, 5, 9, 13),
extended=ExtendedConfig(
additional_entities={
0: ("ACTUAL_TEMPERATURE",),
}
),
"ZEL STG RM FEP 230V": CustomConfig(func=make_rf_cover, channels=(1,)),
}
)
),
"ZEL STG RM FEP 230V": CustomConfig(func=make_rf_cover, channels=(1,)),
}
hmed.ALL_DEVICES.append(DEVICES)
Loading

0 comments on commit 629395a

Please sign in to comment.