Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to fix Errors in _async_subscribe_for_data #347 #374

Merged
merged 4 commits into from
Dec 17, 2024
Merged
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
13 changes: 11 additions & 2 deletions custom_components/nest_protect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,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:
Expand Down
7 changes: 6 additions & 1 deletion custom_components/nest_protect/pynest/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ def __post_init__(self):
# if self.type == BucketType.TOPAZ:
# self.value = TopazBucketValue(**self.value)
if self.type == BucketType.WHERE:
self.value = WhereBucketValue(**self.value)
if isinstance(self.value, WhereBucketValue):
# It's already the correct type, no need to reinitialize
pass
else:
# Convert dictionary to WhereBucketValue instance
self.value = WhereBucketValue(**self.value)


@dataclass
Expand Down
Loading