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

KeyError on integration setup when custom area is set in Nest app #73

Open
blue-hound opened this issue Apr 25, 2022 · 7 comments
Open
Labels
bug Something isn't working

Comments

@blue-hound
Copy link

blue-hound commented Apr 25, 2022

The problem

I didn't run into any errors during the setup, but when it was complete, my Nest Protects weren't found. The logs showed the following for all the entities the integration tried to set up. The line numbers vary of course but it happens for binary_sensor, sensor, select, and switch.

This seemed to be corrected when I made the areas in the Nest app match the areas in Home Assistant. For example, I had my basement Nest Protect location set to 'Downstairs' but that location does not exist in Home Assistant, instead it is called 'Rec. Room'. Once I changed the name from 'Downstairs' to 'Dining Room' the Nest Protects were discovered immediately. I also removed the additional descriptions that appear in brackets, so I am not sure if that contributed as well.

Perhaps a solution would be to not to try and add the area automatically and let the user decide where they go. Seems the simplest way to go :-)

After the initial setup, I was able to change the location of Nest Protect back to 'Downstairs' and there were no issues. I manually changed the Nest Protect area in Home Assistant from 'Dining Room' to 'Rec Room'. All seems to be functioning well.

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

v0.3.3 & v0.3.4

What version of Home Assistant Core has the issue?

core-2022.4.7

Device / Model

Topaz-2.9, Topaz-2.33, Topaz-2.33 (Nest Protect 2nd Gens)

Diagnostics information

Working - config_entry-nest_protect-e07d1c46cc43a0e1eb6bcc5b2d3b406a.json.txt
Not Working - config_entry-nest_protect-7f217c93e3fce8d43ce4078eabe506eb.json.txt

Home Assistant log

Logs
2022-04-25 12:10:21 ERROR (MainThread) [homeassistant.components.select] Error while setting up nest_protect platform for select
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/nest_protect/select.py", line 60, in async_setup_entry
NestProtectSelect(device, description, data.areas, data.client)
File "/config/custom_components/nest_protect/entity.py", line 89, in __init__
super().__init__(bucket, description, areas, client)
File "/config/custom_components/nest_protect/entity.py", line 31, in __init__
self.area = areas[self.bucket.value["where_id"]]
KeyError: '00000000-0000-0000-bb70-aa3f78160280'

Additional information

The logging above is with debug on but nothing else useful was logged. I've included diagnostic data from before and after things started to work.

@blue-hound blue-hound added the bug Something isn't working label Apr 25, 2022
@operinko
Copy link

The way to go would be to gracefully fall back on an unset area if automatic assignment fails like this.

@blue-hound
Copy link
Author

That would work or do it like the other Nest integration or a combination. I just re-added my doorbell and thermostat as well and it asked what areas to put them in during the setup.

@iMicknl
Copy link
Owner

iMicknl commented Apr 28, 2022

Thanks for reporting! I will investigate why this is not working.

This seemed to be corrected when I made the areas in the Nest app match the areas in Home Assistant.

This should not be necessary. We only 'suggest' the areas, thus it will create new areas in Home Assistant if they are not present yet. This is default behavior of Home Assistant.

@blue-hound
Copy link
Author

When you say you only suggest areas, how is the suggestion made? I didn't get any suggestions. The integration for the other Nest products asked me where my doorbell and thermostat was located for example.

I didn't get that prompt from the Protect integration though. I picked the integration from the list and authenticated. It appeared in my integrations with no devices/entities associated with it and the mentioned errors in the logs.

I'm not sure how the keys are generated and compared so it's hard for me to help you troubleshoot. How does that work?

@iMicknl
Copy link
Owner

iMicknl commented Apr 29, 2022

image

They are assigned by default; above a screenshot of my development environment where I didn't create any areas myself yet. It looks like a mismatch between the where_id of your device and the available ids in the 'all Google areas query'.

How did you create your own custom areas in the Nest app? I will have a look if I can reproduce this, since I found the issue, but I am not sure why you have an area id that is not present in the area list.

@iMicknl iMicknl changed the title KeyError on integration setup when area doesn't match KeyError on integration setup when custom area is set in Nest app Apr 29, 2022
@iMicknl
Copy link
Owner

iMicknl commented Jun 15, 2022

@blue-hound any update? Otherwise I will close this issue, since I cannot reproduce.

@blue-hound
Copy link
Author

Sorry, I got busy. I will investigate some more on the next few days, I seemed to have missed your update back in April.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants