From 9aaf80de91b25394209135fa5fad85fda36c12cf Mon Sep 17 00:00:00 2001 From: Matt Clare Date: Fri, 11 Jul 2025 08:55:19 -0400 Subject: [PATCH 1/2] Update __init__.py According to the latest Home Assistant documentation, we should be using async_forward_entry_setups (plural) instead of async_forward_entry_setup (singular). The documentation specifically states: "Instead, await hass.config_entries.async_forward_entry_setups as it can load multiple platforms at once and is more efficient since it does not require a separate import executor job for each platform." We're now calling async_forward_entry_setups once with the entire list of components (KUNA_COMPONENTS) instead of in a loop --- custom_components/kuna/__init__.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/custom_components/kuna/__init__.py b/custom_components/kuna/__init__.py index 4f23ac4..b0801a2 100644 --- a/custom_components/kuna/__init__.py +++ b/custom_components/kuna/__init__.py @@ -69,10 +69,9 @@ async def async_setup_entry(hass, entry): hass.data[DOMAIN] = kuna - for component in KUNA_COMPONENTS: - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(entry, component) - ) + hass.async_create_task( + hass.config_entries.async_forward_entry_setups(entry, KUNA_COMPONENTS) + ) async_track_time_interval(hass, kuna.update, update_interval) From 1eea5191d3eb68ff6ee5c2a1f9aae9439040855b Mon Sep 17 00:00:00 2001 From: Matt Clare Date: Sat, 19 Jul 2025 13:50:25 -0400 Subject: [PATCH 2/2] Update camera.py Fixed error caused by the stream monitoring's trying to pass width and height parameters to the async_camera_image() method, but it looks like HA no longer accept these parameters. --- custom_components/kuna/camera.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/custom_components/kuna/camera.py b/custom_components/kuna/camera.py index c33746f..233510c 100644 --- a/custom_components/kuna/camera.py +++ b/custom_components/kuna/camera.py @@ -118,11 +118,17 @@ async def async_added_to_hass(self): def _ready_for_snapshot(self, now): return self._next_snapshot_at is None or now > self._next_snapshot_at - async def async_camera_image(self): + async def async_camera_image(self, width: int | None = None, height: int | None = None): """Get and return an image from the camera, only once every stream_interval seconds.""" stream_interval = timedelta(seconds=self._config[CONF_STREAM_INTERVAL]) now = utcnow() + if self._ready_for_snapshot(now): - self._last_image = await self._camera.get_thumbnail() - self._next_snapshot_at = now + stream_interval + try: + self._last_image = await self._camera.get_thumbnail() + self._next_snapshot_at = now + stream_interval + except Exception as e: + _LOGGER.error(f"Error fetching thumbnail for {self.name}: {str(e)}") + self._last_image = None + return None return self._last_image