From 53f70f7e70763969ef1518503c4ecac167654ae8 Mon Sep 17 00:00:00 2001 From: SukramJ Date: Tue, 7 May 2024 13:26:15 +0200 Subject: [PATCH] Bump hahomematic to 2024.5.1 (#668) --- changelog.md | 5 +++++ .../homematicip_local/control_unit.py | 6 ++++-- custom_components/homematicip_local/event.py | 14 ++++++++++---- .../homematicip_local/generic_entity.py | 14 ++++++++------ custom_components/homematicip_local/manifest.json | 4 ++-- custom_components/homematicip_local/update.py | 8 ++++---- requirements_test.txt | 6 +++--- 7 files changed, 36 insertions(+), 21 deletions(-) diff --git a/changelog.md b/changelog.md index c4d29a4c..5000c1f3 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,8 @@ +# Version 1.61.0 (2024-05-07) + +- Bump hahomematic to 2024.5.1 + - Improve callback register/unregister + # Version 1.61.0 (2024-05-05) - Bump hahomematic to 2024.5.0 diff --git a/custom_components/homematicip_local/control_unit.py b/custom_components/homematicip_local/control_unit.py index fd13df32..9c620e54 100644 --- a/custom_components/homematicip_local/control_unit.py +++ b/custom_components/homematicip_local/control_unit.py @@ -13,6 +13,7 @@ from hahomematic.central import INTERFACE_EVENT_SCHEMA, CentralConfig, CentralUnit from hahomematic.client import InterfaceConfig from hahomematic.const import ( + CALLBACK_TYPE, CONF_PASSWORD, CONF_USERNAME, EVENT_ADDRESS, @@ -114,7 +115,7 @@ def __init__(self, control_config: ControlConfig) -> None: self._enable_system_notifications = self._config_data[CONF_ENABLE_SYSTEM_NOTIFICATIONS] self._central: CentralUnit = self._create_central() self._attr_device_info: DeviceInfo | None = None - self._unregister_callbacks: list[Callable] = [] + self._unregister_callbacks: list[CALLBACK_TYPE] = [] async def start_central(self) -> None: """Start the central unit.""" @@ -231,7 +232,8 @@ async def stop_central(self, *args: Any) -> None: self._scheduler.de_init() for unregister in self._unregister_callbacks: - unregister() + if unregister is not None: + unregister() await super().stop_central(*args) diff --git a/custom_components/homematicip_local/event.py b/custom_components/homematicip_local/event.py index 0a1ab147..9c7e992c 100644 --- a/custom_components/homematicip_local/event.py +++ b/custom_components/homematicip_local/event.py @@ -2,11 +2,16 @@ from __future__ import annotations -from collections.abc import Callable import logging from typing import Any -from hahomematic.const import ENTITY_EVENTS, EVENT_ADDRESS, EVENT_INTERFACE_ID, HmPlatform +from hahomematic.const import ( + CALLBACK_TYPE, + ENTITY_EVENTS, + EVENT_ADDRESS, + EVENT_INTERFACE_ID, + HmPlatform, +) from hahomematic.platforms.event import GenericEvent from homeassistant.components.event import EventDeviceClass, EventEntity @@ -93,7 +98,7 @@ def __init__( EVENT_ADDRESS: self._hm_primary_entity.channel_address, EVENT_MODEL: self._hm_primary_entity.device.device_type, } - self._unregister_callbacks: list[Callable] = [] + self._unregister_callbacks: list[CALLBACK_TYPE] = [] _LOGGER.debug( "init: Setting up %s %s", self._hm_primary_entity.device.name, @@ -142,7 +147,8 @@ async def async_will_remove_from_hass(self) -> None: """Run when hmip device will be removed from hass.""" # Remove callback from device. for unregister in self._unregister_callbacks: - unregister() + if unregister is not None: + unregister() @callback def _async_device_removed(self, *args: Any, **kwargs: Any) -> None: diff --git a/custom_components/homematicip_local/generic_entity.py b/custom_components/homematicip_local/generic_entity.py index ba3c6287..c65f0480 100644 --- a/custom_components/homematicip_local/generic_entity.py +++ b/custom_components/homematicip_local/generic_entity.py @@ -2,11 +2,11 @@ from __future__ import annotations -from collections.abc import Callable, Mapping +from collections.abc import Mapping import logging from typing import Any, Final, Generic -from hahomematic.const import CallSource +from hahomematic.const import CALLBACK_TYPE, CallSource from hahomematic.platforms.custom.entity import CustomEntity from hahomematic.platforms.entity import CallbackEntity from hahomematic.platforms.generic.entity import GenericEntity @@ -84,7 +84,7 @@ def __init__( ) self._static_state_attributes = self._get_static_state_attributes() - self._unregister_callbacks: list[Callable] = [] + self._unregister_callbacks: list[CALLBACK_TYPE] = [] _LOGGER.debug("init: Setting up %s", hm_entity.full_name) if ( @@ -245,7 +245,8 @@ async def async_will_remove_from_hass(self) -> None: """Run when hmip device will be removed from hass.""" # Remove callback from device. for unregister in self._unregister_callbacks: - unregister() + if unregister is not None: + unregister() @callback def _async_device_removed(self, *args: Any, **kwargs: Any) -> None: @@ -314,7 +315,7 @@ def __init__( self.entity_description = entity_description self._attr_name = hm_hub_entity.name self._attr_device_info = control_unit.device_info - self._unregister_callbacks: list[Callable] = [] + self._unregister_callbacks: list[CALLBACK_TYPE] = [] _LOGGER.debug("init sysvar: Setting up %s", self.name) @property @@ -341,7 +342,8 @@ async def async_will_remove_from_hass(self) -> None: """Run when hmip sysvar entity will be removed from hass.""" # Remove callbacks. for unregister in self._unregister_callbacks: - unregister() + if unregister is not None: + unregister() @callback def _async_hub_entity_updated(self, *args: Any, **kwargs: Any) -> None: diff --git a/custom_components/homematicip_local/manifest.json b/custom_components/homematicip_local/manifest.json index 60aba060..8205c9d1 100644 --- a/custom_components/homematicip_local/manifest.json +++ b/custom_components/homematicip_local/manifest.json @@ -10,13 +10,13 @@ "iot_class": "local_push", "issue_tracker": "https://github.com/danielperna84/hahomematic/issues", "loggers": ["hahomematic"], - "requirements": ["hahomematic==2024.5.0"], + "requirements": ["hahomematic==2024.5.1"], "ssdp": [ { "manufacturer": "EQ3", "manufacturerURL": "http://www.homematic.com" } ], - "version": "1.61.0", + "version": "1.62.0", "zeroconf": [] } diff --git a/custom_components/homematicip_local/update.py b/custom_components/homematicip_local/update.py index 94c182bd..d3130955 100644 --- a/custom_components/homematicip_local/update.py +++ b/custom_components/homematicip_local/update.py @@ -2,11 +2,10 @@ from __future__ import annotations -from collections.abc import Callable import logging from typing import Any, Final -from hahomematic.const import DeviceFirmwareState, HmPlatform +from hahomematic.const import CALLBACK_TYPE, DeviceFirmwareState, HmPlatform from hahomematic.platforms.update import HmUpdate from homeassistant.components.update import UpdateEntity, UpdateEntityFeature @@ -83,7 +82,7 @@ def __init__( self._attr_extra_state_attributes = { ATTR_FIRMWARE_UPDATE_STATE: hm_entity.firmware_update_state } - self._unregister_callbacks: list[Callable] = [] + self._unregister_callbacks: list[CALLBACK_TYPE] = [] _LOGGER.debug("init: Setting up %s", hm_entity.full_name) @property @@ -156,7 +155,8 @@ async def async_will_remove_from_hass(self) -> None: """Run when hmip device will be removed from hass.""" # Remove callback from device. for unregister in self._unregister_callbacks: - unregister() + if unregister is not None: + unregister() @callback def _async_device_removed(self, *args: Any, **kwargs: Any) -> None: diff --git a/requirements_test.txt b/requirements_test.txt index 27de1102..b463dc69 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -2,8 +2,8 @@ async-upnp-client coverage==7.5.0 -hahomematic==2024.5.0 -homeassistant==2024.5.1 +hahomematic==2024.5.1 +homeassistant==2024.5.2 mypy==1.10.0 pip==24.0 pre-commit==3.7.0 @@ -12,7 +12,7 @@ pylint-strict-informational==0.1 pylint==3.1.0 pytest-asyncio==0.23.6 pytest-cov==5.0.0 -pytest-homeassistant-custom-component==0.13.121 +pytest-homeassistant-custom-component==0.13.122 pytest-rerunfailures==14.0 pytest-socket==0.7.0 pytest-timeout==2.3.1