Nest Thermostat Turns off After Calling Service in AD

I have a Nest thermostat integrated into HA. I use AppDaemon to adjust the thermostat during the day, when we’re out of the house, at night, etc. The call is:

self.call_service(service, **proper_args)

Where proper_args is:

{'entity_id': 'climate.hallway', 'temperature': 69.0, 'hvac_mode': 'heat'}

The service call is: climate/set_temperature

This works most of the time, but every now and then the climate card in the UI shows the system is off the actual thermostat is still on. I looked in the logs and the output for the last 12 hours are:

Hallway changed to Heat triggered by service Climate: Set HVAC mode
9:47:28 AM - 14 minutes ago - kirby
Hallway turned off
9:00:14 AM - 1 hour ago
Hallway turned off
9:00:14 AM - 1 hour ago
Hallway changed to Heat triggered by service Climate: Set target temperature
5:06:04 AM - 5 hours ago - Supervisor
Hallway changed to Heat triggered by service Climate: Set target temperature
5:06:04 AM - 5 hours ago - Supervisor
December 19, 2023
Hallway turned off triggered by service Climate: Set target temperature
9:00:05 PM - 13 hours ago - Supervisor 

The first (latest) entry is when I used the UI card to turn the thermostat back on. The 2 entries at 09:00:14 are when the set_temperature service was called to adjust the thermostat. The next two entries at 5:06:04 are when ONE service call was also made. The UI card didn’t turn off.

And then, going back to last night at 9:00:05 pm, the scheduled service call turned off the UI card thermostat. But interestingly, it did set the thermostat properly (sets back to 64).

Does anyone notice anything similar?

1 Like

Yep, the Nest API sucks:

Most of the time mine seems to work, but for instance just this morning mine randomly went ‘off’ even though that’s not the case. In my case, it seems to be somewhat random (not just at setpoint changes, etc.)

Thanks for the quick response! I’ll stop trying to debug it. It didn’t used to do this, which is very frustrating - especially after I paid my 5 bucks! :wink:

Yeah, it didn’t seem to do it in the past for me either.

Some more info on this. I noticed in the logs on a trigger to adjust the thermostat that I received the following warning in the logs:

2024-01-03 09:00:10.706584 WARNING HASS: Error calling Home Assistant service default/climate/set_temperature
2024-01-03 09:00:10.707993 WARNING HASS: Code: 500, error: 500 Internal Server Error

Server got itself in trouble

I retriggered it, so it’s the same action, just triggered by an input_boolean, and it worked as expected (the thermostat adjusted, and the heat came on).

Then, in the logs, I noticed this:

  File "/usr/src/homeassistant/homeassistant/components/nest/climate.py", line 272, in async_set_hvac_mode
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Error setting climate.hallway HVAC mode to heat: Error from API: 500: INTERNAL: Internal error encountered.: Internal Server Error

which is the same as what shows up in the Appdaemon log. Down a little further in the HASS logs is this:

  File "/usr/src/homeassistant/homeassistant/components/nest/climate.py", line 307, in async_set_temperature
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Error setting climate.hallway temperature to {'entity_id': ['climate.hallway'], 'temperature': 21.11111111111111, 'hvac_mode': <HVACMode.HEAT: 'heat'>}: Error from API: 400: FAILED_PRECONDITION: sdm.devices.commands.ThermostatTemperatureSetpoint.SetHeat command not allowed in current thermostat mode.: Bad Request

The interesting words are sdm.devices.commands.ThermostatTemperatureSetpoint.SetHeat command not allowed in current thermostat mode.

So now I’m thinking that when we include the MODE in the service call, it seems to cycle through the OFF mode and then to HEAT mode. If it’s still in the OFF mode, then you can’t set the thermostat temperature setpoint. I have observed the thermostat turning off in the front end as it goes to the new setpoint.

Thoughts? In the meantime, I’m going to change my call so it doesn’t include the mode (I’m not expecting to have to change to COOL mode anytime soon) to see if that works better.

I have the same issue with it going to off frequently when only setting the temperature through automations.

I tried removing the setting of the mode in the service call but it didn’t help.

Yea, it didn’t do anything positive for me, either. I’ve now written an automation that watches for one of the following (I created sensors for the target_temp and target_mode):

  1. If the climate entity is unavailable then reload the integration
  2. If target_temp is different than the climate target temperature, then reload
  3. If target_mode is different than the climate state, then reload

This seems like overkill, but it works (so far).

I think mine has been solid lately. It was probably an issue on Google’s end that’s been fixed

The best thing I did recently was to throw my Nest in the thrash and replace it with a zigbee switch. I’m in Ireland so setup might be different, but honestly, never had a good experience with Nest. Imagine being throttled on setting your temperature level?! Best to be keep it all local imo.