cancel
Showing results for 
Search instead for 
Did you mean: 

Google Home Script Editor - Condition "time duration"

s_dimaio
Community Member

Hi,

I'd like to receive a notification on my mobile phone if a light stays on for more than 10 minutes. However, I can't find any suitable "conditions" on Google Home - Script Editor.

Do you have any suggestions?

Simone

1 Recommended Answer

nickfromgoogle
Googler
Googler

Hey @s_dimaio  - Conditions are things that are checked each time your automation starts so they won't quite fit this use case. You can try using the for: parameter in combination with the OnOff device state starter so that they light being on for 11 minutes for example will start the automation and send you a notification. This simple example will only send one notification each time the automation runs so you may need to add more starters to send follow up notifications (e.g. every 10 minutes). Check out the example script below for this basic example:

metadata:
  name: Test 11 minute light
  description: Send me a notification if a light is left on for more than 10 minutes

automations:
  # Start automation if office light has been on for 11 minutes
  starters:
    - type: device.state.OnOff
      state: on
      is: true
      device: Office light - Office
      for: 11 min

  # Send me a notification to remind me that the office light is on
  actions:
    - type: home.command.Notification
      title: Office light left on
      body: Looks like you left something on
      members: [home member email]

 

View Recommended Answer in original post

5 REPLIES 5

nickfromgoogle
Googler
Googler

Hey @s_dimaio  - Conditions are things that are checked each time your automation starts so they won't quite fit this use case. You can try using the for: parameter in combination with the OnOff device state starter so that they light being on for 11 minutes for example will start the automation and send you a notification. This simple example will only send one notification each time the automation runs so you may need to add more starters to send follow up notifications (e.g. every 10 minutes). Check out the example script below for this basic example:

metadata:
  name: Test 11 minute light
  description: Send me a notification if a light is left on for more than 10 minutes

automations:
  # Start automation if office light has been on for 11 minutes
  starters:
    - type: device.state.OnOff
      state: on
      is: true
      device: Office light - Office
      for: 11 min

  # Send me a notification to remind me that the office light is on
  actions:
    - type: home.command.Notification
      title: Office light left on
      body: Looks like you left something on
      members: [home member email]

 

Thanks! It works like a charm

OpethNJ
Community Member

I want to confirm this but I want to say leveraging FOR in your starter would do it. Something like this: 

 

metadata:
  name: Light Notification After A period odf Time.
  description: TEST
automations:
  starters:
    - type: device.state.OnOff
      state: on
      is: true
      device: Glide Hexa - Living Room
      for: 15sec
  # condition:
  # type:
  actions:
    - type: home.command.Notification # Send a notification to the specified home members.
      title: Lighting Uptime
      body: Govee Glide Hex has been on for 15 seconds
      # members:  Your Home members go here

OpethNJ
Community Member

I need to check that code when i get home

s_dimaio
Community Member

Thanks! It works!