I have a motion sensor that I want to use in an automation to trigger a notification but I don’t want to have the notification sent over and over. I would like the automation to trigger once then after say 10 mins be able to be triggered again.
I’ve taken a look at conditions but can’t work out which to use.
In your action section put in a command to turn that automation off, then have a second automation which is triggered by that to turn the original automation back on after 10mins
Do I understand correctly that you have a motion sensor that triggers a lot (every x seconds) and that you only want it to notify you every 10 minutes or so?
I don’t want the motion sensor to keep sending the notifications within a 10 min (or less) period. I do want it to however trigger the first time asap.
The other way you could do it is with a wait template I think. Have a look at the docs under scripts. I’m not good with templates because the docs are terrible to try and learn from
automation:
- alias: Test
trigger:
# Your trigger
- platform: state
entity_id: input_boolean.testbool
to: 'on'
action:
# Disable this automation
- service: automation.turn_off
entity_id: automation.test
# Do stuff
- service: homeassistant.toggle
entity_id: switch.some_switch
# Wait some time and turn the automation back on
- delay:
minutes: 1
- service: automation.turn_on
entity_id: automation.test
If it’s only the notification that you want to suppress then you could do that from the notification action, but my way will also prevent other things acting on the trigger if thats handy
Haven’t tried before but I think that automation will completely stop after it turns itself off and then not be able to do the delay and switch itself back on
Another way to achieve what you want is to create a hidden proxy input boolean that you set to true on every motion detection and use an automation to 1) notify you when set to True, 2) wait for 10 minutes and then set it to False.
input_boolean:
notify_motion:
name: Notify When Motion Detected
initial: off
automation:
- alias: Detect Motion
trigger:
- platform: state
entity_id: binary_sensor.my_motion_sensor
state: on
action:
- service: input_boolean.turn_on
entity_id: input_boolean.notify_motion
- alias: Notify Motion
trigger:
- platform: state
entity_id: input_boolean.notify_motion
state: on
action:
- service: notify.notify
data:
message: 'Motion detected'
- delay: 10:00
- service: input_boolean.turn_off
entity_id: input_boolean.notify_motion
@shire210’s automation will not stop the automation dead in it’s tracks. It is the ‘best way’ to ensure the light doesn’t go off when you are in the room. The current flow continues and it stops the previous one if it exists. Think of it as stopping a timer and restarting it. Basically, it ensures the light stays on with motion and only shuts off when all movement is gone… after a minute.
EDIT: Actually, this will stop the automation, my mind is all jumbled. You’ll have to move the action into 2 scripts.