Trouble with creating scene on the fly, flash lights, then restore scene

I’m working on setting up an automation when a certain NHL team scores, my lights flash red and then go back to their previous state. I have it successfully triggering and flashing red, but it isn’t reverting the light to it’s previous color and brightness, it stays red. Below is the script that I’m calling from the automation:

blackhawksgoal:
  sequence:
    - service: scene.create
      data_template:
        scene_id: before
        snapshot_entities:
          - light.couch_left:
    - service: light.turn_on
      data:
        entity_id: light.couch_left
        brightness: 255
        rgb_color: [255, 0, 0]
        flash: long
    - delay:
        seconds: 20
    - service: scene.turn_on
      data:
        entity_id: scene.before

Here is the documentation I was following for creating scenes on the fly - https://www.home-assistant.io/integrations/scene/#creating-scenes-on-the-fly

Try removing the colon at the end of the entity.

1 Like

Doh! Thanks, not sure how I missed that.

1 Like

No problem - a fresh set of eyes always helps.

1 Like

Hello everyone, trying to do the similar thing, but after restoring scene “before”, light brightness remains low. Here’s the full automation. Let’s imagine - I manually set the light.strop_zvonka to 80%, then turn off the light (toggle). Then the automation below triggers, turn on the light to 20%, after minute turn off and restore scene. Then when I turn on the light manually, it’s not restored to 80%, but remains on 20%… Any suggestions? Thanks!

alias: Obyvacka svetlo vecer
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.pir_obyvacka
    to: 'on'
condition:
  - condition: numeric_state
    entity_id: sensor.tasmota_analog_a0
    below: '300'
action:
  - service: scene.create
    data:
      scene_id: before
      snapshot_entities:
        - light.strop_zvonka
  - service: light.turn_on
    data:
      transition: 5
      brightness_pct: 20
    target:
      entity_id: light.strop_zvonka
  - wait_template: ''
    timeout: '00:01:00'
  - service: light.turn_off
    data:
      transition: 5
    target:
      entity_id: light.strop_zvonka
  - service: scene.turn_on
    target:
      entity_id: scene.before
mode: single

I too am having this problem.

A single Hue colour ambiance bulb (connected via Hue hub/integration) and I cannot get it to restore to the previous state after flashing red. With the following script, it always turns back on with red/brightness 1.

- alias: Flash office globe red when alarm mode enabled
  trigger:
  - platform: state
    entity_id: input_boolean.alarm_mode
    to: 'on'
  action:
  - service: scene.create
    data:
      scene_id: before
      snapshot_entities:
      - light.office_globe
  - delay: '00:00:01'
  - service: light.turn_on
    entity_id: light.office_globe
    data:
      rgb_color: [255,0,0]
      brightness: 1
      transition: 0
  - service: light.turn_off
    entity_id: light.office_globe
    data:
      transition: 0
  - service: light.turn_on
    entity_id: light.office_globe
    data:
      flash: long
      rgb_color: [255,0,0]
      brightness: 255
      transition: 0
  - delay: '00:00:01'
  - service: scene.turn_on
    entity_id: scene.before
  mode: single

Have searched all the discussions on this topic and tried multiple scripts (with varying delays etc), but to no avail.

Does anybody have this working as intended?

I also had the problem that the scene did not restore. I think the first example here is wrong (or outdated). So if you still have the problem or someone else finds this thread. The following change did the trick at least for me:

    - service: scene.turn_on
      target: 
        entity_id: scene.before

It’s also documented with the „target“ option here: Scenes - Home Assistant

I am also having a similar issue, I have 2 separate automation and both have the same issue.

This one, takes a snapshot of the current state of room lights, calls it “scene.masterbedroom_currentstate” , then loads a scene “Blue DoorBell” (otherwise the routine starts with white) tells it to flash for 5 seconds then restore to the scene. But I get two different outcomes, depending on if the trigger starts with the lights on or off.

If there are already on, then the scene restores ok, if they are off when it triggers, then next time the bulbs are turned on they are at 1% brightness and then blue.

If you try and add a “white” scene at the end, you get a white flash before it completes, not sure how to fix this different outcomes depending on the on/off state.

alias: 'Doorbell Pressed Flash  Master Bedroom Light Blue '
description: ''
trigger:
  - platform: device
    device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    domain: nest
    type: doorbell_chime
condition: []
action:
  - service: scene.create
    data:
      scene_id: masterbedroom_currentstate
      snapshot_entities:
        - light.master_bedroom_main_light
        - light.innr_masterbedroom_lighstrip
  - service: scene.turn_on
    target:
      entity_id: scene.blue_doorbell
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 500
  - service: light.turn_on
    target:
      entity_id: light.innr_masterbedroom_lighstrip
    data:
      brightness_pct: 100
      rgb_color:
        - 0
        - 0
        - 255
      flash: long
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 1
  - service: light.turn_off
    target:
      entity_id: light.innr_masterbedroom_lighstrip
  - service: scene.turn_on
    target:
      entity_id: scene.masterbedroom_currentstate
mode: single
max: 5

still no fix for this sadly

anybody got this working correctly?