From 4edb8a3f59838841bfbe0455da25f229d8705114 Mon Sep 17 00:00:00 2001 From: Elad Bar Date: Thu, 27 Jun 2024 09:39:23 +0300 Subject: [PATCH] set non unique device name to water meter instead of just meter --- CHANGELOG.md | 9 +++++++++ custom_components/citymind_water_meter/common/enums.py | 4 ++-- .../data_processors/account_processor.py | 6 +++--- .../citymind_water_meter/models/account_data.py | 4 ++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93976af..830817a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## v3.0.7 + +- Adjust non unique device names: + + | Approach | Meter | Account | Reason | + | ---------------- | --------------------------------- | ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | + | Unique (Default) | {address} {meter serial number} | {first name} {last name} {account number} | [can't rename meter device to a meaningful name #39](https://github.com/maorcc/citymind_water_meter/issues/39) | + | Non unique | Water Meter {meter serial number} | Account {account number} | [Bad Entity Names - seems to be translated from Hebrew #71](https://github.com/maorcc/citymind_water_meter/issues/71) | + ## v3.0.6 - Improve reconnect process (cool-down between attempts) diff --git a/custom_components/citymind_water_meter/common/enums.py b/custom_components/citymind_water_meter/common/enums.py index d1963a3..7170b1e 100644 --- a/custom_components/citymind_water_meter/common/enums.py +++ b/custom_components/citymind_water_meter/common/enums.py @@ -13,8 +13,8 @@ class AlertType(Enum): class EntityType(StrEnum): - METER = "meter" - ACCOUNT = "account" + METER = "Water Meter" + ACCOUNT = "Account" class ResetPolicy(Enum): diff --git a/custom_components/citymind_water_meter/data_processors/account_processor.py b/custom_components/citymind_water_meter/data_processors/account_processor.py index 0f66d50..4cff25a 100644 --- a/custom_components/citymind_water_meter/data_processors/account_processor.py +++ b/custom_components/citymind_water_meter/data_processors/account_processor.py @@ -21,7 +21,7 @@ SETTINGS_ALERT_TYPE_ID, SETTINGS_MEDIA_TYPE_ID, ) -from ..common.enums import AlertChannel, AlertType, EntityType +from ..common.enums import AlertChannel, AlertType, EntityKeys, EntityType from ..managers.config_manager import ConfigManager from ..models.account_data import AccountData from .base_processor import BaseProcessor @@ -112,8 +112,8 @@ def _process_api_data(self): ) @staticmethod - def _get_alert_settings(settings_section: dict) -> dict[EntityType, bool]: - alert_settings: dict[EntityType, bool] = {} + def _get_alert_settings(settings_section: dict) -> dict[EntityKeys, bool]: + alert_settings: dict[EntityKeys, bool] = {} for entity_type in ALERT_MAPPING: alert_mapping = ALERT_MAPPING[entity_type] diff --git a/custom_components/citymind_water_meter/models/account_data.py b/custom_components/citymind_water_meter/models/account_data.py index d41ddc3..d745129 100644 --- a/custom_components/citymind_water_meter/models/account_data.py +++ b/custom_components/citymind_water_meter/models/account_data.py @@ -2,7 +2,7 @@ import json -from custom_components.citymind_water_meter.common.enums import EntityType +from custom_components.citymind_water_meter.common.enums import EntityKeys class AccountData: @@ -16,7 +16,7 @@ class AccountData: vacations: int | None alerts: int | None messages: int | None - alert_settings: dict[EntityType, bool] | None + alert_settings: dict[EntityKeys, bool] | None def __init__(self): self.account_number = None