Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions custom_components/kuna/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 9 additions & 3 deletions custom_components/kuna/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -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