Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add button lock CE #1619

Merged
merged 7 commits into from
Jul 26, 2024
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.5.4
rev: v0.5.5
hooks:
- id: ruff
args:
Expand Down
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Version 2024.8.0 (2024-08-01)
# Version 2024.7.0 (2024-07-26)

- Rename last_updated -> modified_at
- Rename last_refreshed -> refreshed_at
- Add button lock CE

Add time units to HmIP-RGBW calls

Expand Down
47 changes: 38 additions & 9 deletions hahomematic/caches/visibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@
_RELEVANT_MASTER_PARAMSETS_BY_DEVICE: Final[
Mapping[str, tuple[tuple[int, ...], tuple[Parameter, ...]]]
] = {
"ALPHA-IP-RBG": (
(0, 1),
(
Parameter.TEMPERATURE_MAXIMUM,
Parameter.TEMPERATURE_MINIMUM,
Parameter.GLOBAL_BUTTON_LOCK,
),
),
"HM-CC-RT-DN": ((1,), (Parameter.TEMPERATURE_MAXIMUM, Parameter.TEMPERATURE_MINIMUM)),
"HM-CC-VG-1": ((1,), (Parameter.TEMPERATURE_MAXIMUM, Parameter.TEMPERATURE_MINIMUM)),
"HmIP-BWTH": (
(0, 1),
(
Parameter.TEMPERATURE_MAXIMUM,
Parameter.TEMPERATURE_MINIMUM,
Parameter.GLOBAL_BUTTON_LOCK,
),
),
"HmIP-DRBLI4": (
(1, 2, 3, 4, 5, 6, 7, 8, 9, 13, 17, 21),
(Parameter.CHANNEL_OPERATION_MODE,),
Expand All @@ -35,26 +53,37 @@
"HmIP-DRSI1": ((1,), (Parameter.CHANNEL_OPERATION_MODE,)),
"HmIP-DRSI4": ((1, 2, 3, 4), (Parameter.CHANNEL_OPERATION_MODE,)),
"HmIP-DSD-PCB": ((1,), (Parameter.CHANNEL_OPERATION_MODE,)),
"HmIP-FAL": ((0,), (Parameter.GLOBAL_BUTTON_LOCK,)),
"HmIP-FCI1": ((1,), (Parameter.CHANNEL_OPERATION_MODE,)),
"HmIP-FCI6": (tuple(range(1, 7)), (Parameter.CHANNEL_OPERATION_MODE,)),
"HmIP-FSI16": ((1,), (Parameter.CHANNEL_OPERATION_MODE,)),
"HmIP-HEATING": ((1,), (Parameter.TEMPERATURE_MAXIMUM, Parameter.TEMPERATURE_MINIMUM)),
"HmIP-MIO16-PCB": ((13, 14, 15, 16), (Parameter.CHANNEL_OPERATION_MODE,)),
"HmIP-MOD-RC8": (tuple(range(1, 9)), (Parameter.CHANNEL_OPERATION_MODE,)),
"HmIP-RGBW": ((0,), (Parameter.DEVICE_OPERATION_MODE,)),
"HmIP-STH": ((1,), (Parameter.TEMPERATURE_MAXIMUM, Parameter.TEMPERATURE_MINIMUM)),
"HmIP-WTH": (
(0, 1),
(
Parameter.TEMPERATURE_MAXIMUM,
Parameter.TEMPERATURE_MINIMUM,
Parameter.GLOBAL_BUTTON_LOCK,
),
),
"HmIP-eTRV": (
(0, 1),
(
Parameter.TEMPERATURE_MAXIMUM,
Parameter.TEMPERATURE_MINIMUM,
Parameter.GLOBAL_BUTTON_LOCK,
),
),
"HmIPW-DRBL4": ((1, 5, 9, 13), (Parameter.CHANNEL_OPERATION_MODE,)),
"HmIPW-DRI16": (tuple(range(1, 17)), (Parameter.CHANNEL_OPERATION_MODE,)),
"HmIPW-DRI32": (tuple(range(1, 33)), (Parameter.CHANNEL_OPERATION_MODE,)),
"HmIPW-FAL": ((0,), (Parameter.GLOBAL_BUTTON_LOCK,)),
"HmIPW-FIO6": (tuple(range(1, 7)), (Parameter.CHANNEL_OPERATION_MODE,)),
"ALPHA-IP-RBG": ((1,), (Parameter.TEMPERATURE_MAXIMUM, Parameter.TEMPERATURE_MINIMUM)),
"HM-CC-RT-DN": ((1,), (Parameter.TEMPERATURE_MAXIMUM, Parameter.TEMPERATURE_MINIMUM)),
"HM-CC-VG-1": ((1,), (Parameter.TEMPERATURE_MAXIMUM, Parameter.TEMPERATURE_MINIMUM)),
"HmIP-BWTH": ((1,), (Parameter.TEMPERATURE_MAXIMUM, Parameter.TEMPERATURE_MINIMUM)),
"HmIP-HEATING": ((1,), (Parameter.TEMPERATURE_MAXIMUM, Parameter.TEMPERATURE_MINIMUM)),
"HmIP-STH": ((1,), (Parameter.TEMPERATURE_MAXIMUM, Parameter.TEMPERATURE_MINIMUM)),
"HmIP-WTH": ((1,), (Parameter.TEMPERATURE_MAXIMUM, Parameter.TEMPERATURE_MINIMUM)),
"HmIP-eTRV": ((1,), (Parameter.TEMPERATURE_MAXIMUM, Parameter.TEMPERATURE_MINIMUM)),
"HmIPW-STH": ((1,), (Parameter.TEMPERATURE_MAXIMUM, Parameter.TEMPERATURE_MINIMUM)),
"HmIPW-WTH": ((1,), (Parameter.TEMPERATURE_MAXIMUM, Parameter.TEMPERATURE_MINIMUM)),
}

# Some parameters are marked as INTERNAL in the paramset and not considered by default,
Expand Down
1 change: 1 addition & 0 deletions hahomematic/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ class Parameter(StrEnum):
ERROR = "ERROR"
ERROR_JAMMED = "ERROR_JAMMED"
FREQUENCY = "FREQUENCY"
GLOBAL_BUTTON_LOCK = "GLOBAL_BUTTON_LOCK"
HEATING_COOLING = "HEATING_COOLING"
HUE = "HUE"
HUMIDITY = "HUMIDITY"
Expand Down
2 changes: 1 addition & 1 deletion hahomematic/platforms/custom/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,6 @@ def make_ip_thermostat_group(
"Thermostat AA": CustomConfig(make_ce_func=make_ip_thermostat, channels=(1,)),
"ZEL STG RM FWT": CustomConfig(make_ce_func=make_simple_thermostat, channels=(1,)),
}
hmed.ALL_DEVICES.append(DEVICES)
hmed.ALL_DEVICES[HmPlatform.CLIMATE] = DEVICES
BLACKLISTED_DEVICES: tuple[str, ...] = ("HmIP-STHO",)
hmed.ALL_BLACKLISTED_DEVICES.append(BLACKLISTED_DEVICES)
2 changes: 2 additions & 0 deletions hahomematic/platforms/custom/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
class DeviceProfile(StrEnum):
"""Enum for device profiles."""

BUTTON_LOCK = "ButtonLock"
IP_COVER = "IPCover"
IP_DIMMER = "IPDimmer"
IP_DRG_DALI = "IPDRGDALI"
Expand Down Expand Up @@ -61,6 +62,7 @@ class Field(Enum):
ACTIVE_PROFILE = "active_profile"
AUTO_MODE = "auto_mode"
BOOST_MODE = "boost_mode"
BUTTON_LOCK = "button_lock"
CHANNEL_COLOR = "channel_color"
CHANNEL_LEVEL = "channel_level"
CHANNEL_LEVEL_2 = "channel_level_2"
Expand Down
2 changes: 1 addition & 1 deletion hahomematic/platforms/custom/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,4 +742,4 @@ def make_rf_window_drive(
),
"ZEL STG RM FEP 230V": CustomConfig(make_ce_func=make_rf_cover, channels=(1,)),
}
hmed.ALL_DEVICES.append(DEVICES)
hmed.ALL_DEVICES[HmPlatform.COVER] = DEVICES
23 changes: 17 additions & 6 deletions hahomematic/platforms/custom/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import voluptuous as vol

from hahomematic import support as hms
from hahomematic.const import Parameter
from hahomematic.const import HmPlatform, Parameter
from hahomematic.platforms import device as hmd
from hahomematic.platforms.custom import entity as hmce
from hahomematic.platforms.custom.const import ED, DeviceProfile, Field
Expand All @@ -21,7 +21,7 @@

DEFAULT_INCLUDE_DEFAULT_ENTITIES: Final = True

ALL_DEVICES: list[Mapping[str, CustomConfig | tuple[CustomConfig, ...]]] = []
ALL_DEVICES: dict[HmPlatform, Mapping[str, CustomConfig | tuple[CustomConfig, ...]]] = {}
ALL_BLACKLISTED_DEVICES: list[tuple[str, ...]] = []

SCHEMA_ED_ADDITIONAL_ENTITIES = vol.Schema(
Expand Down Expand Up @@ -279,6 +279,14 @@
},
},
},
DeviceProfile.BUTTON_LOCK: {
ED.DEVICE_GROUP: {
ED.PRIMARY_CHANNEL: 0,
ED.REPEATABLE_FIELDS: {
Field.BUTTON_LOCK: Parameter.GLOBAL_BUTTON_LOCK,
},
},
},
DeviceProfile.IP_SIREN: {
ED.DEVICE_GROUP: {
ED.PRIMARY_CHANNEL: 3,
Expand Down Expand Up @@ -688,6 +696,7 @@ def _get_device_entities(

def get_entity_configs(
device_type: str,
platform: HmPlatform | None = None,
) -> tuple[CustomConfig | tuple[CustomConfig, ...], ...]:
"""Return the entity configs to create custom entities."""
device_type = device_type.lower().replace("hb-", "hm-")
Expand All @@ -699,7 +708,9 @@ def get_entity_configs(
):
return ()

for platform_devices in ALL_DEVICES:
for pf, platform_devices in ALL_DEVICES.items():
if platform is not None and pf != platform:
continue
if func := _get_entity_config_by_platform(
platform_devices=platform_devices,
device_type=device_type,
Expand All @@ -724,10 +735,10 @@ def _get_entity_config_by_platform(
return None


def is_multi_channel_device(device_type: str) -> bool:
def is_multi_channel_device(device_type: str, platform: HmPlatform) -> bool:
"""Return true, if device has multiple channels."""
channels: list[int] = []
for entity_configs in get_entity_configs(device_type=device_type):
for entity_configs in get_entity_configs(device_type=device_type, platform=platform):
if isinstance(entity_configs, CustomConfig):
channels.extend(entity_configs.channels)
else:
Expand Down Expand Up @@ -759,7 +770,7 @@ def get_required_parameters() -> tuple[Parameter, ...]:
):
required_parameters.extend(additional_entities)

for platform_spec in ALL_DEVICES:
for platform_spec in ALL_DEVICES.values():
for custom_configs in platform_spec.values():
if isinstance(custom_configs, CustomConfig):
if extended := custom_configs.extended:
Expand Down
10 changes: 9 additions & 1 deletion hahomematic/platforms/custom/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def __init__(
device=device,
unique_id=unique_id,
channel_no=channel_no,
is_in_multiple_channels=hmed.is_multi_channel_device(device_type=device.device_type),
is_in_multiple_channels=hmed.is_multi_channel_device(
device_type=device.device_type, platform=self.platform
),
)
self._extended: Final = extended
self._data_entities: Final[dict[Field, hmge.GenericEntity]] = {}
Expand Down Expand Up @@ -120,6 +122,11 @@ def _relevant_entities(self) -> tuple[hmge.GenericEntity, ...]:
"""Returns the list of relevant entities. To be overridden by subclasses."""
return self._readable_entities

@property
def entity_name_postfix(self) -> str:
"""Return the entity name postfix."""
return ""

def _get_entity_name(self) -> EntityNameData:
"""Create the name for the entity."""
is_only_primary_channel = check_channel_is_the_only_primary_channel(
Expand All @@ -133,6 +140,7 @@ def _get_entity_name(self) -> EntityNameData:
channel_no=self.channel_no,
is_only_primary_channel=is_only_primary_channel,
usage=self._usage,
postfix=self.entity_name_postfix.replace("_", " ").title(),
)

def _get_entity_usage(self) -> EntityUsage:
Expand Down
2 changes: 1 addition & 1 deletion hahomematic/platforms/custom/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,4 +1160,4 @@ def make_ip_drg_dali_light(
),
"OLIGO.smart.iq.HM": CustomConfig(make_ce_func=make_rf_dimmer, channels=(1, 2, 3, 4, 5, 6)),
}
hmed.ALL_DEVICES.append(DEVICES)
hmed.ALL_DEVICES[HmPlatform.LIGHT] = DEVICES
Loading