06-15-2023 10:46 AM - edited 06-15-2023 11:07 AM
Hey everyone!
This week, we released the script editor, a tool for creating advanced home automations, on Google Home for web and the Google Home app. Learn more about it in our community blog: New to Public Preview: create powerful automations with our script editor.
You can unlock the full potential of home automation by building advanced, personalized automations. Here are some examples that can be done only in the script editor:
We'd love to hear about how you are using the script editor. Share your favorite use cases for the script editor, and your automation scripts in the comments below!
Here are some helpful guidelines for sharing your automations in the Community discussion forum:
06-15-2023 10:52 AM - edited 06-15-2023 10:56 AM
Thanks @kelanfromgoogle
Looking forward to seeing what everyone is creating. We are here to help if there are any questions.
06-22-2023 08:59 AM
I am trying to use a motion detection event as a starter, in lieu of motion activity state, and EventData is an optional state. Per the help file, the event data options are either "Priority" or "TimeStampSec." The list of options for Priority is a number, but the help files do not define what each value relates to. Is there documentation that provides greater details, such as what each priority value equates to? The code below was my attempt to get some information, but the system did not respond.
metadata:
name: TEsting Stuff # Choose a short name that summarizes important starters and actions, like “Sunset lights”.
description: Scripted automation # Write a detailed description that includes everything the automation does, like “At sunset, on weekdays, close blinds, turn on lights to 50%, and play the sunset playlist on certain speakers.”
automations:
# “starters” and “actions” are required; “condition” is optional.
# Use Ctrl + Space to see autocomplete suggestions.
# ---- STARTERS ---- #
# Starters describe events that will start the automation.
# To add more than one starter, duplicate the "- type" section under "starters".
# If you add multiple starter events, any one of them happening will start the automation
- starters:
- type: device.event.MotionDetection # This function belongs to devices which are able to record motion detection.
eventData: priority
is: 0
device: Front Door MotionSensor - Front Porch
actions:
- type: assistant.command.Broadcast
message: "Priority is 0"
devices: Dining Room Speakers - Dining Room
- starters:
- type: device.event.MotionDetection # This function belongs to devices which are able to record motion detection.
eventData: priority
is: 1
device: Front Door MotionSensor - Front Porch
actions:
- type: assistant.command.Broadcast
message: "Priority is 1"
devices: Dining Room Speakers - Dining Room
- starters:
- type: device.event.MotionDetection # This function belongs to devices which are able to record motion detection.
eventData: priority
is: 2
device: Front Door MotionSensor - Front Porch
actions:
- type: assistant.command.Broadcast
message: "Priority is 2"
devices: Dining Room Speakers - Dining Room
06-29-2023 01:35 PM
07-28-2023 08:06 AM
I noticed that motion detection for Nest Thermostats and Cameras are now a starter. This is great! For the cameras, are we able to distinguish motion within a defined zone?
07-28-2023 12:54 PM
Does it works? it gives me an error in the state parameter.
09-02-2023 06:23 AM
Agree here. We need to have zones available to use with the cameras, etc.
On my front door camera with a 'driveway' zone enabled, the script fails validation as it thinks person detection is turned off but it's only turned off for outside of the zone.
I'd say most people have zones set up on their cameras. Without seeing zones in the script editor, it won't be much use unfortunately. 😓
06-21-2024 11:26 PM
is there any updates on zones availability from Google? for Nestcams?
04-05-2024 03:10 AM
Ok Google
05-02-2024 03:43 AM
06-15-2023 11:17 AM - edited 06-15-2023 11:20 AM
I am working on creating a routine that turns my porch light on/off based on two motion sensors. ("or" condition for both sensors to turn the light on and an "and" condition for both sensors to turn the light off) The single light source affects two motion zones, so the ability to write a routine should help. I will find out if it works when it gets dark.
I am struggling with the save feature if I apply a "for" condition to both sensors with the "motionDetectionEventInProgress" state identified as "false." I can apply the "for" condition to one of the sensors and the routine will save, but not both. My preference is for both sensors to have to not sense motion for several minutes before the light turns off. Any thoughts?
automations:
starters:
- type: device.state.MotionDetection # This function belongs to devices that can detect motion.
state: motionDetectionEventInProgress
is: false
for: 3min
device: Front Door MotionSensor - Front Porch
- type: device.state.MotionDetection # This function belongs to devices that can detect motion.
state: motionDetectionEventInProgress
is: false
for: 3min
device: Front Porch MotionSensor - Front Porch
06-15-2023 06:02 PM
Thanks for sharing @William1701 - That's a very interesting use case but is not yet supported. Currently:
The closest workaround for your case could be to use sensor1 as starter using "for" and sensor2 as condition (motionDetectionEventInProgress = False)? You would need to do that both ways.
06-16-2023 12:54 PM
Prafulla
Separating the starters for the no-motion condition into two possible start conditions appears to work to create the "or" condition without the save fail. Thanks for your help. The script is now a bit more complex as I have added a condition that it should not run when I am using the light as part of my holiday decorations, and only for evening hours. New, much longer script below (indentions lost in paste):
metadata:
name: Front Porch Lights On/Off with Motion # Update automation name e.g. "Movie time"
description: Scripted Front Porch Steps Control Test # Update automation description
automations:
- starters:
# Use Ctrl + Space to get autocomplete suggestions
- type: device.state.MotionDetection # This function belongs to devices that can detect motion.
state: motionDetectionEventInProgress
is: true
device: Front Door MotionSensor - Front Porch
- type: device.state.MotionDetection # This function belongs to devices that can detect motion.
state: motionDetectionEventInProgress
is: true
device: Front Porch MotionSensor - Front Porch
condition:
type: and
conditions:
- type: time.between
after: sunset
before: sunrise
weekdays:
- MON
- TUE
- WED
- THU
- FRI
- SAT
- SUN
- type: or
conditions:
- type: device.state.Online
state: online
is: false
device: Icicles Left - Holiday
- type: and
conditions:
- type: device.state.Online
state: online
is: true
device: Icicles Left - Holiday
- type: device.state.OnOff
state: on
is: false
device: Icicles Left - Holiday
actions:
- type: device.command.BrightnessAbsolute # Adjust device absolute brightness.
brightness: 15
devices: Front Porch Steps - Front Porch
- type: device.command.ColorAbsolute
color:
name: warm white
devices: Front Porch Steps - Front Porch
- type: device.command.ColorAbsolute
color:
name: warm white
devices: Front Door Lamp Left - Front Porch
- type: device.command.ColorAbsolute
color:
name: warm white
devices: Front Door Lamp Right - Front Porch
- starters:
- type: device.state.MotionDetection # This function belongs to devices that can detect motion.
state: motionDetectionEventInProgress
is: false
for: 2min
device: Front Porch MotionSensor - Front Porch
condition: # Use Ctrl + Space to get autocomplete suggestions
type: and
conditions:
- type: device.state.MotionDetection # This function belongs to devices that can detect motion.
state: motionDetectionEventInProgress
is: false
device: Front Door MotionSensor - Front Porch
- type: or
conditions:
- type: device.state.Online
state: online
is: false
device: Icicles Left - Holiday
- type: and
conditions:
- type: device.state.Online
state: online
is: true
device: Icicles Left - Holiday
- type: device.state.OnOff
state: on
is: false
device: Icicles Left - Holiday
actions:
- type: device.command.OnOff # Turn the device on or off.
on: false
devices: Front Porch Steps - Front Porch
- starters:
- type: device.state.MotionDetection # This function belongs to devices that can detect motion.
state: motionDetectionEventInProgress
is: false
for: 2min
device: Front Door MotionSensor - Front Porch
condition: # Use Ctrl + Space to get autocomplete suggestions
type: and
conditions:
- type: device.state.MotionDetection # This function belongs to devices that can detect motion.
state: motionDetectionEventInProgress
is: false
device: Front Porch MotionSensor - Front Porch
- type: or
conditions:
- type: device.state.Online
state: online
is: false
device: Icicles Left - Holiday
- type: and
conditions:
- type: device.state.Online
state: online
is: true
device: Icicles Left - Holiday
- type: device.state.OnOff
state: on
is: false
device: Icicles Left - Holiday
actions:
- type: device.command.OnOff # Turn the device on or off.
on: false
devices: Front Porch Steps - Front Porch
- type: device.command.OnOff # Turn the device on or off.
on: false
devices: Front Door Lamp Left - Front Porch
- type: device.command.OnOff # Turn the device on or off.
on: false
devices: Front Door Lamp Right - Front Porch
06-16-2023 05:54 PM
Wow that's one long script 🙂 Btw, you should be able to use the "insert code sample" feature of the editor that looks like "</>" and use "CSS" to format and share your script without losing the indentation.
06-18-2023 05:38 AM
Sending the script in the CSS format as suggested, for those who might be interested.
metadata:
name: Front Porch Lights On/Off with Motion
description: Scripted Front Porch Steps Control Test
automations:
- starters:
- type: device.state.MotionDetection
state: motionDetectionEventInProgress
is: true
device: Front Door MotionSensor - Front Porch
- type: device.state.MotionDetection
state: motionDetectionEventInProgress
is: true
device: Front Porch MotionSensor - Front Porch
condition:
type: and
conditions:
- type: time.between
after: sunset
before: sunrise
weekdays:
- MON
- TUE
- WED
- THU
- FRI
- SAT
- SUN
- type: or
conditions:
- type: device.state.Online
state: online
is: false
device: Icicles Left - Holiday
- type: and
conditions:
- type: device.state.Online
state: online
is: true
device: Icicles Left - Holiday
- type: device.state.OnOff
state: on
is: false
device: Icicles Left - Holiday
actions:
- type: device.command.BrightnessAbsolute
brightness: 15
devices: Front Porch Steps - Front Porch
- type: device.command.ColorAbsolute
color:
name: warm white
devices: Front Porch Steps - Front Porch
- type: device.command.ColorAbsolute
color:
name: warm white
devices: Front Door Lamp Left - Front Porch
- type: device.command.ColorAbsolute
color:
name: warm white
devices: Front Door Lamp Right - Front Porch
- starters:
- type: device.state.MotionDetection
state: motionDetectionEventInProgress
is: false
for: 2min
device: Front Porch MotionSensor - Front Porch
condition:
type: and
conditions:
- type: device.state.MotionDetection
state: motionDetectionEventInProgress
is: false
device: Front Door MotionSensor - Front Porch
- type: or
conditions:
- type: device.state.Online
state: online
is: false
device: Icicles Left - Holiday
- type: and
conditions:
- type: device.state.Online
state: online
is: true
device: Icicles Left - Holiday
- type: device.state.OnOff
state: on
is: false
device: Icicles Left - Holiday
actions:
- type: device.command.OnOff
on: false
devices: Front Porch Steps - Front Porch
- starters:
- type: device.state.MotionDetection
state: motionDetectionEventInProgress
is: false
for: 2min
device: Front Door MotionSensor - Front Porch
condition:
type: and
conditions:
- type: device.state.MotionDetection
state: motionDetectionEventInProgress
is: false
device: Front Porch MotionSensor - Front Porch
- type: or
conditions:
- type: device.state.Online
state: online
is: false
device: Icicles Left - Holiday
- type: and
conditions:
- type: device.state.Online
state: online
is: true
device: Icicles Left - Holiday
- type: device.state.OnOff
state: on
is: false
device: Icicles Left - Holiday
actions:
- type: device.command.OnOff
on: false
devices: Front Porch Steps - Front Porch
- type: device.command.OnOff
on: false
devices: Front Door Lamp Left - Front Porch
- type: device.command.OnOff
on: false
devices: Front Door Lamp Right - Front Porch
06-15-2023 01:39 PM
I created a script that will play sound on a device in the house when I am away and the Sensor is open.
The issues I have are. It is very delayed and sometimes does not trigger and set volume on device does not seem to work. Media shuffle resume is temperamental too.
What I am trying to achieve is to start music on a few devices when the alarm is triggered.
Below is the script.
# ------------------------------------------------------------------------------------------ #
# Any line that starters with "#" sign is a comment and gets ignored.
# Indentation (i.e. Number of spaces before each line) is used to decide information hierarchy.
# To populate the template, please follow instructions listed via comments in this template.
# To learn more, please visit g.co/home/scripts for full documentation.
# ------------------------------------------------------------------------------------------ #
metadata:
name: Alarm Front Door # Update automation name e.g. "Movie time"
description: Scripted automation # Update automation description
automations:
# Update "starters", "actions" and optionally "condition" sections to create an automation
# Duplicate these three sections under "automations" to add more automations in the same script
# ---- STARTERS ---- #
# Starters describe events that should start the automation
# Duplicate "- type" section under "starters" to add more than one starters
# If you add multiple starters, any one of them happening will start the automation
# Automations will run if any of the starters meets the criteria
starters:
# Use Ctrl + Space to get autocomplete suggestions
- type: device.state.OnOff
state: on
# [available operators: is, isNot]
is: true
device: Smart Meter - Generic devices
# ---- CONDITIONS ---- #
# Conditions are optional checks that can limit an automation to run only in certain cases
# If your automations does not require conditions, please completely delete the CONDITIONS section
# To use advance conditions that use logical operators ("and", "or", "not") please visit our documentation
condition:
# Use Ctrl + Space to get autocomplete suggestions
type: home.state.HomePresence
state: homePresenceMode
# [available operators: is, isNot]
is: AWAY
# ---- ACTIONS ---- #
# Actions are performed when a automation starts and all conditions are met
# Actions run sequentially and respect any delay introduced between them
# Duplicate "- type" section under "actions" to add more than one action
actions:
# Use Ctrl + Space to get autocomplete suggestions
- type: device.command.SetVolume # Set the volume of a given device.
devices: Livingroom speaker - Livingroom
volumeLevel: 50
- type: assistant.command.Broadcast
message: The front door has been opened
devices: Livingroom speaker - Livingroom
06-15-2023 06:10 PM
@adriangalbincea - thanks for the feedback. Do you mind sharing which smart devices / speakers are you using? How often is it working? and what's the latency you are seeing?
06-16-2023 12:16 AM - edited 06-16-2023 12:17 AM
Hi @Prafulla, the speaker is Nest mini. The other device used as a trigger is a smart switch(Smart Life).
I did a test today and after 80 seconds was triggered. Very slow...
06-16-2023 05:55 PM
That's really slow and unexpected. Taking a note for internal investigation.
06-21-2023 02:29 PM
I also have an automation that doesn't work with a sensor. The automation is supposed to turn on the lights to my shed when I open the door via a contact sensor on the door. The automation doesn't work at all, not until you open the home app, then it works flawlessly. I noticed when opening the home app all your devices load, I'm guessing that it's because the Google home app doesn't recognize the state of my sensor until the Google home app is open.
06-15-2023 01:42 PM
Hi!
The scripting is great. But I tought there would be more starters than only our devices.
- I'd suggest to have a Weather based starter (Sun, Rain, ...)
- Nest Camera Events Starters (Person detected, Zones, ...)
I'm eager to see those!!
Thanks
06-15-2023 05:53 PM
Great suggestions.
Beyond device starters there are Assistant voice starter:
starters:
- type: assistant.event.OkGoogle
eventData: query
is: Movie time # No need to add "Ok Google" to the query here.
Home Presence starter:
starters:
- type: home.state.HomePresence
state: homePresenceMode
is: HOME
condition:
type: home.state.HomePresence
state: homePresenceMode
is: AWAY
Time schedule starter
https://developers.home.google.com/automations/schema/reference/standard/time_schedule_event
06-15-2023 06:06 PM
Thanks for the feedback @Toner - "Camera events" are coming very soon as we shared in our announcement (https://www.googlenestcommunity.com/t5/Blog/Create-powerful-automations-with-our-new-script-editor-n...)
Weather event starters is another top use case that the team is actively exploring.
06-16-2023 05:47 AM
The weather to know if is necessary or not to open blinds (if too sunny, no open because too hot in the house)
06-16-2023 08:22 AM
Actually, to control blinds/ curtains it would be more useful to use level of light (usually measured in LUX) from a sensor.
For instance all HUE motion sensor also measure LUX. These values are not available to see in the Google Home app nor the native HUE app itself. But the 3rd party app "Hue essentials" gives you access to level of light measured by the motion sensor.
At the moment i have a HUE motion sensor sitting in my window. Once it measures more than 30.000 LUX - which is direct sunlight - it will trigger a lamp to turn on, and when that lamp turns on my blinds/ shutters will close.
This is of course a workaround, and i would obviously be much more happy to be able to create this scenario and automation directly in the Google Home app.
One thing that i dont understand is, why not all sensor data is available in the Google Home app.
I have several Shelly products, and on my Google Nest hub i can access both temperature and humidity data. But in the Google Home app only humidity.
How hard can it be to display the data, when the sensor is providing it?
Same with the HUE motion sensor. They measure both movement, temperature and light level/ LUX. It should not be that hard to make the data available in the Google Home app.....
06-16-2023 05:45 PM
Hi @Toner - Thanks for sharing. We are systematically collecting all ideas here: https://www.googlenestcommunity.com/t5/Home-Automation/Script-Editor-Share-your-ideas-and-vote-on-ot...
May I request you to submit those ideas separately so that others can vote on them? Thanks.
06-15-2023 03:12 PM
Looks like you can't set the volume on Nest Audio, or the JBL Portable Smart Google Speaker.
Nothing happens. No errors, but the volume never changes.
I have several switchbot devices, and I need to "toggle" some of those. there is no toggle action.
06-15-2023 06:16 PM
Thanks for the feedback @lardo5150 - We are investigating the volume issue.
Re: Switchbot - can you toggle them using Google Home app and not via the script editor?
06-16-2023 05:21 AM
yes. if I set it up to be a on/off button.
Here is an example of having a toggle option AND a repeat.
I am controlling the volume on a receiver that is not smart.
To change to bluetooth, I have to turn "on" and "off" that button to get it to the right input.
Then same thing for volume, I have to keep processing the on and off to get the volume to 30. A repeat would be good here.
06-16-2023 06:03 PM
Thanks for the details @lardo5150 - I would love to capture your "repeat" idea and example in this post to allow other users to vote on it too. https://www.googlenestcommunity.com/t5/Home-Automation/Script-Editor-Share-your-ideas-and-vote-on-ot...
06-15-2023 06:53 PM
I was looking forward to trying something with my Aqara FP2, using OccupancySensingState as a start state. However, when I tried to do so, using something like the example on that page, i.e.:
- type: device.state.OccupancySensing
device: Desk - Master Bedroom
state: occupancy
is: OCCUPIED
I found that the editor highlighted the type as not being a valid type, and the script would not save. In fact, if I ctrl-spacebar in "type," that OccupancySensing does not seem to exist. Is the documentation wrong, or is the editor?
06-16-2023 06:06 PM
Hi @jkane001 - Do you see "Aqara FP2" in your Google Home app but not in the script editor? We are investigating this further but autocomplete / ctrl+space shows options only when your home has devices that can support a given state e.g. OccupancySensingState.
06-17-2023 07:01 AM
The Aqara device is in my home app (but shows as "Presence Sensor FP2" on the tile). Having multiple detection zones set up w/ that device, it also has 2 additional motion sensor tiles in Home, one called "Bed" and one called "Desk." In the home app, all three show a "motion detected" or "no motion" status as I am looking at it right now on my device.
06-17-2023 08:08 AM
I see. Motion sensors are treated differently from Matter occupancy sensors. See these two examples:
Can you try #1 and use your FP2 as a motion sensor?
06-17-2023 09:35 PM - edited 06-17-2023 09:37 PM
Can Nest Protect, Nest Learning Thermostat (Gen 3), and/or Nest Cameras be used a motion detection sensor?
06-18-2023 10:01 AM
Not yet but we are actively exploring this. Looks like other users are suggesting it too. Please feel free to to upvote related ideas in the ideas post.
08-27-2023 08:20 PM
@Prafulla rather than hiding valid items in the autocomplete why not offer the options but colour them in a different colour, like red, to indicate that the syntax is valid but the option is not currently valid in the current context. This could allow scripts to be developed and prepared even when the current options may be unavailable at the time of development.
11-07-2024 06:45 PM
I got the exact same problem with Google Home and Aqara fp2, did you ever get it to work with OccupancySensing?
06-15-2023 11:57 PM
Hi
Is it possible to make custom variables
06-16-2023 05:24 PM
Hi @Eurik123 - We don't yet but would love to capture your request and use case as a new idea here, if you don't mind sharing. This will allow others to vote as well. https://www.googlenestcommunity.com/t5/Home-Automation/Script-Editor-Share-your-ideas-and-vote-on-ot...