I want to make an automation to turn a light off, after X minutes. No matter how the light was turned On.
I have tried all kind of combinations, and tried all the tips I found googling. But the automation never seems to get triggered. I have changed the trigger to check from ‘Off’ to ‘On’, also added the delay to the action instead of the trigger. But it just seems that the automation never triggers.
(just using 10 in the code below to check the automation in 10 seconds)
When I click execute on the automation, it does turn off the light.
alias: Slaapkamer uit na 30 minuten
description: ''
trigger:
- platform: state
entity_id: light.54802417d8f15bcdfb49
to: 'On'
for: '10'
condition: []
action:
- type: turn_off
device_id: 9c6bd3a09a47421fb7dd732cf6a0db1f
entity_id: light.54802417d8f15bcdfb49
domain: light
mode: single
I just wanted to say thank you for this post. It really helped me!
I made a automation that turns off the lights I have on the outside. Usaually they are turned on via a physical Ikea on/off switch, but they are rarely needed for more than 10 minutes.
I really like Home Assistant and the whole smart home thingy, but I do wish it wasn’t so dam-ed complicated in some ways…
I was just attempting to use the switch version of the blueprint, the time input is a little confusing. Wouldn’t a “duration” selector instead of a “time” selector be more appropriate? In it’s current state it’s looking for a time of day instead of length of time.
Currently I have a motion sensor and upon triggering it will turn on.
I want it to turn on for 15mins and if I re-trigger again, I don’t mind that the counter is resetted and then turn on for 15mins.
You can do that with a standard automation like this. It will turn the lights on for 10 minutes. If it detects movement within that 10 minutes, it will just extend it to 10 minutes again. I use it in my bathroom and also have a ventilation automation connected to it. So when I leave the bathroom, the lights (and ventilation) stay on for max 10 more minutes and then turn off.
Thank you for this, I’m still new to this and had spent an age trying to get this to work. This after already pulling my hair out because my light was showing up as an entity rather than a device when turning it on.
Hope someone can help me, unfortunately I’m not experienced with creating rules.
Always get error “Message malformed: extra keys not allowed @ data[‘0’]”
alias: Turn off via motion detector
description: “test”
fashion: single
triggers:
platform: state
entity_id: binary_sensor.lumi_lumi_motion_ac02_occupancy
to: ‘off’
for:
minutes: 10
action:
service: light.turn_off
entity_id: light.sofa
Hi fellow Dutchman.
Does this work when you switch the light on bij putting the power on it with a normal switch?
I can’t get that to work.
My kids have a tendency of not switching off the light on the overloop. No idea what overloop is in English.
Works when i run the automation manually.
I use Zigbee lights from Lidl.
alias: Zet lamp Overloop uit
description: ""
trigger:
- platform: state
entity_id:
- light.lamp_overloop_light_4
to: "on"
for:
hours: 0
minutes: 0
seconds: 10
condition: []
action:
- type: turn_off
device_id: a8993e58f2802892ff41a715d5620f04
entity_id: light.lamp_overloop_light_4
domain: light
mode: single
Hi,
I don’t know if this would work by using the normal power button. I have disabled all my normal powerbuttons in my house (by adding a bit of tape while its in the OFF position). HA will probably not get the right event here, as the device is not available when it is completely turned off. Perhaps there is a way to detect that the light is connected to HA again and then do this check, but not sure if that can be detected.