From a1a41f327694de3ce4519f517b977930f3e88971 Mon Sep 17 00:00:00 2001 From: Jeff Culverhouse Date: Tue, 27 Jan 2026 12:48:31 -0500 Subject: [PATCH] fix: prevent crash when unsupported device model is configured Iterate over self.devices (successfully built devices) instead of self.amcrest_devices (all API devices) in event and snapshot collection loops. This prevents KeyError when calling is_rebooting() or get_device_name() for devices that failed model validation. Co-Authored-By: Claude Opus 4.5 --- src/amcrest2mqtt/mixins/refresh.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/amcrest2mqtt/mixins/refresh.py b/src/amcrest2mqtt/mixins/refresh.py index 5736acf..40bbaf1 100644 --- a/src/amcrest2mqtt/mixins/refresh.py +++ b/src/amcrest2mqtt/mixins/refresh.py @@ -30,7 +30,7 @@ class RefreshMixin: async def collect_all_device_events(self: Amcrest2Mqtt) -> None: tasks = [] - for device_id in self.amcrest_devices: + for device_id in self.devices: if self.is_rebooting(device_id): self.logger.debug(f"skipping collecting events for '{self.get_device_name(device_id)}', still rebooting") continue @@ -42,7 +42,7 @@ class RefreshMixin: async def collect_all_device_snapshots(self: Amcrest2Mqtt) -> None: tasks = [] - for device_id in self.amcrest_devices: + for device_id in self.devices: if self.is_rebooting(device_id): self.logger.debug(f"skipping snapshot for '{self.get_device_name(device_id)}', still rebooting") continue