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.

 

172 REPLIES 172

Diazed
Community Member

The section about variables is documented very briefly.
I would like to see a larger example using variables.

It would also be great to have the possiblity to create variables that are used inside multiple Script Automations.

Is it possible to start audio inside an action? For example my favorite podcast in the morning.
And if so, is it possible to start the podcast on multiple devices?

I only found the setInput action but i guess that means VideoInput for TVs right? 

I am deeply in love with the new possibilities this offers. I am very thankful for all the work that has been poured inside this new feature.  

Hi @Diazed - Variable support is in early stages but I would love to capture your ideas here so that other can vote on it too. https://www.googlenestcommunity.com/t5/Home-Automation/Script-Editor-Share-your-ideas-and-vote-on-ot...

 

Please add one comment per idea in the format suggested in the post. Thanks.

 

Re: your audio question, we do support OkGoogleCommand custom action that allows you to run any Assistant command as an action. See if that helps?

Diazed
Community Member

It would also be great to have the possibility to ask for a confrimation.

Have the assistant ask a question i provided as string.
If i reply with yes the condition is met.

Just an idea.  

Hi @Diazed - May I request you to submit the Assistant confirmation idea here? https://www.googlenestcommunity.com/t5/Home-Automation/Script-Editor-Share-your-ideas-and-vote-on-ot...

Vitor_Videira
Community Member

Hi Kelan,

Are there any chances of triggering automations based on weather conditions?

Regards,

Vitor Videira.

Pls hel0 me my money from gcash account get one app unauthorized

 

nickfromgoogle
Googler
Googler

Adding a fun automation that I've started building out. I have one light at home with a touch control base to turn it on/off which is handy but unfortunately also makes it easy for my cats to turn it on and off. For now, I'm starting with that light to turn it off in case my cats turn it on while I'm away from home.

 

I plan to expand it to some other devices in my house that my cats may be able to trigger - my kitten loves to swipe at my Nest Hub with the weather frog background. Looking forward to the camera event starters as well!

 

metadata:
  name: Cat proofing
  description: While I'm away, prevent my cats from turning on the lights

automations:
  starters:
    - type: device.state.OnOff
      state: on
      is: true
      device: Office light - Office

  condition:
    type: home.state.HomePresence
    state: homePresenceMode
    is: AWAY

  actions:
    - type: device.command.OnOff
      on: false
      devices:
        - Office light - Office

 

Google Photos can recognize my cat from others so I propose higher definition Nest cameras and facial recognition automations for animals 🐱

LoL

 

 

Regards,
Cathal

@Cathal_S if you haven't already, please do submit this cool idea in ideas thread

AbeF
Community Member

Would really open a lot of options if we can use Google Calendar as a starter. Would love to create a specific calendar in Google Calendar called Smart Home Calendar. I would then create an automation if the Calendar has an event "ABC" then perform "XYZ" automation when event "ABC" starts and then perform "DEF" automation when event "ABC" ends etc. I can then create calendar events on the fly that will automate my home with ease and on a schedule. 

Diazed
Community Member

Yes please

 

Could enter my free days and pause my morning alarm for those days. 

No more waking up early on days off work 

Hi @AbeF - May I request you to submit the calendar integration idea here? https://www.googlenestcommunity.com/t5/Home-Automation/Script-Editor-Share-your-ideas-and-vote-on-ot...

Eurik123
Community Member

It would be great if I could use google home hub's motion sensor and it's secret  temperature sensor in code.

It would be great if Google offered a stand alone motion sensor.

ThierryGuy
Community Member

Custom automations built using the script don't appear on my Google Home app, according to the documentation, it should appear in the app: https://developers.home.google.com/codelabs/create-a-scripted-automation

Any suggestions? 

 

Thanks!

Hi @ThierryGuy - Google Home app features are slowly rolling out this week and next. Please ping this thread if you cannot see them by the end of the next week.

Hi @Prafulla, my Google Home app intermittently stops showing my scripted routines and when it stops showing them it doesn't let me create new ones within the app.  I can't find a consistent pattern to when they show or not in my Home App.

Hmm... that should not happen. We have not seen other users reporting this. Android or iOS? Tried clearing cache? Can you try filing in-app feedback next time you don't see them? Thanks.

I have this same issue.

Same to my Home App

il_Capitano_25
Community Member

Is it possible to get a notification on my smartphone when an action has taken place?For example, I want to get a notification when the window is open for more than 10 minutes.

"home.command.Notification" doesn't seem to work no matter what I select.

@il_Capitano_25 custom in-app notifications are coming soon as we shared in our announcement post. Feel free to submit this idea in our idea post so that other members can vote on it as well.

When can we expect an update for custom in-app notifications?

The Aqara Mini Switch (connected via Matter of the Aqara M2 Hub) has recently been displayed in the Google Home App. Unfortunately, this has no function or the "on and off" buttons do not trigger. There is also no function via the script editor. Is there any way to trigger automations by pushing a button?

Same here. I tried different scenarios but "home.command.Notification" never send the notifications.

krroller
Community Member

Is it possible to view automation runtime history to be able to see what automations ran when, and what the trigger for the starter was if conditional or multiple starters exist?

@krroller - Currently we post an event in Google Home > Activity tab whenever a scripted Automations starts. We are actively exploring ways to support better debugging and will share an update in this community whenever advanced logging / debugging capabilities are available. 

JP3006
Community Member

Unable to use "device.state.TemperatureControl" as a starter. Getting an error that it is an unknown type name. Any idea how to fix that?

JP3006_1-1687041192139.png

 

#Adjust temperature based of reading from pantry sensor
- starters:
- type: device.state.TemperatureControl
device: Pantry Sensor - Living Area
state: temperatureAmbient
is: 78F
condition:
type: and
conditions:
- type: device.state.OnOff
state: on
device: Ceiling Fan - Living Area
is: false
- type: time.between
after: 12:00 PM
before: 9:00 PM
actions:
- type: device.command.ThermostatTemperatureSetpoint
devices: Thermostat One - Entryway
thermostatTemperatureSetpoint: 76F

Hi @JP3006 - Currently, you can use a state in an starter (e.g. device.state.TemperatureControl) only when you have at least one device in your home that reports that state to Google Home. For your scenario, can you confirm if (1) you can see "Pantry Sensor - Living Area" in the Google Home app? (2) You can see temperature value from that sensor in the Google Home app? 

 

Also, can you share the model type of your sensor and can you check if your sensor is listed in the supported devices?

 

the most likely reason for this is that the devices you l

JP3006
Community Member

Yes, I can the see the sensor in the GH app under devices and climate tab, but no temperature value, which is probably the reason for the error. If I ask via voice for the temp value, I get a response back of the reported temperature. It's an Aeotec/smartthings Multipurpose Sensor.

Hi,

Adding on to the response above, when you go to the supported devices page linked below and check the 'sensors' box this device doesn't seem to be listed as supported yet.

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

 

Regards,
Cathal

I am having same error message. my sensor is Tuya Temperature Humidity sensor, able to show temperature in Google Home properly.

Screenshot_2023-06-20-20-56-29-041_com.lazada.android-edit.jpg

Hello, I have a similar issue with getting the temperature from my Aqara temperature sensor which is in the list of supported devices, BTW.

0

I'm trying to set up automation via the script editor, a new Google feature. My goal is for the script to turn off the AC when the temperature, as detected by a sensor on my balcony, exceeds a certain value and the balcony door is open.

Here's the condition I wrote for the temperature sensor:

condition:
    type: device.state.TemperatureControl
    state: temperatureAmbientCelsius
    greaterThan: 24
    device: WiFi Temperature & Humidity Sensor - Balcony

However, when I validate, I get the following error:

[device.state.TemperatureControl] is an unknown type name. Expected types: [and, or, not, time.between, device.state... (truncated for brevity)].

Interestingly, a similar condition works for humidity using HumiditySetting:

condition:
    type: device.state.HumiditySetting 
    state: humidityAmbientPercent
    greaterThan: 55
    device: WiFi Temperature & Humidity Sensor - Balcony

It seems TemperatureSetting is reserved exclusively for thermostats. However, there's a note in the documentation:

Sensors that report data covered by another trait should use that trait with the queryOnly* attribute for that trait set to true. For example, temperature sensors should use the TemperatureControl trait with the queryOnlyTemperatureControl attribute set to true.

I'm unsure how to set this attribute in the script editor. Any guidance would be appreciated.

15624980
Community Member

Criei essa rotina através do script, porém por causa da condição de TEMPO ENTRE: 22h até o nascer do Sol, a rotina não funciona de jeito algum, quando eu retiro a condição de tempo, a rotina funciona perfeitamente, porém em qualquer horário.

 A rotina seria essa; A "Led da Cama", só ligara a noite dás "22h até o nascer do Sol", se a "Luz do Quarto" estiver desligada e o "Ventilador de Teto" estiver ligado.

 

"<# ------------------------------------------------------------------------------------------ #

# 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: Led da Cama # Choose a short name that summarizes important starters and actions, like “Sunset lights”.

  description: A "Led da Cama", só ligara a noite dás "22h até o nascer do Sol", se a "Luz do Quarto" estiver desligada e o "Ventilador de Teto" estiver ligado # 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.state.OnOff

      state: on

      # [available operators: is, isNot]

      is: true

      device: Sensor do Quarto - Quarto do Casal

  # ---- 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: and

    conditions:

      - type: device.state.OnOff

        state: on

        # [available operators: is, isNot]

        is: true

        device: Ventilador de Teto - Quarto do Casal

      - type: device.state.OnOff

        state: on

        # [available operators: is, isNot]

        is: false

        device: Luz do Quarto - Quarto do Casal

      - 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: sunrise

        # 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: 22: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

        #of the week to apply condition on.

  # ---- 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: Led Branco - Cama do Casal

    - type: time.delay

      # Adjust duration as needed. Supported units: sec, min, hour

      for: 1sec

    - type: device.command.OnOff # Turn the device on or off.

      on: false

      devices: Led Branco - Cama do Casal

    - type: time.delay

      # Adjust duration as needed. Supported units: sec, min, hour

      for: 5sec

    - type: device.command.OnOff # Turn the device on or off.

      on: true

      devices: Led da Cama - Cama do Casal

    - type: time.delay

      # Adjust duration as needed. Supported units: sec, min, hour

      for: 2sec

    - type: device.command.OnOff # Turn the de

vice on or off.

      on: false

      devices: Led da Cama - Cama do Casal />"

 

 

Obs: deveria funcionar, porém não funciona por causa da condição "tempo entre" e isso está acontecendo em todas as rotinas que estou testando com essa mesma condição de tempo.

Olá, obrigado pela sua pergunta. Eu não falo português, então desculpe qualquer erro de tradução.

Posso solicitar que simplifique o script para identificar a parte que não está funcionando? Você pode usar um dos exemplos de nossa documentação que usa a condição time.between e ver se isso funciona? Em caso afirmativo, você pode adicionar gradualmente outras partes do seu script?

 

Além disso, ao compartilhar seu exemplo, você pode usar o formato de inserção de código </> para que ele seja renderizado corretamente.

15624980
Community Member

Obrigado pela atenção ✌🏼

Mesmo usando um exemplo de script bem simples, não funcionou... 

Uma observação, essa função de condição com horário e dias da semana, nunca funcionou pra mim, nem no app do Google Home 😕 e olha que eu sempre tento utilar essa função, que é fantástica, mas nunca deu certo nas minhas rotinas, estava esperançoso que com as rotinas por script, essa função iria funcionar pra mim.

Screenshot_20230618-173159~2.png

Esse script parece certo para mim.

1) Você pode confirmar se o script está marcado como ativo? Activate.jpg
2) Funciona se você remover todas as condições?

15624980
Community Member

A rotina está "Ativa" e se eu removo as condições, a rotina funciona perfeitamente.

O problema é com essa condição de intervalo de hora. 😕