I’m trying to flash my Philips Hue Playbars red one time when a motion detector detects motion.
I’ve been searching around a bit but can’t find a way to get it working.
I’ve tried to put the following code in automation.yaml but I think I’m missing something.
#automation:
- alias: 'Flash Lights'
trigger:
platform: state
entity_id: binary_sensor.0x00158d00031cd4ef_contact
to: 'on'
action:
service: light.turn_on
entity_id: light.playbar_links
data:
entity_id: light.playbar_links
flash: short
rgb_color: [252,3,3]
I’ll give you the answer. Don’t look until you’re done reading, then check back here to see if you’ve got it.
#automation:
- alias: 'Flash Lights'
trigger:
platform: state
entity_id: binary_sensor.0x00158d00031cd4ef_contact
to: 'on'
action:
- service: scene.create
data:
scene_id: before
snapshot_entities:
- light.playbar_links
- service: light.turn_on
entity_id: light.playbar_links
data:
flash: short
rgb_color: [252,3,3]
- delay: 5
- service: scene.turn_on
entity_id: scene.before
I added a 5 second delay to allow the flash to complete. I don’t know how long the flash will take, so adjust accordingly. Also, add the following to your config if it isn’t there. Otherwise the scene services won’t exist.
You mean you want the automation to be triggered by another sensor? If the type and other parameters of the trigger are the same then you can just add the entity_id:
trigger:
platform: state
entity_id:
- binary_sensor.0x00158d00031cd4ef_contact
- binary_sensor.OTHER_SENSOR
to: 'on'
When either sensor changes to on the automation will trigger.
I try to achieve something similar but currently cannot get it working. The trigger is the second step I want to tackle, starting first with the flashing part. Here is my automation:
My issue is, that actually the light flashed in cold-white light and AFTERWARDS changes to the specified color and stays in that color. Any Idea what I have set up wrong?
Hi, any reason you chose 252,3,3 as RGB color instead of 255,0,0.
In my case I had to add the light simply turning on as red color before doing the flash, as they would otherwise flash white instead of red :
I don’t know why, but using “short” flash does not work with my hue lights, only long works well…
[EDITS] : had tu turn on the light in red then turn it off before launching the flash, otherwise it would flash badly (white if I did not set red before the flashing, and not very nicely if I did not turn it off before flashing).
Also, added a delay just after the scene creation for restoring state, because without that HA would sometimes remember another in-between state…
I copied your code snippet into a script and replaced the entity_id of the light with my own. Unfortunately I get the error message below when trying to save the script.