Skip to content

Commit

Permalink
Mark secondary channels name with a V --> Vch (#163)
Browse files Browse the repository at this point in the history
* Mark secondary channels name with a V --> Vch

* Reduce logging
  • Loading branch information
SukramJ authored Jan 11, 2022
1 parent 970cf0b commit 4efd7c1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Version 0.19.0 (2022-01-10)
- Mark secondary channels name with a V --> Vch

Version 0.18.1 (2022-01-10)
- Reduce some log_level
- Fix callback to notify un_reach
Expand Down
4 changes: 2 additions & 2 deletions hahomematic/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,12 +643,12 @@ def create_devices(central: hm_central.CentralUnit) -> None:
new_entities: list[BaseEntity] = []
for interface_id, client in central.clients.items():
if not client:
_LOGGER.warning(
_LOGGER.debug(
"create_devices: Skipping interface %s, missing client.", interface_id
)
continue
if not central.paramsets.get_by_interface(interface_id=interface_id):
_LOGGER.warning(
_LOGGER.debug(
"create_devices: Skipping interface %s, missing paramsets.",
interface_id,
)
Expand Down
5 changes: 3 additions & 2 deletions hahomematic/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,19 +470,20 @@ def __init__(
device_has_multiple_channels = hm_custom_entity.is_multi_channel_device(
device_type=self._device.device_type, sub_type=self._device.sub_type
)
self.usage = self._custom_entity_usage()
self.name = get_custom_entity_name(
central=self._central,
device_address=self.device_address,
unique_id=self.unique_id,
channel_no=channel_no,
device_type=self.device_type,
is_primary_channel=check_channel_is_only_primary_channel(
is_only_primary_channel=check_channel_is_only_primary_channel(
current_channel=channel_no,
device_def=device_def,
device_has_multiple_channels=device_has_multiple_channels,
),
usage=self.usage,
)
self.usage = self._custom_entity_usage()
self.data_entities: dict[str, GenericEntity] = {}
self._init_entities()

Expand Down
9 changes: 6 additions & 3 deletions hahomematic/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
ATTR_NAME,
ATTR_TYPE,
ATTR_VALUE,
HmEntityUsage,
)
import hahomematic.devices.entity_definition as hm_entity_definition
from hahomematic.exceptions import HaHomematicException
Expand Down Expand Up @@ -199,17 +200,19 @@ def get_custom_entity_name(
unique_id: str,
channel_no: int,
device_type: str,
is_primary_channel: bool,
is_only_primary_channel: bool,
usage: HmEntityUsage,
) -> str:
"""Rename name for custom entity"""
if custom_entity_name := _get_base_name_from_channel_or_device(
central=central,
channel_address=f"{device_address}:{channel_no}",
device_type=device_type,
):
if is_primary_channel and ":" in custom_entity_name:
if is_only_primary_channel and ":" in custom_entity_name:
return custom_entity_name.split(":")[0]
return custom_entity_name.replace(":", " ch")
marker = " ch" if usage == HmEntityUsage.CE_PRIMARY else " vch"
return custom_entity_name.replace(":", marker)

_LOGGER.info(
"Helper.get_custom_entity_name: Using unique_id for %s %s %s",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def readme():
},
PACKAGE_NAME = "hahomematic"
HERE = os.path.abspath(os.path.dirname(__file__))
VERSION = "0.18.1"
VERSION = "0.19.0"

PACKAGES = find_packages(exclude=["tests", "tests.*", "dist", "build"])

Expand Down

0 comments on commit 4efd7c1

Please sign in to comment.