cancel
Showing results for 
Search instead for 
Did you mean: 

Control Nest Thermostat with Script Editor if temp exceeds a set limit

krroller
Community Member

Is it possible to create an automation routine with the new script editor to be able to change the temperature when the temperature exceeds a limit?

I used to have this functionality with the IFTTT and "Works with Nest" integration before Google pulled support for it.

As an example, if the Nest Thermostat is in Cool mode and the temperature drops below 73 degrees, then set the temperature to 74 degrees.  This works well for scenarios where someone might turn the thermostat too low.

A related automation routine would be when the Nest Thermostat is in Heat mode and temperature exceeds 76 degrees, reset the temperature to 72 degrees. 

Can this be done with the new script editor?

I realize the thermostat can be locked to limit the temperature to a pre-set range, but there are scenarios where a short term override by anyone is applicable without having to unlock the thermostat.

5 REPLIES 5

Prafulla
Googler
Googler

Hi @krroller - I wonder if the following examples can help with your use case:

krroller
Community Member

Thanks!  These examples helped find my errors which were a case sensitive "lessThan" where I had a capital L  which was throwing an error; and I also neglected to indicate the temperature scale as F or C.   

A couple of rookie mistakes.  ;-(

Here is what I came up with:

metadata:
name: Dining Room Temp Less 73
description: If Cooling drops below 73 set it to 74
automations:
# “starters” and “actions” are required; “condition” is optional.
# ---- STARTERS ---- #
# Starters describe events that will start the automation.
starters:
- type: device.state.TemperatureSetting # Handles temperature points and modes of a thermostat device.
state: thermostatTemperatureAmbient
lessThan: 73F
device: Dining Room - Dining Room

# ---- ACTIONS ---- #
# Actions will start when a starter event takes place and all conditions are met.
actions:
- type: device.command.ThermostatTemperatureSetpoint # Set the target temperature for a thermostat device.
thermostatTemperatureSetpoint: 74F
devices: Dining Room - Dining Room

Awesome.. good to hear that!

Did your script pass validation with that typo? 

With the typo, it did not pass the validation, but being new to this scripting, the error was not specific to pinpoint the issue.  The error was showing an invalid struct or something similar to that.


Once I made the changes noted above, the script passed the validation.   

I added a condition as well to ensure this applied to running in Cool mode:

condition:
type: device.state.TemperatureSetting # Handles temperature points and modes of a thermostat device.
state: activeThermostatMode
is: cool
device: Dining Room Thermostat - Dining Room

 

I'll spend some time to make this more elegant and efficient and apply to all 4 of my thermostats. 

I'm not sure if it's better to have one automation per thermostat or combine them all into one for the same action(s).

Thank you for the feedback @krroller - Taking a note to improve the validation message.