cancel
Showing results for 
Search instead for 
Did you mean: 

Let's discuss: creating powerful automations with our new script editor!

kelanfromgoogle
Community Manager (Admin)
Community Manager (Admin)

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: 

  • Use clear and concise titles in your post. For example, Automation Script: Water the lawn in the mornings.
  • Include why you created the automation. Describing what this solved for you may inspire others to try it out. For example, "My schedule can vary a lot during the week so it's helpful to add a few conditions to create the automation flexibility I need."
  • Share the script in text format. Copy and paste your automation script so that other users can learn from what you’ve created.

  • Do not include personal information. To ensure your safety, security, and privacy, make sure your custom automation doesn’t include any personal information you don’t want to share.
  • Use the category “Sharing an Automation.” Using the correct category helps other community members find your post.

 

166 REPLIES 166

I wish.. 

dwploc
Community Member

I have consolidated a number of "old" routines that control a number of window shades throughout the house into a singe script with multiple starters.   The reporting of a script starting only reports the script name.  It would be great if it reported both the script name and the starter that was triggered.

teoh-g-home
Community Member

by the way, having Online state condition is really awesome, with that I don't have to buy expensive raspberry pi for home assistant.

I can automate devices that don't support relay (physically turn on will turn on by default). I can also press switch physical button to automate other smart switch !

dwploc
Community Member

I've got two sets of automations 1. what happens at night 2. set a group of window shades positions

In one the OkGoogle events trigger just fine but the other it won't recognize the query

The following is test automation gen'd from the larger file.  There are no errors but still 'open the window shades' is not recognized.  I've tried changing that string but nothing works.  I MUST be missing something obvious.  I built this same automation as a personal routine and it worked fine

 

 

metadata:
  name: test
  description: Scripted automation 
automations:
  - name: testing shades
    starters:
      - type: assistant.event.OkGoogle
        eventData: query
        is: open the window shades
    actions:
      - type: assistant.command.Broadcast
        message: ok
        devices: Office Speaker - Office
      - type: device.command.ActivateScene
        activate: true
        devices: Open Shades in Master Bedroom - Master Bedroom
      - type: assistant.command.Broadcast
        message: opened
        devices: Office Speaker - Office

 

 

nabot
Community Member

time.delay is not working

Nerthus
Community Member

I've tried a rather simple automation as a workaround for the confusing states of the Samsung Frame TV:

(The Frame showing art while in Art mode, but beeing ON in the google home app. Seems like there is no way to distinguish OFF, ON, ART MODE)

 

When the TV gets muted, turn on the light.

starters:
    - type: device.state.Volume # Provides volume state info.
      state: isMuted
      is: true
      device: Samsung The Frame 55

actions:
    - type: device.command.OnOff # Turn the device on or off.
      on: true
      devices: someLight

 For some reason muting the TV does not seem to activate the routine.

 

Then I tried to use the volume but there it seems I can not enter any valid input. Whatever number I use it's always marked as invalid.

starters:
- type: device.state.Volume # Provides volume state info.
      state: currentVolume
      is: 0
      device: Samsung The Frame 55

actions:
    - type: device.command.OnOff # Turn the device on or off.
      on: true
      devices: someLight

 

Questions

  • Why does the routine not react to the mute?
  • What are valid values for the volume state?
  • How do I know what values a device actually sends / what I can use for automations? Only trial and error?

Jordi1232
Community Member

I am trying to add a delay to my motion sensor. My motion sensor is supposed to turn off lights if the hallway lights are turned on (hallway lights turned on = leaving. Hallway lights turned off = coming home).

I am trying to use the following snippet:

condition:
    type: and
    # "AND" together two or more conditionals
    conditions:
      - type: device.state.MotionDetection # This function belongs to devices that can detect motion.
        state: lastMotionDetectionEventEndTimestampSec
        is: 60
        device: Hallway - Hallway

However if I try this it won't allow me to save the script. The problem is that when someone comes home the lights turn on, but that immediately causes everything to turn off as well. Any ideas?

Gk1984
Community Member

Can you provide some more information on using the following code as it doesn't work. 

actions:
type: home.command.Notification
    [Available parameter options: title, body, members]
    title: Notification Title
    body: Notification text
    members: Self

I receive an error that the home.command.Notification is an unknown type name, yet it was available in the auto complete. I also get an error that I am not a member of the household when I use my name or email. I can't find much documentation on this Type. 

What I'm trying to do is add a notification after a script is executed as sort of a confirmation that it ran and to get an idea of when it executed. In this case, it's to turn the lights on based on presence sensing. But in the past, with the built-in Home automation, it would turn the lights on based on presence about 3-5 minutes before anyone even pulled into the driveway. 

I'd also like to use the same action type to send a silent reminder if the garage door is still open when we go to bed based on a smart garage door opener we have. It has it's own tools built in for that, but I'd like to explore what else I can do with it as well. 

dwploc
Community Member

Is there a way to tell that a new build of the scripting system has dropped?

francoisp59
Community Member

I'm having an issue with "type: device.state.TemperatureControl" in the "conditions" section. I picked it from the list but somehow it is rejected by the validation. 

 

# ------------------------------------------------------------------------------------------ #
# Lines starting with “#” are comments and will be ignored by the automation.
# Indentation determines hierarchy within the script.
# Visit g.co/home/script-editor-docs for full documentation.
# ------------------------------------------------------------------------------------------ #

metadata:
  name: Too Hot
  description: When Smartthing sensor is above 75F turnon the window fan

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: time.schedule
      # Required. Time to schedule automation. Accepts either clock time (10:00:00 AM, with seconds optional, or in a 24 hour format), or 'sunrise' or 'sunset', with an optional offset ('sunrise+10m', for instance)
      at: sunset-60min # Adjust offset as needed. Supported units: sec, min, hour
      # Optional. Days of the week to run automation on.
      weekdays:
        - MON
        - TUE
        - WED
        - THU
        - FRI
        - SAT
        - SUN

  # ---- CONDITIONS ---- #
  # Conditions are optional. Delete this section if it’s empty.
  # Conditions will prevent an automation from starting if the conditions aren’t met.
  # See g.co/home/script-editor-docs for documentation about how to use logical operators like “and”, “or”, “not”.
  condition:
    type: device.state.TemperatureControl
    state: temperatureAmbientCelsius
    is: 24
    device: Temperature Sensor - Master Bedroom

  # ---- ACTIONS ---- #
  # Actions will start when a starter event takes place and all conditions are met.
  # Actions will start in the order they appear in the script, and with any delay specified.
  # To add more than one action, duplicate the "- type" section under "actions".
  actions:
    - type: device.command.OnOff # Turn the device on or off.
      on: true
      devices: Ceiling Fan - Master Bedroom

 

You have to add C or F for Celsius or Fahrenheit behind the number. 

jakron
Community Member

I created a simple automation that changes the color of the light depending on whether the thermostat is in heating or cooling status. Everything works if I change the temperature/mode in the Google Home app. But after changing it in the Meross app or on the device itself, the starter doesn't work until I open the Google Home app or ask the speaker about the temperature set in the room. The thermostat is a Meross MTS200, in the list of supported devices it says it should support TemperatureControlState.

 

EDIT1: I waited more than 20 minutes to see if it was due to the delay, but still no response. I also checked the same script with Sonoff light on and off starters, and in this case the script was triggered almost immediately after switching the physical button.

 

My script:

 

 

 

metadata:
  name: Thermostat status light # 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:
      - type: device.state.TemperatureSetting # Handles temperature points and modes of a thermostat device.
        state: thermostatMode
        is: cool
        device: Living Room - Living Room

    actions:
      - type: device.command.ColorAbsolute
        color:
          name: blue
        devices: Ambient 1 - Office

  - starters:
      - type: device.state.TemperatureSetting # Handles temperature points and modes of a thermostat device.
        state: thermostatMode
        is: heat
        device: Living Room - Living Room

    actions:
      - type: device.command.ColorAbsolute
        color:
          name: red
        devices: Ambient 1 - Office

 

 

 

 

I also have gotten a similar issue when setting up a contact sensor, the sensor won't trigger the automation unless I open the home app or the actual contact sensor app. I'm almost certain that it's because the home app is not consistent in checking for device status. Meaning if you change status of the device via some other way then in the home app it doesn't get recognized as a changed status so it doesn't trigger the automation. 

Did you find a solution for this? I am experiencing similar behavior. 

FYI, so... I was able to fix my Tuya sensor, by registering it with the SmartLife application rather than the Tuya application. Apparently, with the SmartLife app... the sensor will proactively send an event to Google, where registration with the other app doesn't. 

No but I guess you figured it out, I will try this when I get home if it works, I'm gonna deem you the goat! And sorry for the late response. 

il_Capitano_25
Community Member

I have no way of starting an automation with the Google Assistant. An error is always output for "eventdata", even if it says standard "query".

What's the error you get? 

I've solved the problem in the meantime. The name voice command was probably not possible because of the umlauts.

1teegulley
Community Member

Is it possible to do any kind of math, or plans for this? This post is a good reference to what I am looking for. I'd like to do something like set the temp like this: thermostatTemperatureSetpoint: thermostatTemperatureAmbient - 2 with the starter being greater than (or equal to)  a specific humidity value.

bostonfern
Community Member

I don't see a way to read the temperature from a temperature sensor.  In my case, it's a Smart Life temperature & humidity sensor.   I think being able to determine the room temperature is very important for automation. 

Cathal_S
Gold Product Expert
Gold Product Expert

Hi @bostonfern 

Unless your sensor is an available device within the Google Home app then you will need to use another home automation system that can communicate with the sensor.

https://developers.home.google.com/automations/supported-devices 

 

 

Regards,
Cathal

In Google Home App, it does display the temperature and the humidity reported by this Smart Life sensor.  I just don't see a way to read temperature using automation. 

Cathal_S
Gold Product Expert
Gold Product Expert

From the supported devices list that I linked to if you select sensors they only list one smart life (Nedis SmartLife) sensor and that only has on/off as the supported actions or commands 😞

 

 

Regards,
Cathal

I hope google will make the temperature and humidity available to these routines.  If google can display them, then there should not be any technical issue in passing the values to the routines. 

15624980
Community Member

I'm having the same problem, I have three temperature sensors, and I can't create routines with them. And both are compatible with Google Home and show temperature and humidity in the app. 

Allen_78
Community Member

Sharing an Automation.

Automation Script: This simple script turns on the lights if someone opens that patio door at night.

The Home app does not let me use door sensors as starters, so I was not able to do this previously.

Here's the automation text:

metadata:
name: Kitchen Light On/Off
description:
Turn on kitchen light when back patio door is opened and it's between 10PM and 6AM
Turn off kitchen light when back patio door is closed and it's between 10PM and 6AM

automations:
- starters:
- type: device.state.OpenClose # If the patio door is opened
device: Back Patio Door Sensor
state: openPercent
is: 100

condition:
type: time.between # Between 10:00 PM and 6:00 AM
after: 10:00 PM
before: 06:00 AM

actions:
- type: device.command.OnOff # Turn the kitchen lights on.
devices: Kitchen light - Kitchen
on: true

- starters:
- type: device.state.OpenClose # If the patio door is closed
device: Back Patio Door Sensor
state: openPercent
is: 0

condition:
type: time.between # Between 10:00 PM and 6:00 AM
after: 10:00 PM
before: 06:00 AM

actions:
- type: device.command.OnOff # Turn the kitchen lights off.
devices: Kitchen light - Kitchen
on: false

 For me this time.between condition doesn't work. I try and the routine doesn't work when I put this condition.

boogieman81
Community Member

Pretty useless tool until you add support for Google Nest Cameras. It's sort of sad that several open source home automation tools are more advanced functionally speaking than Google.

KrajeQ
Community Member

Hi! I really like the new automation, but I have a question. Will there be a condition that will check weather temperature outside? Like from AccuWeather or something. It would be really helpful for me because I could make a routine like:
starter: when turning on tv:
condition: if temperature outside is higher than 20 degrees Celcius
action: close the blinds in living room

fin_david21
Community Member

Absolutely! The script editor on Google Home for web and the Google Home app allows you to create powerful automations and unlock the full potential of home automation

Wysheer
Community Member

Hello to all! I have a nest cam (battery) with flooding light that is power connected full time.

Im trying to do a testing alert with following code, but it gives me error, it tells me that the device isnt  compatible with the motion detection type.  Would you help me please? Thanks!

# ------------------------------------------------------------------------------------------ #
# Lines starting with “#” are comments and will be ignored by the automation.
# Indentation determines hierarchy within the script.
# Visit g.co/home/script-editor-docs for full documentation.
# ------------------------------------------------------------------------------------------ #

metadata:
  name: Untitled # 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; “conditions” are 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.state.MotionDetection
      state: motionDetectionEventInProgress
      is: true
      device: Entrada - Entrada

  # ---- CONDITIONS ---- #
  # Conditions are optional. Delete this section if it’s empty.
  # Conditions will prevent an automation from starting if the conditions aren’t met.
  # See g.co/home/script-editor-docs for documentation about how to use logical operators like “and”, “or”, and “not”.
  condition:
    type: time.between
    # Optional. Accepts either clock time (10:00:00 AM, with seconds optional, or in a 24 hour format), or 'sunrise' or 'sunset', with an optional offset ('sunrise+10m', for instance)
    before: 07:00 # HH:MM (24 hours format). Adjust time as needed
    # Optional. Accepts either clock time (10:00:00 AM, with seconds optional, or in a 24 hour format), or 'sunrise' or 'sunset', with an optional offset ('sunrise+10m', for instance)
    after: 23:00 # HH:MM (24 hours format). Adjust time as needed
    # Optional. Days of the week to apply condition on.
    weekdays:
      - MON
      - TUE
      - WED
      - THU
      - FRI
      - SAT
      - SUN

  # ---- ACTIONS ---- #
  # Actions will start when a starter event takes place and all conditions are met.
  # Actions will start in the order they appear in the script and with any delay specified.
  # To add more than one action, duplicate the "- type" section under "actions".
  actions:
    - type: assistant.command.Broadcast
      message: People on front door
      devices: Parlante Living - Living

 

krroller
Community Member

This same issue exists for Nest Protects and Nest Thermostats. 

It's not likely the API's exist yet to throw events for motion detection on these devices, but it would be good to hear this from the experts and to get this on the roadmap, if not already.

As a member of the Google Developer program I can pull the motion events from the API for Nest Battery Cameras into other 3rd Party open source home automation platforms so the API likely isn’t the issue.

I do not have device.state.motion as a starter option and typing it in (vs selecting from the drop down list for which it's not an option) does not seem to work either.

Cathal_S
Gold Product Expert
Gold Product Expert

@Wysheer 

Motion detection from Nest cameras isn't available yet but Google has indicated that they plan on including it sometime.

 

Regards,
Cathal

@Cathal_S 

Is Motion detection available for Nest Protect or Doorbells or Nest Hubs?

I don't have device.state.motion as a starter option.  Is it because I don't have devices that support this?

As a summary of the various and very much in-the-Google-ecosystem of devices on my home network:

4 Nest Thermostats, 10 Chromecast w/ Google TV devices, 9 Nest Protects, 11 Nest Cameras, 7 Nest Hubs, 2 Nest Doorbells, ~20 Nest Speakers, and ~30 Wemo Switches not to mention Nest Wifi Pro router with 2 access points. 

Cathal_S
Gold Product Expert
Gold Product Expert

@krroller 

No it's not currently available using the Google script editor. As others have mentioned though the API exists as it's possible to do within Home Assistant.

 

A month or so back Google accidentally released motion detection events for automations, they didn't work and was quickly removed. So it's definitely something that's being worked on.

Screenshot_20230706-211508.png

 

 

Regards,
Cathal

Wysheer
Community Member

Thank you all for your responses!

@boogieman81  so you as a developer member can make use of it?

 

Yes, I use them in a Home Assistant application but look forward to them being available to setup in the Google Home app so I can hopefully move off of having to host my own third party app for home automation.