From 97b12d35a030b1c7459433682dfa118d62f35f28 Mon Sep 17 00:00:00 2001 From: GSzabados <35445496+GSzabados@users.noreply.github.com> Date: Tue, 26 Nov 2024 14:36:14 +0100 Subject: [PATCH] Trying to fix Errors in _async_subscribe_for_data #347 This would fix the issue with objects and then wraps it with Bucket as expected by the pynest client, but if it is still generating high traffic on Google servers, then there is a flaw somewhere in the main logic of subscription process, and it re-subscribes again and again with the pynest client, which I cannot really test, as I have only battery powered nest protects, so there isn't live motion detection. --- custom_components/nest_protect/__init__.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/custom_components/nest_protect/__init__.py b/custom_components/nest_protect/__init__.py index 49cf68b..bfde016 100644 --- a/custom_components/nest_protect/__init__.py +++ b/custom_components/nest_protect/__init__.py @@ -205,10 +205,19 @@ async def _async_subscribe_for_data( LOGGER.debug(buckets) objects = [ - dict(b, **buckets.get(b.object_key, {})) for b in [data.updated_buckets] + dict(vars(b), **buckets.get(b.object_key, {})) for b in data.updated_buckets ] - data.updated_buckets = objects + data.updated_buckets = [ + Bucket( + object_key=bucket["object_key"], + object_revision=bucket["object_revision"], + object_timestamp=bucket["object_timestamp"], + value=bucket["value"], + type=bucket["type"] + ) + for bucket in objects + ] _register_subscribe_task(hass, entry, data) except ServerDisconnectedError: