Nest integration doesn't receive preset mode change from thermostat?

Hi all.

I’ve been trying to create an automation triggered when my Nest thermostat changes itself into “eco” mode. But upon doing some research I never see this being captured as a state change (I have 8mo of history in Influx to query) and I have seen myself where the thermostat shows “Eco” on it yet HA still reports the preset_mode as “none”. Anyone else able to receive this state change in HA reliably?

I do have a theory that the thermostat goes into a bit of a “sleep” mode upon changing to eco mode because I have the direct Alexa integration enabled and when it’s in Eco mode, Alexa says she can’t make any changes to the thermostat. Possibly related? I’m not sure.

Thanks for any help.

-Tom

There’s a similar discussion happening in another thread with @LearningHASlowly and @RogTP so curious if there is a problem with the apis not sending events. In the thread Google-Nest Offical Device Access Console Finally Released! - #1616 by RogTP

If you turn up debugging in configuration yaml you should be able to get more detailed logs about the events being received from the API:

logger:
  default: info
  logs:
    homeassistant.components.nest: debug
    google_nest_sdm.event: debug
    google_nest_sdm.event.device: debug

Typically this includes details about eco mode when things are working correctly.

if you can confirm you are receiving events then it would point out a home assistant bug. I may see one here. Also if you could comment on the home assistant versions you are running @RogTP and @LearningHASlowly maybe that is the difference

I’m running 2021.12.4 HA, Nest 3rd Gen UK. No air con, so no cool mode on it.

Bear in mind I don’t know what it shows when it switches automatically into eco, but I know it shows ‘eco’ when I manually change it. If you change it manually to eco, and it doesn’t change in HA then that make help with diagnosis.

One last comment, it won’t be a state change as such, it will be an attribute change on the preset_mode attribute.

Agreed. Attribute change, not a state change.

If I manually change it in HA, then:

  • It does indeed change to Eco at the Nest
  • It does record the attribute change in HA DB
  • And I can see it in Influx as well
  • In addition, my automation to trigger on such change does fire correctly.

Moreover, if I use the “Start Eco” button in the Nest App, all of the above are also true.

So, it seems that it’s only when the thermostat decides automatically to enable Eco mode that all the above are false. And this is consistent with my experience. I will happen to notice the thermostat went into Eco mode while I was away yet my automation never fired (to just validate if the event is captured, right now the automation just sends me a push notification).

Interestingly, this isn’t the easiest to test :slight_smile: Presumably, I need to leave debug on and leave the house for a while and hope Nest decides I’m not home in a timely fashion and auto-set Eco.

Thanks for the conversation on this!

Hi Allen - sorry for the delay

Here are my findings:

I’m using Home Assistant OS 7.0 with core-2021.12.7, and have both a Nest 2020 Thermostat and a Nest Learning Thermostat. [The results are slightly different]

My Nest 2020 Thermostat doesn’t reflect that it is in “Eco” mode when it’s automatically set based on lack of activity, but I noticed I can infer it based on the set temp being 56 degrees:

hvac_modes:
  - 'off'
  - heat
min_temp: 45
max_temp: 95
preset_modes:
  - none
  - eco
current_temperature: 68
temperature: 56
hvac_action: 'off'
preset_mode: none
friendly_name: Basement Thermostat
supported_features: 17

When I put the thermostat into “away” mode in the Google Home app, I see no change:

hvac_modes:
  - 'off'
  - heat
min_temp: 45
max_temp: 95
preset_modes:
  - none
  - eco
current_temperature: 68
temperature: 56
hvac_action: 'off'
preset_mode: none
friendly_name: Basement Thermostat
supported_features: 17

When I use the Google Home app to put the device into Eco mode manually, I also see no change:

hvac_modes:
  - 'off'
  - heat
min_temp: 45
max_temp: 95
preset_modes:
  - none
  - eco
current_temperature: 68
temperature: 56
hvac_action: 'off'
preset_mode: none
friendly_name: Basement Thermostat
supported_features: 17

When I put the thermostat back into Comfort mode, or it automatically switches out of Eco/Away, and th set temp goes back to 69:

hvac_modes:
  - 'off'
  - heat
min_temp: 45
max_temp: 95
preset_modes:
  - none
  - eco
current_temperature: 68
temperature: 69
hvac_action: 'off'
preset_mode: none
friendly_name: Basement Thermostat
supported_features: 17

This is what I see in the logs with the advanced logging you recommended at the time the device transitions between normal heat to “eco mode”, because it senses I’m away (I removed unique info):

2022-01-01 16:30:15 DEBUG (MainThread) [google_nest_sdm.event] EventMessage raw_data={'eventId': '**REMOVED**', 'timestamp': '2022-01-01T21:30:14.004412Z', 'resourceUpdate': {'name': 'enterprises/**REMOVED**/devices/**REMOVED**', 'traits': {'sdm.devices.traits.ThermostatHvac': {'status': 'OFF'}}}, 'userId': '**REMOVED**', 'resourceGroup': ['enterprises/**REMOVED**/devices/**REMOVED**']}
2022-01-01 16:30:18 DEBUG (MainThread) [google_nest_sdm.event] EventMessage raw_data={'eventId': '**REMOVED**', 'timestamp': '2022-01-01T21:30:17.584106Z', 'resourceUpdate': {'name': 'enterprises/**REMOVED**/devices/**REMOVED**', 'traits': {'sdm.devices.traits.ThermostatMode': {'mode': 'HEAT', 'availableModes': ['HEAT', 'OFF']}, 'sdm.devices.traits.ThermostatEco': {'availableModes': ['OFF', 'MANUAL_ECO'], 'mode': 'OFF', 'heatCelsius': 13.5, 'coolCelsius': 28.0}, 'sdm.devices.traits.ThermostatTemperatureSetpoint': {'heatCelsius': 13.5}}}, 'userId': '**REMOVED**', 'resourceGroup': ['enterprises/**REMOVED**/devices/**REMOVED**']}

It looks like the only thing that changes is the set temperature. However, in the Google Home/Nest app it shows the device is in Eco mode. For the other changes (manual/forced away/forced Eco) I also see no difference in the logs.

Now, with my Google Nest Learning Thermostat I have slightly different behavior. Here, the device DOES show it’s in Eco mode, but only if I set the Eco mode from the Google Nest app. If I use the Google Home app, or Away mode, or wait for auto mode, there is no change in the Eco value. But this is the way it shows if I do force Eco mode from the Google Nest app:

hvac_modes:
  - 'off'
  - heat_cool
  - heat
  - cool
  - fan_only
min_temp: 45
max_temp: 95
fan_modes:
  - 'on'
  - 'off'
preset_modes:
  - none
  - eco
current_temperature: 71
temperature: 62
target_temp_high: null
target_temp_low: null
fan_mode: 'off'
hvac_action: 'off'
preset_mode: eco
friendly_name: Living Room Thermostat
supported_features: 27

And in the logs, it reflects this eco mode as being manually set:

2022-01-01 17:38:14 DEBUG (MainThread) [google_nest_sdm.event] EventMessage raw_data={'eventId': '**REMOVED**', 'timestamp': '2022-01-01T22:38:13.320972Z', 'resourceUpdate': {'name': 'enterprises/**REMOVED**/devices/**REMOVED**', 'traits': {'sdm.devices.traits.ThermostatMode': {'mode': 'HEAT', 'availableModes': ['HEAT', 'COOL', 'HEATCOOL', 'OFF']}, 'sdm.devices.traits.ThermostatEco': {'availableModes': ['OFF', 'MANUAL_ECO'], 'mode': 'MANUAL_ECO', 'heatCelsius': 16.666672, 'coolCelsius': 24.444443}, 'sdm.devices.traits.ThermostatTemperatureSetpoint': {}}}, 'userId': '**REMOVED**', 'resourceGroup': ['enterprises/**REMOVED**/devices/**REMOVED**']}

If I observe the logs, the availableModes is always ‘OFF’ for the other states (Away, Auto-Eco).

This leads me to believe there is some difference in the way Google is reporting out activity for both the Nest 2020 thermostat and the Learning Thermostat. It also appears to be a limitation of the way Auto Eco and Away modes are handled in the logs. For some reason the Google Nest and Google Home apps are able to properly reflect this activity, but the API isn’t returning enough information to properly identify? So if I want to know if it’s set to Eco, I need to infer from the set temp, which is probably sufficient, but not as easy to program, if I ever tweak the temperature preference.

Unrelated, but may be of interest: I also noticed some errors in the more detailed logs

2022-01-01 14:45:21 INFO (Thread-6) [google.cloud.pubsub_v1.subscriber._protocol.streaming_pull_manager] Observed non-terminating stream error 503 The service was unable to fulfill your request. Please try again. [code=8a75]

2022-01-01 14:45:21 INFO (Thread-6) [google.cloud.pubsub_v1.subscriber._protocol.streaming_pull_manager] Observed recoverable stream error 503 The service was unable to fulfill your request. Please try again. [code=8a75]

2022-01-01 14:45:21 INFO (Thread-6) [google.api_core.bidi] Re-established stream

2022-01-01 14:45:21 INFO (Thread-ConsumeBidirectionalStream) [google.cloud.pubsub_v1.subscriber._protocol.streaming_pull_manager] Observed non-terminating stream error 503 The service was unable to fulfill your request. Please try again. [code=8a75]

2022-01-01 14:45:21 INFO (Thread-ConsumeBidirectionalStream) [google.cloud.pubsub_v1.subscriber._protocol.streaming_pull_manager] Observed recoverable stream error 503 The service was unable to fulfill your request. Please try again. [code=8a75]
1 Like

Thanks, so it looks like a limitation or bug in how messages are published. Thanks for all of that detail. I may be able to forward these on to a contact on the Nest API team to put in their queue to look at.

Those subscriber codes are normally as it reconnects the streaming RPC.

1 Like

Gotcha and thanks so much for the offer to forward on (hopefully it helps, if they weren’t aware)

Appreciate all your support and hope you’re having a nice new year

@allenporter

Any ideas on how to troubleshoot this issue? I created a scene to adjust my 3 thermostats when I return home (2 are nest devices) and when I got home I noticed one of my Nest devices didn’t adjust.

In the logs I found this error:

Turn Thermostats Back On (Someone Came Home): Error executing script. Unexpected error for scene at pos 1: Error from API: 500: INTERNAL: Internal error encountered.: Internal Server Error
While executing automation automation.turn_thermostats_back_on_someone_came_home
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/google_nest_sdm/auth.py", line 88, in _raise_for_status
    resp.raise_for_status()
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1004, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 500, message='Internal Server Error', url=URL('https://smartdevicemanagement.googleapis.com/v1/enterprises/**REMOVED**/devices/**REMOVED**:executeCommand')

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 381, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 603, in _async_scene_step
    await self._hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 209, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 663, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 896, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 700, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/homeassistant/scene.py", line 314, in async_activate
    await async_reproduce_state(
  File "/usr/src/homeassistant/homeassistant/helpers/state.py", line 116, in async_reproduce_state
    await asyncio.gather(
  File "/usr/src/homeassistant/homeassistant/helpers/state.py", line 110, in worker
    await platform.async_reproduce_states(  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/climate/reproduce_state.py", line 85, in async_reproduce_states
    await asyncio.gather(
  File "/usr/src/homeassistant/homeassistant/components/climate/reproduce_state.py", line 68, in _async_reproduce_states
    await call_service(SERVICE_SET_PRESET_MODE, [ATTR_PRESET_MODE])
  File "/usr/src/homeassistant/homeassistant/components/climate/reproduce_state.py", line 47, in call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 209, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 663, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 896, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 700, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/nest/climate_sdm.py", line 330, in async_set_preset_mode
    await trait.set_mode(PRESET_INV_MODE_MAP[preset_mode])
  File "/usr/local/lib/python3.9/site-packages/google_nest_sdm/thermostat_traits.py", line 59, in set_mode
    return await self._cmd.execute(data)
  File "/usr/local/lib/python3.9/site-packages/google_nest_sdm/traits.py", line 26, in execute
    return await self._auth.post(f"{self._device_id}:executeCommand", json=data)
  File "/usr/local/lib/python3.9/site-packages/google_nest_sdm/auth.py", line 81, in post
    return await AbstractAuth._raise_for_status(resp)
  File "/usr/local/lib/python3.9/site-packages/google_nest_sdm/auth.py", line 93, in _raise_for_status
    raise ApiException(": ".join(detail)) from err
google_nest_sdm.exceptions.ApiException: Error from API: 500: INTERNAL: Internal error encountered.: Internal Server Error

I used the Scene UI editor to add the devices and configure the temperature.

When I look at the Scenes.yaml file I see the following:

- id: '*REMOVED**'
  name: Turn Thermostats Back On
  entities:
    climate.basement_thermostat:
      hvac_modes:
      - 'off'
      - heat
      min_temp: 45
      max_temp: 95
      preset_modes:
      - none
      - eco
      current_temperature: 67
      temperature: 68
      hvac_action: heating
      preset_mode: none
      friendly_name: Basement Thermostat
      supported_features: 17
      state: heat
    climate.family_room_thermostat:
      hvac_modes:
      - 'off'
      - heat
      - cool
      - heat_cool
      min_temp: 41
      max_temp: 86
      current_temperature: 72
      temperature: 67
      current_humidity: 30
      hvac_action: idle
      friendly_name: Family Room Thermostat
      supported_features: 1
      state: heat
    climate.living_room_thermostat:
      hvac_modes:
      - cool
      - 'off'
      - heat
      - heat_cool
      - fan_only
      min_temp: 45
      max_temp: 95
      fan_modes:
      - 'on'
      - 'off'
      preset_modes:
      - none
      - eco
      current_temperature: 71
      temperature: 70
      target_temp_high:
      target_temp_low:
      fan_mode: 'off'
      hvac_action: 'off'
      preset_mode: none
      friendly_name: Living Room Thermostat
      supported_features: 27
      state: heat

Only the Living Room Thermostat failed, which is the Nest Learning Thermostat.

Thoughts on how I can troubleshoot this?

I don’t know much about scenes. Maybe one thing to watch out for is the API only seems to like setting certain thermostat modes or fields when it’s in the right mode. (For example, setting a temp range when it’s off might not work). I don’t have a good way to diagnose what the problem is but maybe by playing with individual settings manually you can reproduce it.

(May a scene is restoring properties in a unexpected order for the sdm API)

1 Like

Gotcha

My first time using scenes too (it seemed like the recommended way to perform repetitive actions)

In your own usage do you use automations with direct service calls to perform these activities? Maybe I’ll just switch to that if troubleshooting this error is challenging

Read up on alternative approaches and learned about “scripts”. Had to make a couple of calls to enable/disable eco mode separate from setting the temp, but got it all working.

For anyone looking to group thermostat actions: use scripts and save yourself some headaches :slight_smile:

1 Like

Just found this thread after running into some issues and I think this is related. HA appears to be unable to change hvac_mode from an automation. In this case, from heat_cool to heat. It’s also unable to set the intended temperature as well. I can change from the HA overview, but not from automation. Both the mode and temp settings are completely ignored if it’s setting a different mode than the current one. This has been baffling me for a bit. Wonder if there is an integration issue where it can’t set the temp AND the mode at the same time and integration just rejects it.

However, as I read the thread again, sounds like there is an issue just changing the mode altogether from an automation? I will look at scripts. Have not done those yet in HA.

Can you elaborate on the calls that aren’t working? Likely the call is different from whatever call the UI makes, and it may be a big or missing implementation.

In my examples above, that is copied straight from the HA interface when attempting to run the service call using the developer tools. The UI and YAML both show the hvac_mode can be modified using the climate.set_temperature service call.

Oh you’re https://github.com/home-assistant/core/issues/66852 yeah we’ll follow up there.

1 Like

Hello,

I fixed the problem for my nest thermostat more or less.
I installed the google assistant sdk and with the text command ‘set thermostat to eco’ it realy turns on the eco. It also shows eco in HA.
To activate normal operation: set HVAC mode to heat, or send text command ‘set thermostat to on’.

1 Like