Light Scripting Problem - Possibly User Error

Hi there,

I’ve got a problem I just can’t get my head around. I’ve got a script that I want to use to flash my lights red, when I’m out and motion is detected in the house, i.e. part of an Alarm type setup.

So on running the script to test, it flashes the light but does not change it to red. I’ve tried this with both the “RGB-Color” and “Color name” data types, with no difference, the light flashes white. I’m using Hue Colour Ambience bulbs by the way.

But then strangely, after the test, when I turn the light on normally, it comes on Red. What am I missing please? Here’s the script, with the rgb_color type: -

alarm_flash_the_inside_lights:
  alias: Alarm Flash the Inside Lights Red-Off
  sequence:
  - repeat:
      while:
      - condition: state
        entity_id: alarm_control_panel.ha_alarm
        state: armed_away
      sequence: []
  - service: light.turn_on
    data:
      rgb_color:
      - 255
      - 0
      - 0
      brightness_pct: 100
      flash: long
    target:
      entity_id:
      - light.amys_light
      - light.hallway_light1
      - light.hallway_light2
      - light.landing_light
      - light.mias_light
      - light.spareroom_lamp
      - light.spareroom_light
  mode: single

Did you try with 2 actions, 1st that set the color, and a 2nd that flashes?
I suspect having both in the same action will only pick the flashing.

@koying No I didn’t try that, will give it a go, thanks.

Hello I have a quation to this.

With to action:

service: light.turn_on
data:
  color_name: blue
target:
  entity_id: light.mondo_wand
service: light.turn_on
data:
  flash: long
target:
  entity_id: light.mondo_wand

It works. That the color go to blue and flashing.

But I have one problem, if the light is on before the script start for example in color green. After the flashing is the color still blue. How can I make it show the old color again after flashing?

I do this with a few automations. At the end of the automation just restore the color before turning them off. The color change persists and then when you turn on the color is there.

It’s that our when you have a switch turn them on you set them to soft white or whatever you want.

Here is an example for my water alarm

For an alarm though I would suggest making an input Boolean for alarm tripped and then do two automations. One to trigger it and one to clear it.

Similar to my goal lights.

Hello,
I’m not sure if it gets it right.

But if so, you turn on the light afterwards, with a defined color, not with the color that was on before or?

And if the light are off before it turns on the alarm, after the alarm, the light is also on or?

What I want is:
if the light is off, the alarm come and put on the light in blue, after the alarm, the light goes off.
if the light is on for example green or a other color, the alarm come and the light switch to blue, after the alarm, the light goes back to the color before.

Yeah I keep it simple and use conditions but if you want that kind of activity, then you need to use scenes. You would fire the automation, create a scene, do your light blink, then restore the scene afterwards. That would be a way to get to a single automation without having multiple that are condition based.