How would one setup a rule to strobe all the lights on and off in the house if the alarm system is triggered. My idea is if someone enters the home they arent going to know every nook and cranny of your house as well is you do and if the lights strobe, number 1 will make it harder to see if it happens at night and number 2 will also make people think something is up if lights outside the house and strobing as well.
What type of light?
Some have a pulse effect.
Mainly isy connected zwave switches and some tplink switches and lamp plugsā¦ I have a good mix of different thingsā¦ even 1 lifx bulb in the mix as well.
āStrobeā implies a sub-second flashing rate. Owing to the latency in most lighting protocols, youāre unlikely to be able to get a sub-second flashing rate (unless āstrobeā is a native feature of the lighting technology)
More achievable is 1-second-on, 1-second-off. Thatās far from a strobe effect but still quite annoying.
ill take what i can getā¦ lol the question is how would you do this untill the alarm is disarmed.
This is rudimentary and requires refinement. Nevertheless, it demonstrate the principle of using a timer to repeatedly toggle a light.
I donāt know what youāre using to represent your alarm. In this example, itās an input_boolean.
- When
on
it starts a timer calledtimer.looper
(needs to be predefined in the config file). It sets a duration of 1 second. - When
off
it stopstimer.looper
.
- alias: 'Looping Control'
trigger:
platform: state
entity_id: input_boolean.alarm
action:
service_template: >-
{{ 'timer.start' if trigger.to_state.state == 'on' else 'timer.finish' }}
data_template:
entity_id: timer.looper
duration: "{{ 1 if trigger.to_state.state == 'on' else 0 }}"
When the timer starts, it toggles a light.
- alias: 'Looper timer started'
trigger:
- platform: event
event_type: timer.started
event_data:
entity_id: timer.looper
action:
- service: light.toggle
entity_id: light.family
When the timer stops it check if the input_boolean is still on
. If it is, it restarts the timer.
- alias: 'Looper timer finished'
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.looper
condition:
condition: state
entity_id: input_boolean.alarm
state: 'on'
action:
- service: timer.start
entity_id: timer.looper
Thanks for this. Could you possibly advise how to add a line or two that would ensure that the light.family
state tracked the trigger state when the timer finishes?
Iād like to use your code to solve my problem here but when my trigger is off, I need to ensure the input boolean is off too. At the moment its random depending on when the trigger is turned off.
If you want to ensure the toggling light is turned off when the input_boolean is off, probably the easiest way is to add another automation like this:
- alias: 'Looper timer finished 2'
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.looper
condition:
condition: state
entity_id: input_boolean.alarm
state: 'off'
action:
- service: light.turn_off
entity_id: light.family
So now there are two automations that are executed when the timer finishes.
- The first one checks if the input_boolean is on and restarts the timer.
- The second one checks if the input_boolean is off and turns off the light.
Would you be so kind to help - Iām trying this but nothing is hapening.
- Created an input bolean called āpanicā
- I assumed that all here are to be added to āautomations.yamlā
- my test light is ālight.closet_1ā
My log shows that switching the input bolean manually does trigger the automation - but nothing happens with the lightā¦ what did I do wrong?
- alias: 'Looping Control'
trigger:
platform: state
entity_id: input_boolean.panic
action:
service_template: >-
{{ 'timer.start' if trigger.to_state.state == 'on' else 'timer.finish' }}
data_template:
entity_id: timer.looper
duration: "{{ 1 if trigger.to_state.state == 'on' else 0 }}"
- alias: 'Looper timer started'
trigger:
- platform: event
event_type: timer.started
event_data:
entity_id: timer.looper
action:
- service: light.toggle
entity_id: light.closet_1
- alias: 'Looper timer finished'
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.looper
condition:
condition: state
entity_id: input_boolean.panic
state: 'on'
action:
- service: timer.start
entity_id: timer.looper
- alias: 'Looper timer finished 2'
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.looper
condition:
condition: state
entity_id: input_boolean.panic
state: 'off'
action:
- service: light.turn_off
entity_id: light.closet_1
Replying to myself. Seems Home Assistant now support looping natively. I was able to build this using the automation configurator in the UI (Hassio). This works.
- id: '1602585004975'
alias: Home Panic Lights
description: ''
trigger:
- platform: state
entity_id: input_boolean.panic
from: 'off'
to: 'on'
condition: []
action:
- repeat:
until:
- condition: state
entity_id: input_boolean.panic
state: 'off'
sequence:
- service: light.toggle
data: {}
entity_id: light.closet_1
- delay: 00:00:01
mode: single
Used your how to and works great thank you for this.
One question. I have multiply dimmers and lights that work with an on/of switch.
I am wondering if it is possible when activating the loop the dimmable lights turn their brightness to 100%? And when the loop is switched off is it possible to turn all the lights back in the on / off and brightness position the where before the alarm was activated ?
thank you! gr Mark
My previous post in this topic is 1.5 years old. Due to Home Assistantās improvements, I wouldnāt do it that way today (I would use repeat
like lkeays did).
turn their brightness to 100%
Add a brightness parameter to your light.toggle service.
- service: light.toggle
data:
entity_id: light.closet_1
brightness: 255
turn all the lights back in the on / off and brightness position the where before the alarm was activated
Create a scene that includes all of the lights you want to restore in your alarm automation before your light loop (using the repeat method as @123 suggested).
- service: scene.create
data:
scene_id: alarm_triggered_lights_restore
entities:
light.living_room_pot_lights:
state: "{{ states('light.living_room_pot_lights') }}"
brightness: "{{ state_attr('light.living_room_pot_lights','brightness') }}"
light.living_room_cove_light:
state: "{{ states('light.living_room_cove_light') }}"
brightness: "{{ state_attr('light.living_room_cove_light','brightness') }}"
light.kitchen_potlights:
state: "{{ states('light.kitchen_potlights') }}"
brightness: "{{ state_attr('light.kitchen_potlights','brightness') }}"
light.kitchen_sink_light:
state: "{{ states('light.kitchen_sink_light') }}"
Restore that scene when your alarm is disarmed.
- service: scene.turn_on
entity_id: scene.alarm_triggered_lights_restore
thanks for your quick response. I will let you know when it is successful. thank you both very much again