Tuesday
Hi, I have simple (as I though) task.
When door is opened, wait for 5 seconds and switch on the light
When door is closed switch off the light.
Problem is, if I close the door within this 5 seconds light is switched on behind the closed door when time comes.
I couldn't find the way to add condition on second part of the action (switching the light on only if door still opened) after time.delay or maybe cancel the action that is already running.
Are there any workarounds or am I missing something simple?
Answered! Go to the Recommended Answer.
Wednesday - last edited Wednesday
You might have to look into Google scripts (public preview) to add sensor conditions like... If the door sensor is open for longer than 5 seconds turn on light (if that's even possible there).
Also check the sensor manufacturer's app to see if there's anything like that.
Without special script coding of an automation I can only think to mitigate or reduce the lighting like ...
1. Door opens: delay 5 seconds, light on.
Door closes: delay (up to) 5 seconds, light off.
OR
2. Use a light strip at 1% which has a much lower brightness than a bulb at 1% and then 50% to 100% after 5 seconds.
Tuesday - last edited Tuesday
So let me see if I understand you correctly.
Door open Light on for 5 seconds
Door closed light off.
But if door closes with the 5 second delay you want the light to turn off immediately?
Well, I would try...
1st automation: open = on
2nd automation: light on triggers 5 second delay
3rd automation: closed = off
Hopefully the 3rd automation will override the delay.
Tuesday - last edited Tuesday
Hi, not exactly
Door open
- delay 5 seconds ( in case I just opened it to throw socks in the laundry basket, I do not need the light)
- after 5 seconds lights on (in case I actually need something in the closet)
Door closed
- lights off
But what happens when Door closed after let's say 3 seconds, lights still switched on after following 2 . Exactly 5 seconds after opening even though door is already closed.
Wednesday - last edited Wednesday
You might have to look into Google scripts (public preview) to add sensor conditions like... If the door sensor is open for longer than 5 seconds turn on light (if that's even possible there).
Also check the sensor manufacturer's app to see if there's anything like that.
Without special script coding of an automation I can only think to mitigate or reduce the lighting like ...
1. Door opens: delay 5 seconds, light on.
Door closes: delay (up to) 5 seconds, light off.
OR
2. Use a light strip at 1% which has a much lower brightness than a bulb at 1% and then 50% to 100% after 5 seconds.
Thursday
I see, script does have it's limitations.
This answer actually is a good workaround. I set five switch off actions with 1 second interval after door is closed. This is closest to what I'm trying to achieve.
Thank you
Thursday
You're welcome 👍
7 hours ago
There are essentially 3 ways to build automations in the Google Home ecosystem.
1. Via the Google Home App - Automations most common, limited though not by much)
2. Automations Script Editor (the best way to do it IMO as return vs learning curve is that bad)
3. Via the Homes API (if you know how to do this then im not going to say anythiung you dont already know.)
Automations Script Editor , while not a full IDE, is fairly robust. I have 1 script that uses an Aqara Contact Sensor to turn on Xbox Series X, Turn on a Samsung TV, Turn on an Okyo receiver, turn on or off specific Govee and Govee LIfe items, set a Dreo fan and lock a Swithbot lock.
Nothing about that scrjipt is limited.
Anyway what you want to do shouldn't be hard in SE, i just pulled this togethe rand tested here without issue.
metadata:
name: Sunday Test
description: Door Open, Turn on lights, delay, off
automations:
- starters:
- type: device.state.OpenClose
state: openPercent
is: 100
device: AQCS01 - Control
suppressFor: 5 seconds
# condition:
# type:
actions:
- type: device.command.OnOff
on: true
devices: Bedroom Lights - Bedroom
- starters:
- type: device.state.OpenClose
state: openPercent
is: 0
device: AQCS01 - Control
# condition:
# type:
actions:
- type: device.command.OnOff
on: false
devices: Bedroom Lights - Bedroom
5 hours ago - last edited 5 hours ago
Try this:
metadata:
name: wait 5 then run
description: Turn on light 5 sec after door opens
automations:
- starters:
- type: device.state.OpenClose
device: Back door - Family room
state: openPercent
is: 100
for: 5sec
actions:
- type: device.command.OnOff
devices:
- Family room light - Family room
on: true
The "for: 5 sec" is not well documented but does work and will validate.