Integrating Nest Protect smoke alarms

I’ve asked the same question in the Github community too.

Really hope there is a way to get this working as I want to link it to my desk lamp so when the smoke alarm goes off, my desk lamp flashes to alert me as I am deaf.

2 Likes

Worked first time, thank you for this :+1:

No issueToken available when following the docs, and no Cookie available when using incognito mode (although it is available when not using incognito mode). I like a a challenge and am not uncomfortable using the console. But only if it matches the documentation. Which, in this case, just isn’t.

I was unable to make this work. Issue authorising to get the token. Is there a way to resolve this?

Thanks

Excellent thanks for the work on this - it seems to be working OK so far :slight_smile:

What was the issue - did you follow the setup guide exactly? Did you get an error or was something missing? You need to provide more info…

Apologies

When adding the integration, I click this link

Ok here

image

Click Submit here

image

I click “Authorize Your Account”

image

and I get this message

I’m familair with providing some access to Google Projects etc - I have my 5 Google Camera (doorbell etc) working correctly directly in HA and went through the set up for that ok.

Thanks for any support anyone can give.

That’s a google/nest thing though isn’t it? You login separately through a browser.

Correct, it opens up in a browser. I’m not sure exactly how it works but the link appears to embed somehow and try to connect to my Google account for permission.

Perhaps the method used by this HA setup is out of date or superceded by a newer process Google now requires for this type of thing?

I didn’t have that. Are you sure you’re using the beta version?

Is this integration working or does it disconnect all the time. I haven’t try it for some time but want to reactivate it… But if there still some issues then I leave it for now

Hi. My issue was that I was able to download the old version without any issue but the “show beta options” tick-box was missing.

The trick is to go into HACS, find the Nest Protect add-on and then click the three dots to the right and click on “Redownload”. The resulting dialog box has the option to select the beta versions. At time of writing, the latest beta version is 0.4.0b4.

Link to relevant HACS documentation - Enable beta for a repository | HACS

Once you’ve got the correct version installed, collecting the token (by following the instructions at the top) should be straightforward.

Tony - love your creative idea to solve an interesting problem. Hope this helps!

I got many errors. But its still working


2024-05-26 04:02:48.594 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 298, in subscribe_for_data
    result = await response.json()
             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/aiohttp_client.py", line 74, in json
    return await super().json(*args, loads=loads, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1176, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/plain', url=URL('https://czfe135-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 168, in _async_subscribe_for_data
    result = await entry_data.client.subscribe_for_data(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/nest_protect/pynest/client.py", line 302, in subscribe_for_data
    raise PynestException(
custom_components.nest_protect.pynest.exceptions.PynestException: 200 error while subscribing - 
2024-05-26 04:26:21.896 ERROR (Recorder) [homeassistant] Error doing job: Task was destroyed but it is pending!
2024-05-26 05:23:22.294 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 298, in subscribe_for_data
    result = await response.json()
             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/aiohttp_client.py", line 74, in json
    return await super().json(*args, loads=loads, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1176, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/plain', url=URL('https://czfe135-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 168, in _async_subscribe_for_data
    result = await entry_data.client.subscribe_for_data(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/nest_protect/pynest/client.py", line 302, in subscribe_for_data
    raise PynestException(
custom_components.nest_protect.pynest.exceptions.PynestException: 200 error while subscribing - 
2024-05-26 06:24:25.675 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 298, in subscribe_for_data
    result = await response.json()
             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/aiohttp_client.py", line 74, in json
    return await super().json(*args, loads=loads, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1176, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/plain', url=URL('https://czfe135-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 168, in _async_subscribe_for_data
    result = await entry_data.client.subscribe_for_data(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/nest_protect/pynest/client.py", line 302, in subscribe_for_data
    raise PynestException(
custom_components.nest_protect.pynest.exceptions.PynestException: 200 error while subscribing - 
2024-05-26 07:25:28.586 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 298, in subscribe_for_data
    result = await response.json()
             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/aiohttp_client.py", line 74, in json
    return await super().json(*args, loads=loads, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1176, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/plain', url=URL('https://czfe135-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 168, in _async_subscribe_for_data
    result = await entry_data.client.subscribe_for_data(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/nest_protect/pynest/client.py", line 302, in subscribe_for_data
    raise PynestException(
custom_components.nest_protect.pynest.exceptions.PynestException: 200 error while subscribing - 
2024-05-26 08:26:13.240 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 258, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 414, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in async_update_listeners
    update_callback()
  File "/config/custom_components/moonraker/sensor.py", line 682, in _handle_coordinator_update
    self._attr_native_value = self.entity_description.value_fn(self)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/moonraker/sensor.py", line 40, in <lambda>
    value_fn=lambda sensor: sensor.coordinator.data["printer.info"]["state"],
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
KeyError: 'state'
2024-05-26 08:26:31.525 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 298, in subscribe_for_data
    result = await response.json()
             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/aiohttp_client.py", line 74, in json
    return await super().json(*args, loads=loads, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1176, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/plain', url=URL('https://czfe135-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 168, in _async_subscribe_for_data
    result = await entry_data.client.subscribe_for_data(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/nest_protect/pynest/client.py", line 302, in subscribe_for_data
    raise PynestException(
custom_components.nest_protect.pynest.exceptions.PynestException: 200 error while subscribing -

@Steve12345 you need to install the beta version, the current stable version doesn’t work for new logins anymore.

Merging both versions is long over-due as everyone notices. I haven’t had much time lately to work on this and someone else contributed the initial cookie method integration. There are still many open issues with the cookie method integration and merging it might break existing users (on old login flow) their component.

I have been working on this a few months ago, but it is a lot more work than expected unfortunately, so until someone else is willing to co-contribute, for now you will need to install the beta version and it will be less polished with error messages visible.

1 Like

Just installed my first Nest smoke detectors and indeed, the current beta version works with the cookie instructions mentioned earlier.

Lets hope you can find time to merge this functionality to the PROD version :slight_smile:

It took a few attempts, but the beta version is now installed. However, it’s not finding any of my nest thermostats or temp sensors. The ‘regular’ Nest integration finds the thermostats right away. I can’t figure out what I may be doing wrong.

Was able to use the Beta 0.4.0b4 and it found all my devices. Then early this week stopped working and are in an Unavailable Status. I see the message Failed setup, will retry: USER_LOGGED_OUT

Installed 3 Protects yesterday and this integration on the beta version worked first time! Excellent work!

I’m sharing the credentials from Badnest, which I need for my thermostat to control hot water.

In case this helps anyone, I had to do this using Firefox because trying to log into Nest with Chrome gave me a login loop which kept cycling me back to the “Sign in with Google” screen at Nest.

In Firefox, when you copy the issueToken URL out of DevTools, there may be spaces in it. In the example at the top of this thread you can see the spaces are shown as “%20” (the URL encoding for a space character). So you have to find/replace all spaces with “%20” (without the quotes). I had to replace 4 spaces in my issueToken.

ETA: the reason I had to do this was I was getting invalid authorization errors at the Options screen.

1 Like

You need to enable 3rd party cookies to solve this in Chrome/Edge.