Skip to content

Commit ce8c919

Browse files
Merge pull request #53 from milosljubenovic/fix/ha-2026.2.0-compatibility
Fix HA 2026.2.0 compatibility
2 parents 12ca53d + d6172f8 commit ce8c919

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

custom_components/catlink/entitites/catlink.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from homeassistant.components import persistent_notification
44
from homeassistant.helpers.device_registry import DeviceInfo
55
from homeassistant.helpers.update_coordinator import CoordinatorEntity
6+
from homeassistant.util import slugify
67

78
from ..const import _LOGGER, DOMAIN
89
from ..modules.device import Device
@@ -23,11 +24,12 @@ def __init__(self, name, device: Device, option=None) -> None:
2324
self._attr_device_id = f"{device.type}_{device.mac}"
2425
self._attr_unique_id = f"{self._attr_device_id}-{name}"
2526
mac = device.mac[-4:] if device.mac else device.id
26-
self.entity_id = f"{DOMAIN}.{device.type.lower()}_{mac}_{name}"
27+
object_id = f"{device.type}_{mac}_{name}"
28+
self.entity_id = f"{DOMAIN}.{slugify(object_id)}"
2729
self._attr_icon = self._option.get("icon")
2830
self._attr_device_class = self._option.get("class")
29-
self._attr_unit_of_measurement = self._option.get("unit")
30-
self._attr_state_class = option.get("state_class")
31+
self._attr_native_unit_of_measurement = self._option.get("unit")
32+
self._attr_state_class = self._option.get("state_class")
3133
self._attr_device_info = DeviceInfo(
3234
identifiers={(DOMAIN, self._attr_device_id)},
3335
name=device.name,
@@ -68,7 +70,7 @@ async def async_request_api(self, api, params=None, method="GET", **kwargs) -> d
6870
throw = kwargs.pop("throw", None)
6971
rdt = await self.account.request(api, params, method, **kwargs)
7072
if throw:
71-
persistent_notification.create(
73+
persistent_notification.async_create(
7274
self.hass,
7375
f"{rdt}",
7476
f"Request: {api}",

custom_components/catlink/modules/account.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ async def request(self, api, pms=None, method="GET", **kwargs) -> dict:
109109
kws["data"] = pms
110110
try:
111111
req = await self.http.request(method, url, **kws)
112-
return await req.json() or {}
112+
result = await req.json() or {}
113+
_LOGGER.debug("API response %s %s: %s", method, api, result)
114+
return result
113115
except (ClientConnectorError, TimeoutError) as exc: # noqa: UP041
114116
_LOGGER.error("Request api failed: %s", [method, url, pms, exc])
115117
return {}

custom_components/catlink/modules/devices_coordinator.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ async def update_hass_entities(self, domain, dvc) -> None:
7373
add = self.hass.data[DOMAIN]["add_entities"].get(domain)
7474
if not add or not hasattr(dvc, hdk):
7575
return
76+
added_entity_ids: list[str] = []
7677
for k, cfg in getattr(dvc, hdk).items():
7778
key = f"{domain}.{k}.{dvc.id}"
7879
new = None
@@ -91,3 +92,10 @@ async def update_hass_entities(self, domain, dvc) -> None:
9192
if new:
9293
self._subs[key] = new
9394
add([new])
95+
added_entity_ids.append(new.entity_id)
96+
if added_entity_ids:
97+
_LOGGER.info(
98+
"Device %s entities: %s",
99+
dvc.name,
100+
added_entity_ids,
101+
)

0 commit comments

Comments
 (0)