home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.93k stars 30.15k forks source link

Google API returns 400 error with Nest thermostat #123123

Closed dredjohn21 closed 2 months ago

dredjohn21 commented 2 months ago

The problem

I have a script that sets my Nest Learning Thermostat to Eco mode when we all leave house. It has been working fine until 3 days ago when I started getting 400 errors. Nothing changed with script… but I did upgrade my HAOS software?

logger:%20homeassistant.components.script.set_thermostats_to_eco_mode%0ASource%3A%20helpers/script.py:2002%0Aintegration:%20Script%20(documentation,%20issues)%0AFirst%20occurred:%2011:48:33%20AM%20(5%20occurrences)%0ALast%20logged:%205:40:51%20PM%0A%0ASet%20Thermostats%20to%20Eco%20Mode:%20Error%20executing%20script.%20Error%20for%20device%20at%20pos%201:%20Error%20setting%20climate.basement_thermostat%20preset%20mode%20to%20eco:%20Error%20from%20API:%20400:%20FAILED_PRECONDITION:%20sdm.devices.commands.ThermostatEco.SetMode%20command%20not%20allowed%20in%20current%20thermostat%20mode.:%20Bad%20Request

What version of Home Assistant Core has the issue?

2024.7.4

What was the last working version of Home Assistant Core?

2024.7.2

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Google Nest

Link to integration documentation on our website

https://www.home-assistant.io/integrations/nest/

Diagnostics information

No response

Example YAML snippet

sequence:%0A%20%20-%20device_id%3A%205b91d76e29449228b0238b54215a6df5%0A%20%20%20%20domain%3A%20climate%0A%20%20%20%20entity_id%3A%20climate.basement_thermostat%0A%20%20%20%20type%3A%20set_preset_mode%0A%20%20%20%20preset_mode%3A%20eco%0A%20%20-%20device_id%3A%20c0b787645a735917cf8f6a0957e34f40%0A%20%20%20%20domain%3A%20climate%0A%20%20%20%20entity_id%3A%20climate.living_room_thermostat%0A%20%20%20%20type%3A%20set_preset_mode%0A%20%20%20%20preset_mode%3A%20eco%0A%20%20-%20service%3A%20climate.turn_off%0A%20%20%20%20data%3A%20%7B%7D%0A%20%20%20%20target%3A%0A%20%20%20%20%20%20entity_id%3A%20climate.mysa_cda094%0Amode%3A%20single%0Aalias%3A%20Set%20Thermostats%20to%20Eco%20Mode%0A

Anything in the logs that might be useful for us?

logger:%20homeassistant.components.websocket_api.http.connection%0ASource%3A%20components/websocket_api/commands.py:241%0Aintegration:%20Home%20Assistant%20WebSocket%20API%20(documentation,%20issues)%0AFirst%20occurred:%201:01:41%20PM%20(3%20occurrences)%0ALast%20logged:%205:40:51%20PM%0A%0A%5B546689866128%5D%20Unexpected%20exception%0A%5B546852006368%5D%20Unexpected%20exception%0A%5B546855281584%5D%20Unexpected%20exception%0ATraceback%20(most%20recent%20call%20last):%0A%20%20File%20%22/usr/local/lib/python3.12/site-packages/google_nest_sdm/auth.py%22,%20line%20140,%20in%20_raise_for_status%0A%20%20%20%20resp.raise_for_status()%0A%20%20File%20%22/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py%22,%20line%201070,%20in%20raise_for_status%0A%20%20%20%20raise%20ClientResponseError(%0Aaiohttp.client_exceptions.ClientResponseError:%20400,%20message='Bad%20Request',%20url=URL('https://smartdevicemanagement.googleapis.com/v1/enterprises/2cc67f31-bf6b-4615-b53b-e224d4925d3c/devices/AVPHwEt4wkRI3fFSnQ_obB3s_ynN13z9WnAuNkd4a7hcvrF5NjuxKZz53gDBPVwaZI148U-VhVl_xRrzjn1JWeExrVj1lus:executeCommand')%0A%0AThe%20above%20exception%20was%20the%20direct%20cause%20of%20the%20following%20exception:%0A%0ATraceback%20(most%20recent%20call%20last):%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/components/nest/climate.py%22,%20line%20321,%20in%20async_set_preset_mode%0A%20%20%20%20await%20trait.set_mode(PRESET_INV_MODE_MAP%5Bpreset_mode%5D)%0A%20%20File%20%22/usr/local/lib/python3.12/site-packages/google_nest_sdm/thermostat_traits.py%22,%20line%2055,%20in%20set_mode%0A%20%20%20%20return%20await%20self.cmd.execute(data)%0A%20%20%20%20%20%20%20%20%20%20%20%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%0A%20%20File%20%22/usr/local/lib/python3.12/site-packages/google_nest_sdm/traits.py%22,%20line%2055,%20in%20execute%0A%20%20%20%20return%20await%20self._auth.post(f%22%7Bself._device_id%7D:executeCommand%22,%20json=data)%0A%20%20%20%20%20%20%20%20%20%20%20%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%0A%20%20File%20%22/usr/local/lib/python3.12/site-packages/google_nest_sdm/auth.py%22,%20line%20121,%20in%20post%0A%20%20%20%20return%20await%20AbstractAuth._raise_for_status(resp)%0A%20%20%20%20%20%20%20%20%20%20%20%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%0A%20%20File%20%22/usr/local/lib/python3.12/site-packages/google_nest_sdm/auth.py%22,%20line%20145,%20in%20_raise_for_status%0A%20%20%20%20raise%20ApiException(%22:%20%22.join(detail))%20from%20err%0Agoogle_nest_sdm.exceptions.ApiException:%20Error%20from%20API:%20400:%20FAILED_PRECONDITION:%20sdm.devices.commands.ThermostatEco.SetMode%20command%20not%20allowed%20in%20current%20thermostat%20mode.:%20Bad%20Request%0A%0AThe%20above%20exception%20was%20the%20direct%20cause%20of%20the%20following%20exception:%0A%0ATraceback%20(most%20recent%20call%20last):%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py%22,%20line%20241,%20in%20handle_call_service%0A%20%20%20%20response%20=%20await%20hass.services.async_call(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/core.py%22,%20line%202731,%20in%20async_call%0A%20%20%20%20response_data%20=%20await%20coro%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/core.py%22,%20line%202774,%20in%20_execute_service%0A%20%20%20%20return%20await%20target(service_call)%0A%20%20%20%20%20%20%20%20%20%20%20%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/components/script/__init__.py%22,%20line%20663,%20in%20_service_handler%0A%20%20%20%20response%20=%20await%20self._async_start_run(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/components/script/__init__.py%22,%20line%20621,%20in%20_async_start_run%0A%20%20%20%20script_result%20=%20await%20coro%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/components/script/__init__.py%22,%20line%20652,%20in%20_async_run%0A%20%20%20%20return%20await%20self.script.async_run(script_vars,%20context)%0A%20%20%20%20%20%20%20%20%20%20%20%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/helpers/script.py%22,%20line%201770,%20in%20async_run%0A%20%20%20%20return%20await%20asyncio.shield(create_eager_task(run.async_run()))%0A%20%20%20%20%20%20%20%20%20%20%20%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/helpers/script.py%22,%20line%20465,%20in%20async_run%0A%20%20%20%20await%20self._async_step(log_exceptions=False)%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/helpers/script.py%22,%20line%20529,%20in%20_async_step%0A%20%20%20%20self._handle_exception(%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/helpers/script.py%22,%20line%20559,%20in%20_handle_exception%0A%20%20%20%20raise%20exception%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/helpers/script.py%22,%20line%20527,%20in%20_async_step%0A%20%20%20%20await%20getattr(self,%20handler)()%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/helpers/script.py%22,%20line%20781,%20in%20_async_device_step%0A%20%20%20%20await%20device_action.async_call_action_from_config(%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/components/device_automation/action.py%22,%20line%2072,%20in%20async_call_action_from_config%0A%20%20%20%20await%20platform.async_call_action_from_config(hass,%20config,%20variables,%20context)%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/components/climate/device_action.py%22,%20line%2098,%20in%20async_call_action_from_config%0A%20%20%20%20await%20hass.services.async_call(%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/core.py%22,%20line%202731,%20in%20async_call%0A%20%20%20%20response_data%20=%20await%20coro%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/core.py%22,%20line%202774,%20in%20_execute_service%0A%20%20%20%20return%20await%20target(service_call)%0A%20%20%20%20%20%20%20%20%20%20%20%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/helpers/service.py%22,%20line%20999,%20in%20entity_service_call%0A%20%20%20%20single_response%20=%20await%20_handle_entity_call(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/helpers/service.py%22,%20line%201071,%20in%20_handle_entity_call%0A%20%20%20%20result%20=%20await%20task%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/components/climate/__init__.py%22,%20line%20776,%20in%20async_handle_set_preset_mode_service%0A%20%20%20%20await%20self.async_set_preset_mode(preset_mode)%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/components/nest/climate.py%22,%20line%20323,%20in%20async_set_preset_mode%0A%20%20%20%20raise%20HomeAssistantError(%0Ahomeassistant.exceptions.HomeAssistantError:%20Error%20setting%20climate.basement_thermostat%20preset%20mode%20to%20eco:%20Error%20from%20API:%20400:%20FAILED_PRECONDITION:%20sdm.devices.commands.ThermostatEco.SetMode%20command%20not%20allowed%20in%20current%20thermostat%20mode.:%20Bad%20Request%0A

Additional information

No response

home-assistant[bot] commented 2 months ago

Hey there @allenporter, mind taking a look at this issue as it has been labeled with an integration (nest) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `nest` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign nest` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


nest documentation nest source (message by IssueLinks)

allenporter commented 2 months ago

The server is returning an API because it cant set the mode when the thermostat is in the specified state. Perhaps the nest behavior changed.

However you are pasting the output into the issue is pretty unreadable so hard to tell what the log says. But with this, not sure we can do much.

dredjohn21 commented 2 months ago

Sorry was pasting from my phone

Do you know if there is any way for me to check if the Nest behavior changed or if there is someway to still push my device into ECO mode?

dredjohn21 commented 2 months ago

Confirmed documentation was updated and error is triggered when thermostat is already set to OFF. It turned out it wasn’t my Living Room thermostat that was triggering it but my basement which was turned off at the time the script was run.

https://developers.google.com/nest/device-access/traits/device/thermostat-mode

“ The thermostat mode must be changed to HEAT, COOL, or HEATCOOL prior to changing the Eco mode.”