I am taking my first stab at automating one of my wemo insight switches to turn on when the Amcrest camera in the room senses motion. Once the light has been turned on if the camera doesn’t sense motion for 15 minutes the light turns off. I have the automations working, however, when the automation triggers to turn off the light after 15 minutes the camera senses it as motion and is triggering the light on again. Is there any way to disable the first animation or build in some sort of delay to prevent this “switching loop” from occurring?
- alias: Turn on Kid's light during the day when motion is sensed
hide_entity: False
trigger:
platform: state
entity_id: sensor.amcrest_motion_detected
from: 'False'
to: 'True'
#Trigger only between 10am and 7pm
condition:
condition: time
after: '10:00:00'
before: '19:00:00'
action:
service: switch.turn_on
entity_id: switch.wemo_insight__kids_room_
- alias: Turn off Kid's light after 15 minutes without motion
hide_entity: False
trigger:
platform: state
entity_id: switch.wemo_insight__kids_room_
state: 'on'
condition:
condition: state
entity_id: sensor.amcrest_motion_detected
state: 'False'
# Trigger only if state was this for last 15 minutes.
for:
minutes: 15
action:
service: switch.turn_off
entity_id: switch.wemo_insight__kids_room_
You could change the action for the “turn off” to the following (check the automation id, I’ve never used aliases with quotes, so don’t know how it translates)
Basically, when it’s time to turn the light off, turn off the automation that turns the light on, turn off the light, pause for one second, then turn the automation back on. You may not need the delay, or it may need to be longer, depending on your motion sensor’s speed.
I use something very similar for a door sensor and lights, such that it’s the opening of the door that turns on the lights, but the second closing of the door that turns them off again.
Great! That’s what I was hoping, but I wasn’t sure if i would be able to invoke multiple actions off a single trigger. I’ll give it a shot when I get home from work and let you know.
I used your method to work my automation but surprisingly I cannot get it to work. What I mean is that after the sensor has detected motion and the lights are on via MQTT (433mhz) I want them to be on for 10 seconds before they turn off after the last motion. My automation is as follows:
I am trying to switch off the lights after 10 seconds as soon as they are on but surprisingly it doesnt work and the lights remain on. Cannot understand what am I doing wrong?
I have the same problem and tried using the same approach without any luck. When a zone is switched on the master relay must be turned on 5 seconds later. Where do I put the “Delay”?
alias: ‘Master on when Zone on’
trigger:
- entity_id: switch.Zone1
from: ‘off’
platform: state
to: ‘on’
- entity_id: switch.Zone2
from: ‘off’
platform: state
to: ‘on’
- entity_id: switch.Zone3
from: ‘off’
platform: state
to: ‘on’
- entity_id: switch.Zone4
from: ‘off’
platform: state
to: ‘on’
- entity_id: switch.Zone5
from: ‘off’
platform: state
to: ‘on’
- entity_id: switch.Zone6
from: ‘off’
platform: state
to: ‘on’
- entity_id: switch.Zone7
from: ‘off’
platform: state
to: ‘on’
- entity_id: switch.Zone8
from: ‘off’
platform: state
to: ‘on’
- entity_id: switch.Zone9
from: ‘off’
platform: state
to: ‘on’
action:
service: homeassistant.turn_on
entity_id: switch.Master
alias: 'Master on when Zone on’
trigger:
- entity_id: switch.Zone1
from: 'off’
platform: state
to: ‘on’
- entity_id: switch.Zone2
from: 'off’
platform: state
to: ‘on’
- entity_id: switch.Zone3
from: 'off’
platform: state
to: ‘on’
- entity_id: switch.Zone4
from: 'off’
platform: state
to: ‘on’
- entity_id: switch.Zone5
from: 'off’
platform: state
to: ‘on’
- entity_id: switch.Zone6
from: 'off’
platform: state
to: ‘on’
- entity_id: switch.Zone7
from: 'off’
platform: state
to: ‘on’
- entity_id: switch.Zone8
from: 'off’
platform: state
to: ‘on’
- entity_id: switch.Zone9
from: 'off’
platform: state
to: 'on’
action:
delay: ’00:00:05'
service: homeassistant.turn_on
entity_id: switch.Master
I tried changing the Z and M to lower case and made sure that all the ''s are correct. It still doesn’t work. I also tried adding a hyphen to the front but no luck.