iMicknl / ha-nest-protect

Nest Protect integration for Home Assistant. This will allow you to integrate your smoke, heat, co and occupancy status real-time in HA.
MIT License
338 stars 64 forks source link

Unknown Exception - 'list' object has no attribute 'object_key' #338

Open Matsuo3rd opened 4 months ago

Matsuo3rd commented 4 months ago

The problem

Under v0.4.0b5 / HA 2024.6.3, every 5 minutes, the following error pops:

2024-06-17 19:21:10.772 ERROR (MainThread) [custom_components.nest_protect] Unknown exception. Please create an issue on GitHub with your logfile. Updates paused for 5 minutes. Traceback (most recent call last): File "/home/homeassistant/.homeassistant/custom_components/nest_protect/init.py", line 208, in _async_subscribe_for_data dict(b, buckets.get(b.object_key, {})) for b in [data.updated_buckets] ^^^^^^^^^^^^ AttributeError: 'list' object has no attribute 'object_key' 2024-06-17 19:26:11.491 ERROR (MainThread) [custom_components.nest_protect] Unknown exception. Please create an issue on GitHub with your logfile. Updates paused for 5 minutes. Traceback (most recent call last): File "/home/homeassistant/.homeassistant/custom_components/nest_protect/init.py", line 208, in _async_subscribe_for_data dict(b, buckets.get(b.object_key, {})) for b in [data.updated_buckets] ^^^^^^^^^^^^ AttributeError: 'list' object has no attribute 'object_key' 2024-06-17 19:31:12.226 ERROR (MainThread) [custom_components.nest_protect] Unknown exception. Please create an issue on GitHub with your logfile. Updates paused for 5 minutes. Traceback (most recent call last): File "/home/homeassistant/.homeassistant/custom_components/nest_protect/init.py", line 208, in _async_subscribe_for_data dict(b, **buckets.get(b.object_key, {})) for b in [data.updated_buckets] ^^^^^^^^^^^^ AttributeError: 'list' object has no attribute 'object_key'

What version of this integration (ha-nest-protect) has the issue?

0.4.0b5

What version of Home Assistant Core has the issue?

2024.6.3

Device / Model

No response

Diagnostics information

No response

Home Assistant log

Logs ``` 2024-06-17 19:21:10.772 ERROR (MainThread) [custom_components.nest_protect] Unknown exception. Please create an issue on GitHub with your logfile. Updates paused for 5 minutes. Traceback (most recent call last): File "/home/homeassistant/.homeassistant/custom_components/nest_protect/__init__.py", line 208, in _async_subscribe_for_data dict(b, **buckets.get(b.object_key, {})) for b in [data.updated_buckets] ^^^^^^^^^^^^ AttributeError: 'list' object has no attribute 'object_key' 2024-06-17 19:26:11.491 ERROR (MainThread) [custom_components.nest_protect] Unknown exception. Please create an issue on GitHub with your logfile. Updates paused for 5 minutes. Traceback (most recent call last): File "/home/homeassistant/.homeassistant/custom_components/nest_protect/__init__.py", line 208, in _async_subscribe_for_data dict(b, **buckets.get(b.object_key, {})) for b in [data.updated_buckets] ^^^^^^^^^^^^ AttributeError: 'list' object has no attribute 'object_key' 2024-06-17 19:31:12.226 ERROR (MainThread) [custom_components.nest_protect] Unknown exception. Please create an issue on GitHub with your logfile. Updates paused for 5 minutes. Traceback (most recent call last): File "/home/homeassistant/.homeassistant/custom_components/nest_protect/__init__.py", line 208, in _async_subscribe_for_data dict(b, **buckets.get(b.object_key, {})) for b in [data.updated_buckets] ^^^^^^^^^^^^ AttributeError: 'list' object has no attribute 'object_key' ```

Additional information

No response

styphonthal commented 4 months ago

I have similar error: 2024-06-17 16:41:37.516 ERROR (MainThread) [custom_components.nest_protect] Unknown exception. Please create an issue on GitHub with your logfile. Updates paused for 5 minutes. Traceback (most recent call last): File "/config/custom_components/nest_protect/init.py", line 208, in _async_subscribe_for_data dict(b, **buckets.get(b.object_key, {})) for b in [data.updated_buckets] ^^^^^^^^^^^^ AttributeError: 'list' object has no attribute 'object_key'

iMicknl commented 4 months ago

Thanks both! I indeed can reproduce this, but haven't been able to figure out yet what is going wrong exactly.

B-double-U commented 4 months ago

FYI:

Same here. Just sharing in case this might help.

This error originated from a custom integration.

Logger: custom_components.nest_protect Source: custom_components/nest_protect/init.py:208 integration: Nest Protect (documentation, issues) First occurred: June 17, 2024 at 10:53:26 (2240 occurrences) Last logged: 11:42:57

Unknown exception. Please create an issue on GitHub with your logfile. Updates paused for 5 minutes. Traceback (most recent call last): File "/config/custom_components/nest_protect/init.py", line 208, in _async_subscribe_for_data dict(b, **buckets.get(b.object_key, {})) for b in [data.updated_buckets] ^^^^^^^^^^^^ AttributeError: 'list' object has no attribute 'object_key'

meanaverage commented 4 months ago

Disregard this message, thought GPT4o fixed, did not...

Also, I am having this issue. 😢

2nd edit: I think it's fixed. Will report back if changes work in about 10 minutes.

Nope. nevermind, i'm only as good as AI and it's not that good.

iMicknl commented 4 months ago

This is a known issue. Hopefully I can have a look soon to fix this. No need to reply with 'same issue', feel free to do a thumbs up on original post if you face the same issue.

iSteve-O commented 2 months ago

This issue resolves itself on my system every time after a reboot, but always requires a full reboot of home assistant. The error that pauses updates for 1 minute seems to correct itself and doesn't require a restart to begin to function again.

I made an automation that restarts HA when the "updates paused for 5 minutes" text appears in the log and this is working for now but is not a viable solution long term. It would be a lot less destructive if I could simply reload the integration but that doesn't resolve this error.

janusn commented 2 months ago

I encounter similar this bug.

Albeit errors are logged, the nest_protect devices continue to report status.

Matsuo3rd commented 1 month ago

Issue fixed once upgraded to latest beta (including https://github.com/iMicknl/ha-nest-protect/pull/355)

lordbah commented 1 month ago

Really? I didn't see any new release notes and couldn't even find any new commits when I looked yesterday.

Matsuo3rd commented 1 month ago

See https://github.com/iMicknl/ha-nest-protect/tree/beta (beta branch) You need to change HACS repo link to the beta one.

lordbah commented 4 weeks ago

What I mean by that is the HA Settings update looks like this: Screenshot from 2024-10-01 20-42-00 It's for v0.4.0b6 but that's the same "What's changed" text it's had for a couple of years and doesn't mention anything new, right? If that version has a potential fix for issues I would expect to see it there, to encourage people facing issues to install it. About the commits you are of course correct, when I change from "main" to "beta" on github I can see very recent commits. I can't find anywhere in HACS to change the URL of a repository. Do I have to Remove it and add it back again, selecting a different version? On the other hand, if it's already offering me v0.4.0b6 then maybe I don't need to change it.

iMicknl commented 3 weeks ago

Reopened this issue due to issues with the fix. Would be good to update as soon as possible to v0.4.0b7 (see release information).

lordbah commented 3 weeks ago

With v0.4.0b7:

2024-10-05 18:21:45.782 ERROR (MainThread) [custom_components.nest_protect] Unknown pynest exception. Please create an issue on GitHub with your logfile. Updates paused for 1 minute.
Traceback (most recent call last):
  File "/config/custom_components/nest_protect/pynest/client.py", line 317, in subscribe_for_data
    result = await response.json()
             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/aiohttp_client.py", line 80, in json
    return await super().json(*args, loads=loads, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1199, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 200, message='Attempt to decode JSON with unexpected mimetype: text/plain', url='https://czfe50-front01-iad01.transport.home.nest.com/v6/subscribe'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/nest_protect/__init__.py", line 169, in _async_subscribe_for_data
    result = await entry_data.client.subscribe_for_data(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/nest_protect/pynest/client.py", line 321, in subscribe_for_data
    raise PynestException(
custom_components.nest_protect.pynest.exceptions.PynestException: 200 error while subscribing -
Maarc commented 2 weeks ago

Hi there,

I have similar issues with v0.4.0b7 on Home Assistant Core 2024.10.1 / Supervisor 2024.10.0 / OS 13.1 / Frontend 20241002.2.

Every 5 minutes, I get the following error in my home assistant log file:

2024-10-10 15:35:27.004 ERROR (MainThread) [custom_components.nest_protect] Unknown exception. Please create an issue on GitHub with your logfile. Updates paused for 5 minutes.
Traceback (most recent call last):
  File "/config/custom_components/nest_protect/__init__.py", line 208, in _async_subscribe_for_data
    dict(b, **buckets.get(b.object_key, {})) for b in [data.updated_buckets]
                          ^^^^^^^^^^^^

I hope this helps.

puterboy commented 2 weeks ago

I also have this issue running v0.4.0b7 Is there any solution in sight?

iMicknl commented 2 weeks ago

@puterboy I don't have time to fix this, however it is only a warning and shouldn't influence the working of the integration. Happy to accept any (tested) PRs.

ScottESanDiego commented 2 weeks ago

Isn't that the same root cause as #364 and the like (delayed presence notifications)?

iMicknl commented 2 weeks ago

@ScottESanDiego not sure if I understand your question? The revert in #364 was because this contributed fix did cause side effects and hit the Nest servers massively.

genehand commented 2 weeks ago

The HA error message says "Updates paused for 5 minutes". I confirmed that my HA occupancy sensor doesn't trigger for up to a few minutes while homebridge-nest picks it up almost immediately.

ScottESanDiego commented 1 week ago

@ScottESanDiego not sure if I understand your question? The revert in #364 was because this contributed fix did cause side effects and hit the Nest servers massively.

I was replying to your ( @iMicknl ) statement above of "owever it is only a warning and shouldn't influence the working of the integration.". I don't believe that is true - it's an error and changes the working of the integration at least insomuch as notifications are delayed.

I agree, the fix to #364 wasn't a good fix and you were right to revert it, just think the issue in this bug is the same root case and impact as the other bugs (like #364 ).

Mark612 commented 6 days ago

2024-10-23 14:27:17.710 ERROR (MainThread) [custom_components.nest_protect] Unknown exception. Please create an issue on GitHub with your logfile. Updates paused for 5 minutes. Traceback (most recent call last): File "/config/custom_components/nest_protect/init.py", line 208, in _async_subscribe_for_data dict(b, **buckets.get(b.object_key, {})) for b in [data.updated_buckets] ^^^^^^^^^^^^ AttributeError: 'list' object has no attribute 'object_key'