Skip to content

Commit

Permalink
Rename instance_name to central_name (#2002)
Browse files Browse the repository at this point in the history
* Rename instance_name to central_name
  • Loading branch information
SukramJ authored Jan 21, 2025
1 parent a675cbe commit c2e6881
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 16 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Version 2025.1.11 (2025-01-20)

- Delay start of scheduler until devices are created
- Rename instance_name to central_name
- Slugify cache file name

# Version 2025.1.10 (2025-01-17)
Expand Down
2 changes: 1 addition & 1 deletion hahomematic/caches/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def _fire_event(mismatch_count: int) -> None:
EventKey.INTERFACE_ID: self._interface_id,
EventKey.TYPE: event_type,
EventKey.DATA: {
EventKey.INSTANCE_NAME: self._central.name,
EventKey.CENTRAL_NAME: self._central.name,
EventKey.PONG_MISMATCH_COUNT: mismatch_count,
},
}
Expand Down
7 changes: 7 additions & 0 deletions hahomematic/caches/persistent.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,3 +391,10 @@ async def load(self) -> DataOperationResult:
async def save(self) -> DataOperationResult:
"""Save current paramset descriptions to disk."""
return await super().save()


def cleanup_cache_dirs(central_name: str, storage_folder: str) -> None:
"""Clean up the used cached directories."""
cache_dir = f"{storage_folder}/{CACHE_PATH}"
for file_to_delete in (FILE_DEVICES, FILE_PARAMSETS):
delete_file(folder=cache_dir, file_name=f"{slugify(central_name)}_{file_to_delete}")
2 changes: 1 addition & 1 deletion hahomematic/central/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@

_LOGGER: Final = logging.getLogger(__name__)

# {instance_name, central}
# {central_name, central}
CENTRAL_INSTANCES: Final[dict[str, CentralUnit]] = {}
ConnectionProblemIssuer = JsonRpcAioHttpClient | XmlRpcProxy

Expand Down
2 changes: 1 addition & 1 deletion hahomematic/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ class EventKey(StrEnum):

ADDRESS = "address"
AVAILABLE = "available"
CENTRAL_NAME = "central_name"
CHANNEL_NO = "channel_no"
DATA = "data"
INSTANCE_NAME = "instance_name"
INTERFACE_ID = "interface_id"
MODEL = "model"
PARAMETER = "parameter"
Expand Down
12 changes: 0 additions & 12 deletions hahomematic/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@
from hahomematic.const import (
ADDRESS_SEPARATOR,
ALLOWED_HOSTNAME_PATTERN,
CACHE_PATH,
CCU_PASSWORD_PATTERN,
CHANNEL_ADDRESS_PATTERN,
DEVICE_ADDRESS_PATTERN,
FILE_DEVICES,
FILE_PARAMSETS,
HTMLTAG_PATTERN,
IDENTIFIER_SEPARATOR,
INIT_DATETIME,
Expand Down Expand Up @@ -386,15 +383,6 @@ def _get_search_key(search_elements: Collection[str], search_key: str) -> str |
return None


def cleanup_cache_dirs(instance_name: str, storage_folder: str) -> None:
"""Clean up the used cached directories."""
cache_dir = f"{storage_folder}/{CACHE_PATH}"
files_to_delete = [FILE_DEVICES, FILE_PARAMSETS]

for file_to_delete in files_to_delete:
delete_file(folder=cache_dir, file_name=f"{instance_name}_{file_to_delete}")


@dataclass(frozen=True, kw_only=True, slots=True)
class CacheEntry:
"""An entry for the value cache."""
Expand Down
2 changes: 1 addition & 1 deletion tests/test_central.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ async def test_pending_pong_failure(
EventType.INTERFACE,
{
"data": {
"instance_name": "CentralTest",
"central_name": "CentralTest",
"pong_mismatch_count": 16,
},
"interface_id": "CentralTest-BidCos-RF",
Expand Down

0 comments on commit c2e6881

Please sign in to comment.