Skip to content

Commit

Permalink
Make load only relevant paramset descriptions configurable (#1637)
Browse files Browse the repository at this point in the history
* Make load only relevant paramset descriptions

Add UN_IGNORE_WILDCARD to get_parameters

* Update changelog.md
  • Loading branch information
SukramJ authored Aug 16, 2024
1 parent 2de68b8 commit c5dfe09
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 12 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Version 2024.8.4 (2024-08-16)

- Make load only relevant paramset descriptions configurable
- Add UN_IGNORE_WILDCARD to get_parameters

# Version 2024.8.3 (2024-08-15)

- Ignore parameters on un ignore parameter list
Expand Down
21 changes: 13 additions & 8 deletions hahomematic/caches/visibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@
from typing import Any, Final

from hahomematic import central as hmcu, support as hms
from hahomematic.const import CLICK_EVENTS, DEFAULT_ENCODING, Parameter, ParamsetKey
from hahomematic.const import (
CLICK_EVENTS,
DEFAULT_ENCODING,
UN_IGNORE_WILDCARD,
Parameter,
ParamsetKey,
)
from hahomematic.platforms.custom.definition import get_required_parameters
from hahomematic.support import element_matches_key, reduce_args

_LOGGER: Final = logging.getLogger(__name__)

_FILE_CUSTOM_UN_IGNORE_PARAMETERS: Final = "unignore"
_UN_IGNORE_WILDCARD: Final = "all"
_IGNORE_DEVICE_TYPE: Final = "ignore_"

# Define which additional parameters from MASTER paramset should be created as entity.
Expand Down Expand Up @@ -456,9 +461,9 @@ def _parameter_is_un_ignored(
search_matrix = (
(
(device_type_l, channel_no),
(device_type_l, _UN_IGNORE_WILDCARD),
(_UN_IGNORE_WILDCARD, channel_no),
(_UN_IGNORE_WILDCARD, _UN_IGNORE_WILDCARD),
(device_type_l, UN_IGNORE_WILDCARD),
(UN_IGNORE_WILDCARD, channel_no),
(UN_IGNORE_WILDCARD, UN_IGNORE_WILDCARD),
)
if paramset_key == ParamsetKey.VALUES
else ((device_type_l, channel_no),)
Expand Down Expand Up @@ -626,8 +631,8 @@ def _get_un_ignore_line_details(
)
return None
if (
device_type == _UN_IGNORE_WILDCARD
and channel_no == _UN_IGNORE_WILDCARD
device_type == UN_IGNORE_WILDCARD
and channel_no == UN_IGNORE_WILDCARD
and paramset_key == ParamsetKey.VALUES
):
return parameter
Expand All @@ -651,7 +656,7 @@ def _add_complex_un_ignore_entry(
channel_no,
)
return
if device_type == _UN_IGNORE_WILDCARD:
if device_type == UN_IGNORE_WILDCARD:
_LOGGER.warning(
"ADD_UN_IGNORE_ENTRY: device_type must be set for paramset_key MASTER."
)
Expand Down
16 changes: 14 additions & 2 deletions hahomematic/central/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
EVENT_INTERFACE_ID,
EVENT_TYPE,
IGNORE_FOR_UN_IGNORE_PARAMETERS,
UN_IGNORE_WILDCARD,
BackendSystemEvent,
Description,
DeviceFirmwareState,
Expand Down Expand Up @@ -1031,6 +1032,7 @@ def get_parameters(
operations: tuple[Operations, ...],
full_format: bool = False,
un_ignore_candidates_only: bool = False,
use_channel_wildcard: bool = False,
) -> tuple[str, ...]:
"""Return all parameters from VALUES paramset."""
parameters: set[str] = set()
Expand Down Expand Up @@ -1064,8 +1066,14 @@ def get_parameters(
or parameter in IGNORE_FOR_UN_IGNORE_PARAMETERS
):
continue

channel = (
UN_IGNORE_WILDCARD
if use_channel_wildcard
else get_channel_no(channel_address)
)
parameters.add(
f"{parameter}@{device_type}:{get_channel_no(channel_address)}:{paramset_key}"
f"{parameter}:{paramset_key}@{device_type}:{channel}"
if full_format
else parameter
)
Expand Down Expand Up @@ -1308,6 +1316,7 @@ def __init__(
json_port: int | None = None,
un_ignore_list: list[str] | None = None,
start_direct: bool = False,
load_only_relevant_paramset_descriptions: bool = True,
) -> None:
"""Init the client config."""
self.connection_state: Final = CentralConnectionState()
Expand All @@ -1326,7 +1335,10 @@ def __init__(
self.callback_port: Final = callback_port
self.json_port: Final = json_port
self.un_ignore_list: Final = un_ignore_list
self.start_direct = start_direct
self.start_direct: Final = start_direct
self.load_only_relevant_paramset_descriptions: Final = (
load_only_relevant_paramset_descriptions
)

@property
def central_url(self) -> str:
Expand Down
4 changes: 3 additions & 1 deletion hahomematic/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,9 @@ async def get_paramset_descriptions(
if channel_no is None
else device_description[Description.PARENT_TYPE]
)
if only_relevant and not self.central.parameter_visibility.is_relevant_paramset(
if (
self.central.config.load_only_relevant_paramset_descriptions or only_relevant
) and not self.central.parameter_visibility.is_relevant_paramset(
device_type=device_type,
channel_no=channel_no,
paramset_key=paramset_key,
Expand Down
2 changes: 2 additions & 0 deletions hahomematic/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@
ENTITY_KEY = tuple[str, str]
CALLBACK_TYPE = Callable[[], None] | None

UN_IGNORE_WILDCARD: Final = "all"


class Backend(StrEnum):
"""Enum with supported hahomematic backends."""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "hahomematic"
version = "2024.8.3"
version = "2024.8.4"
license = {text = "MIT License"}
description = "Homematic interface for Home Assistant running on Python 3."
readme = "README.md"
Expand Down

0 comments on commit c5dfe09

Please sign in to comment.