Skip to content

Commit

Permalink
feat: shorten zone name if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
ml1nk committed Dec 29, 2023
1 parent 35bdabe commit dd65147
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion custom_components/mypyllant/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
ZoneTimeProgram,
)

from custom_components.mypyllant.utils import shorten_zone_name

from . import SystemCoordinator
from .const import (
DEFAULT_TIME_PROGRAM_OVERWRITE,
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion custom_components/mypyllant/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
Zone,
)

from custom_components.mypyllant.utils import shorten_zone_name

from . import DailyDataCoordinator, SystemCoordinator
from .const import DOMAIN

Expand Down Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions custom_components/mypyllant/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dd65147

Please sign in to comment.