Google-Nest Offical Device Access Console Finally Released!

I created a helper input_number.set_temperature and have added it to lovelace dashboard.
Then an automation triggered by it:

alias: Change Thermostat Temperature
description: ''
trigger:
  - platform: state
    entity_id: input_number.set_temperature
    for: '00:00:03'
condition: []
action:
  - service: system_log.write
    data:
      message: 'Temperature set to {{ trigger.to_state.state | float }}'
      level: info
      logger: automations/change_thermostat_temperature
  - service: climate.set_temperature
    data:
      temperature: '{{ trigger.to_state.state | float }}'
    entity_id: climate.inside_nest_thermostat
mode: single

but the service call to climate.set_temperature is generating an error that it can’t find the referenced entity:

2020-11-02 18:14:45 INFO (MainThread) [homeassistant.components.automation.change_thermostat_temperature] Change Thermostat Temperature: Running automation actions
2020-11-02 18:14:45 INFO (MainThread) [homeassistant.components.automation.change_thermostat_temperature] Change Thermostat Temperature: Executing step call service
2020-11-02 18:14:45 INFO (MainThread) [automations/change_thermostat_temperature] Temperature set to 21.5
2020-11-02 18:14:45 INFO (MainThread) [homeassistant.components.automation.change_thermostat_temperature] Change Thermostat Temperature: Executing step call service
2020-11-02 18:14:45 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities climate.inside_nest_thermostat

Calling the same sequence via Developer Tools works:
dev tool climate.set_temperature

Any ideas?

Hi. I’m having a little problem. I have AppDaemon running and connected to my Nest config. I have 3 thermostats, 2 are showing up fine. 1 is erroring out as follows:

2020-11-03 04:31:02.583921 WARNING nest: nest: Entity climate.theresa’s_room_nest_thermostat not found in namespace default
2020-11-03 04:31:02.584808 INFO AppDaemon: nest: Entity climate.theresa’s_room_nest_thermostat created in namespace: default
2020-11-03 04:31:02.611505 WARNING HASS: Error setting Home Assistant state default.climate.theresa’s_room_nest_thermostat, {‘state’: ‘on’, ‘attributes’: {‘friendly_name’: ‘Theresa’s Room Nest Thermostat’, ‘entity_id’: ‘climate.theresa’s_room_nest_thermostat’, ‘hvac_mode’: ‘heat’, ‘preset_mode’: ‘heat’, ‘hvac_modes’: [‘heat’, ‘cool’, ‘heat_cool’, ‘off’], ‘preset_modes’: [‘heat’, ‘cool’, ‘heat_cool’, ‘off’], ‘current_temperature’: 62.2, ‘current_humidty’: 51, ‘hvac_action’: ‘idle’, ‘supported_features’: 19, ‘temperature’: 60.1}}
2020-11-03 04:31:02.612562 WARNING HASS: Code: 500, error: 500 Internal Server Error
Server got itself in trouble
2020-11-03 04:31:02.614989 WARNING nest: nest: Entity sensor.theresa’s_room_nest_thermostat_temp not found in namespace default
2020-11-03 04:31:02.616069 INFO AppDaemon: nest: Entity sensor.theresa’s_room_nest_thermostat_temp created in namespace: default
2020-11-03 04:31:02.636389 WARNING HASS: Error setting Home Assistant state default.sensor.theresa’s_room_nest_thermostat_temp, {‘state’: 62.2, ‘attributes’: {‘device_class’: ‘temperature’, ‘friendly_name’: ‘Theresa’s Room Nest Thermostat Temperature’}}
2020-11-03 04:31:02.637869 WARNING HASS: Code: 500, error: 500 Internal Server Error
Server got itself in trouble
2020-11-03 04:31:02.641819 WARNING nest: nest: Entity switch.theresa’s_room_nest_thermostat_switch not found in namespace default
2020-11-03 04:31:02.651101 INFO AppDaemon: nest: Entity switch.theresa’s_room_nest_thermostat_switch created in namespace: default
2020-11-03 04:31:02.681280 WARNING HASS: Error setting Home Assistant state default.switch.theresa’s_room_nest_thermostat_switch, {‘state’: ‘on’, ‘attributes’: {‘friendly_name’: ‘Theresa’s Room Nest Thermostat Switch’}}
2020-11-03 04:31:02.682184 WARNING HASS: Code: 500, error: 500 Internal Server Error
Server got itself in trouble

Thanks for your assistance.

This is how I do it in one of my scripts.

    - service: climate.set_temperature
      data_template:
        entity_id: climate.upstairs_thermostat
        temperature: > 
          {{ states('input_number.climate_thermostat_normal_temperature') | float }}
        hvac_mode: heat

Daniel, the temp difference is due to the NEST interface in the app rounding to the nearest .5, but he API provide a reading out to 4 decimal places. I round it to 1 decimal place. You will notice when you turn the dial on your NEST that you get multiple clicks before the number changes, but he API is recording it more precisely. HOWEVER, this set in HASS only updates every 30 seconds, so if you are tinkering, you will need to wait 30 seconds between changes.

dinan5,

Pull the latest from GitHub. I suspect your issue is the presence of an apostrophe, “’”, in the name. As I said, I didn’t thoroughly and robustly error check. But I just added a bit to delete the apostrophe and proactively handle any hyphens in the entity id.

I am certain there are other characters I should look for, but again, this a temporary solution until the awesome developers at HASS get the fully baked solution.

I suspect that Google is looking at the demand analysis before doing more integrations, at least I would if I was in their shoes. So, the more people we have making regular calls to the API and the more registrations they get, the higher the chance that we get NEST Protect API published. At least, that is what I tell myself.

I dont know if this will help anyone, however I have documented the setup in a much easier way than the Google docs show:

Prerequisites - obtain external address and add the subdomain location /auth/external/callback, eg with Nabu Casa (NOTE - do not add a port to the address):
https://[xxx].ui.nabu.casa/auth/external/callback
For non Nabu Casa users (probably need to add your port number):
https://[your_external_url]/auth/external/callback

  1. Browse to https://console.nest.google.com/device-access/project-list
  2. Create a new project.
  3. Enter a project name.
  4. Click on Skip.
  5. Select Enable and Create Project.
  6. Make a note of the Project ID and Pub/Sub Topic ID (full id).
  7. Browse to https://developers.google.com/nest/device-access/get-started.
  8. Find the blue box titled ‘Enable the API and get an OAuth 2.0 Client ID’ and click the button.
  9. Create a new project - call it whatever you want.
  10. Click Next.
  11. Give it a Product name - this will show up on the autorisation screen.
  12. Click Next.
  13. Choose ‘Web Server’ from the drop down.
  14. URL to enter is the external from above, eg https://xxx.ui.nabu.casa/auth/external/callback
  15. Click Create.
  16. Make a note of Client ID and Client Secret.
  17. Browse back to https://console.nest.google.com/device-access/project-list
  18. Go into the project.
  19. At the end of the OAuth Client ID line click the 3 buttons and choose Edit.
  20. Enter the Client ID from step 16 and click Save.
  21. Browse to https://console.developers.google.com/apis/library/pubsub.googleapis.com
  22. In the drop down top left slect your project.
  23. Click on blue box with Enable.
    NEW INSTRUCTIONS AT THIS POINT - SEE BELOW!
  24. Go back to HA, File Editor, configuration.yaml.
  25. Add the following lines and corresponding codes and change to your values:
nest:
  client_id: xxx.apps.googleusercontent.com
  client_secret: xxx
  project_id: xxx-xxx-xxx-xxx-xxx
  subscriber_id:  %SEE POINT N BELOW%
  1. Save the changes.
  2. Reboot HA.
  3. When HA has rebooted, use the external address eg Nabu Casa address, not the local IP address.
  4. Go to Configuration.
  5. Go to Integrations.
  6. Add the Nest integration.
  7. Select your Google account.
  8. Tick all the options and click Next.
  9. Choose your account.
  10. A warning is displayed, click on Advanced and Go To the address.
  11. Allow each popup.
    Done!

ADDITIONAL UPDATE 13/11/2020:
In adidtion to the above, after reading updated release notes (found here) I have the following additional instructions, to perform between point 23 and 24 above:
A. Browse to Device Access Console here: https://console.nest.google.com/device-access.
B. Go into your project.
C. Make a note of the pub/sub topic (eg projects/sdm-prod/topics/enterprise-xxx-xxx-xxx-xxx-xxx).
D. Browse to Google Cloud Platform found here: https://console.cloud.google.com/cloudpubsub/subscription/list
E. Click on ‘Create Subscription’
F. In ‘Subscription ID’ field enter any value, eg ‘Nest’
G. Click the drop down title ‘Select a Cloud Pub/Sub topic’.
H. Click on ‘ENTER TOPIC MANUALLY’
I. Enter the full topic name from step C (eg projects/sdm-prod/topics/enterprise-xxx-xxx-xxx-xxx-xxx)).
J. Change ‘Message Retention’ to 1 hour rather than 7 days.
K. Click ‘Create’
L. Click into your new subscription.
M. Click the copy icon to the right of ‘Subscription name’, eg projects/nest-xxx/subscriptions/Nest
N. This value is the subscriber_id from configuration.yaml

@allenporter happy for you to include these instructions on the Gibhub page and HA Nest Integration page.

66 Likes

I’m okay with that. Any idea why my automation to change the temperature is failing?

Logger: homeassistant.helpers.service
Source: helpers/service.py:447
First occurred: 2:31:04 AM (1 occurrences)
Last logged: 2:31:04 AM

Unable to find referenced entities climate.inside_nest_thermostat
alias: Change Thermostat Temperature
description: ''
trigger:
  - platform: state
    entity_id: input_number.set_temperature
    for: '00:00:03'
condition: []
action:
  - service: system_log.write
    data:
      message: 'Temperature set to {{ trigger.to_state.state | float }}'
      level: info
      logger: automations/change_thermostat_temperature
  - service: climate.set_temperature
    data:
      temperature: '{{ trigger.to_state.state | float }}'
    entity_id: climate.inside_nest_thermostat
mode: single

2020-11-03 02:31:04 INFO (MainThread) [homeassistant.components.automation.change_thermostat_temperature] Change Thermostat Temperature: Running automation actions

2020-11-03 02:31:04 INFO (MainThread) [homeassistant.components.automation.change_thermostat_temperature] Change Thermostat Temperature: Executing step call service

2020-11-03 02:31:04 INFO (MainThread) [automations/change_thermostat_temperature] Temperature set to 21.0

2020-11-03 02:31:04 INFO (MainThread) [homeassistant.components.automation.change_thermostat_temperature] Change Thermostat Temperature: Executing step call service

2020-11-03 02:31:04 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities climate.inside_nest_thermostat

I will look at it later, have to head out. Might be related to the created entity being in the wrong domain? Not sure, will have to tinker when I get some time.

Presently, the entities go into the “default” domain. I know there are others, could be the culprit???

Hi, that’s what I suspected. First I changed the name of the the thermostat and for some reason it’s retaining the old name (in appdaemon not nest), I then replaced nest.py as you suggested and I still have the same issue.

Thanks again for your help.

Thanks. I put this into Dev Tools > Template…

domain:
 
{%- set unique_domains = states | map(attribute='domain') |list | unique | list -%}
{%- for domain in unique_domains -%}
- {{domain + "\n"}}
{%- endfor -%}

entities:
 
{%- for state in states -%}
- {{state.entity_id + "\n"}}
{%- endfor -%}

and it listed - climate.inside_nest_thermostat

I followed James T’s steps above and it ll went well (Thanks for that). But I only see 2 entities (Temp and Humidity defined as sensors). I was expecting the thermostat and my doorbell to also be defined. Do I need to define these myself in the configuration.yaml?

as of right now the HA integration only picks up the temp and humidity sensor. The remaining will come in later releases.

2 Likes

No doorbell either? That’s the only nest device I have.

Only thing stopping me from replacing all my Amcrest cameras is not having a Nest integration.

Not yet, but they are in the works.

This link will show the work going into future releases. Technically you could use it now

1 Like

Cool. Well, it’s all set up so once it’s ready I’ll give it a go. Thanks for the hard work.

thanks elliotledger - that resolved “some” of the issue!

So what happens now is that when I add the integration it seems to loop through the authorization process twice and then I get an error message:
“500 Internal Server Error
Server got itself in trouble”

Looking at log files I see this:

Logger: aiohttp.server
Source: helpers/config_entry_oauth2_flow.py:178
First occurred: November 2, 2020, 7:27:01 PM (11 occurrences)
Last logged: 5:53:18 PM

Error handling request
Traceback (most recent call last):
File “/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py”, line 418, in start
resp = await task
File “/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py”, line 458, in _handle
resp = await handler(request)
File “/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py”, line 119, in impl
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/request_context.py”, line 18, in request_context_middleware
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/ban.py”, line 72, in ban_middleware
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/auth.py”, line 127, in auth_middleware
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/view.py”, line 129, in handle
result = await result
File “/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py”, line 406, in get
await hass.config_entries.flow.async_configure(
File “/usr/src/homeassistant/homeassistant/data_entry_flow.py”, line 153, in async_configure
result = await self._async_handle_step(flow, cur_step[“step_id”], user_input)
File “/usr/src/homeassistant/homeassistant/data_entry_flow.py”, line 201, in _async_handle_step
result: Dict = await getattr(flow, method)(user_input)
File “/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py”, line 270, in async_step_creation
token = await self.flow_impl.async_resolve_external_data(self.external_data)
File “/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py”, line 149, in async_resolve_external_data
return await self._token_request(
File “/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py”, line 178, in _token_request
resp.raise_for_status()
File “/usr/local/lib/python3.8/site-packages/aiohttp/client_reqrep.py”, line 941, in raise_for_status
raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 401, message=‘Unauthorized’, url=URL(‘https://www.googleapis.com/oauth2/v4/token’)

Assuming that it has to do with the last line - “message=‘Unauthorized’, url=URL('https://www.googleapis.com/oauth2/v4/token

Any thoughts as to how to correct this?

mostlychris - thanks for the help on this. Another poster elliotledger got me most of the way there - it was to upgrade HA to latest version - that resolved the error message!

Wow. I didn’t even think of that. Glad you got it working. That’s what I get for assuming… :slightly_smiling_face: