From dd6514730f8fa512a5a5e714f4a5ca6f4c24c32b Mon Sep 17 00:00:00 2001 From: Marcel Link Date: Fri, 29 Dec 2023 20:44:14 +0100 Subject: [PATCH] feat: shorten zone name if necessary --- custom_components/mypyllant/climate.py | 4 +++- custom_components/mypyllant/sensor.py | 4 +++- custom_components/mypyllant/utils.py | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/custom_components/mypyllant/climate.py b/custom_components/mypyllant/climate.py index 63591cf..e6415be 100644 --- a/custom_components/mypyllant/climate.py +++ b/custom_components/mypyllant/climate.py @@ -45,6 +45,8 @@ ZoneTimeProgram, ) +from custom_components.mypyllant.utils import shorten_zone_name + from . import SystemCoordinator from .const import ( DEFAULT_TIME_PROGRAM_OVERWRITE, @@ -277,7 +279,7 @@ def circuit_name_suffix(self) -> str: @property def name_prefix(self) -> str: - return f"{self.system.home.home_name or self.system.home.nomenclature} Zone {self.zone.name}{self.circuit_name_suffix}" + return f"{self.system.home.home_name or self.system.home.nomenclature} Zone {shorten_zone_name(self.zone.name)}{self.circuit_name_suffix}" @property def id_infix(self) -> str: diff --git a/custom_components/mypyllant/sensor.py b/custom_components/mypyllant/sensor.py index e8c7366..0289f61 100644 --- a/custom_components/mypyllant/sensor.py +++ b/custom_components/mypyllant/sensor.py @@ -25,6 +25,8 @@ Zone, ) +from custom_components.mypyllant.utils import shorten_zone_name + from . import DailyDataCoordinator, SystemCoordinator from .const import DOMAIN @@ -333,7 +335,7 @@ def circuit_name_suffix(self) -> str: @property def name_prefix(self) -> str: - return f"{self.system.home.home_name or self.system.home.nomenclature} Zone {self.zone.name}{self.circuit_name_suffix}" + return f"{self.system.home.home_name or self.system.home.nomenclature} Zone {shorten_zone_name(self.zone.name)}{self.circuit_name_suffix}" @property def id_infix(self) -> str: diff --git a/custom_components/mypyllant/utils.py b/custom_components/mypyllant/utils.py index 38a77b5..f2bcd45 100644 --- a/custom_components/mypyllant/utils.py +++ b/custom_components/mypyllant/utils.py @@ -3,6 +3,12 @@ from aiohttp.client_exceptions import ClientResponseError +def shorten_zone_name(zone_name: str) -> str: + if zone_name.startswith("Zone "): + return zone_name[5:] + return zone_name + + def is_quota_exceeded_exception(exc_info: Exception) -> bool: """ Returns True if the exception is a quota exceeded ClientResponseError