Scene.create just doesnt seem to be working

I have an alexa timer automation. The script is being created but its just nothing similar to the state of the lights before the automation started. Very odd. I’m using a blueprint so I’ve c&p from “shot trace, automation config”

I’ve also set up scripts to create the scene, then just tried applying the scene, and its still all wrong.

trigger:
  - platform: state
    entity_id: sensor.bedroom_dot_next_timer
condition:
  - condition: not
    conditions:
      - condition: state
        state: unavailable
        entity_id: sensor.bedroom_dot_next_timer
action:
  - delay: >
      {% set index = (((state_attr(timestamp_sensor, 'sorted_active') |
      from_json)) | list | length) - 1 %} {{ ((state_attr(timestamp_sensor,
      'sorted_active') | from_json)[index][1].remainingTime/ 1000)| round(0) }}
  - condition: not
    conditions:
      - condition: state
        entity_id: sensor.bedroom_dot_next_timer
        state: unavailable
  - condition: template
    value_template: '{{ as_timestamp(states(timestamp_sensor)) - as_timestamp(now()) < 0| int}}'
  - choose: null
    default:
      - service: scene.create
        data:
          scene_id: timer_flash_snapshot_two
          snapshot_entities: group.all_lights
      - delay:
          hours: 0
          minutes: 0
          seconds: 1
          milliseconds: 0
      - repeat:
          until:
            - condition: state
              entity_id: sensor.bedroom_dot_next_timer
              state: unavailable
          sequence:
            - service: script.1639139959907
      - service: light.turn_on
        target:
          area_id:
            - bedroom
            - kitchen
            - office
        data:
          brightness_pct: 100
      - wait_for_trigger:
          - platform: state
            entity_id: sensor.bedroom_dot_next_timer
            attribute: status
            from: 'ON'
            to: 'OFF'
      - service: scene.turn_on
        data:
          transition: 1
        target:
          entity_id: scene.timer_flash_snapshot_two

Are you sure you can snapshot groups like that? Have you tried snapshotting a single light from the light domain? You can always make a light group (rather than simply a “group”) so that you could use light.all_lights rather than group.all_lights

Have changed that. Just listed all of the entities separately, still no luck.

variables:
  timestamp_sensor: sensor.bedroom_dot_next_timer
trigger:
  - platform: state
    entity_id: sensor.bedroom_dot_next_timer
condition:
  - condition: not
    conditions:
      - condition: state
        state: unavailable
        entity_id: sensor.bedroom_dot_next_timer
action:
  - delay: >
      {% set index = (((state_attr(timestamp_sensor, 'sorted_active') |
      from_json)) | list | length) - 1 %} {{ ((state_attr(timestamp_sensor,
      'sorted_active') | from_json)[index][1].remainingTime/ 1000)| round(0) }}
  - condition: not
    conditions:
      - condition: state
        entity_id: sensor.bedroom_dot_next_timer
        state: unavailable
  - condition: template
    value_template: '{{ as_timestamp(states(timestamp_sensor)) - as_timestamp(now()) < 0| int}}'
  - choose: null
    default:
      - service: scene.create
        data:
          scene_id: timer_flash_snapshot_two
          snapshot_entities:
            - light.bedroom_light
            - light.office_main_light
            - light.dining_room_light
            - light.kitchen_light
      - delay:
          hours: 0
          minutes: 0
          seconds: 1
          milliseconds: 0
      - repeat:
          until:
            - condition: state
              entity_id: sensor.bedroom_dot_next_timer
              state: unavailable
          sequence:
            - service: script.1639139959907
      - service: light.turn_on
        target:
          area_id:
            - bedroom
            - kitchen
            - office
        data:
          brightness_pct: 100
      - wait_for_trigger:
          - platform: state
            entity_id: sensor.bedroom_dot_next_timer
            attribute: status
            from: 'ON'
            to: 'OFF'
      - service: scene.turn_on
        data:
          transition: 1
        target:
          entity_id: scene.timer_flash_snapshot_two
mode: single
id: '1639140214561'
alias: Timer Flash - Bedroom Dot
description: ''

This seems wrong to me… why do you have a choose block with null, then a default sequence? Can you just delete that choose block since it seems you always want to execute the default sequence?

Hmmm, doesnt show in config.

This is what’s in my automations.yaml:

- id: '1639140214561'
  alias: Timer Flash - Bedroom Dot
  description: ''
  use_blueprint:
    path: Do something when Alexa timer expires.yaml
    input:
      echo_device_next_timer: sensor.bedroom_dot_next_timer
      target_action:
      - service: scene.create
        data:
          scene_id: timer_flash_snapshot_two
          snapshot_entities:
          - light.bedroom_light
          - light.office_main_light
          - light.dining_room_light
          - light.kitchen_light
      - delay:
          hours: 0
          minutes: 0
          seconds: 1
          milliseconds: 0
      - repeat:
          until:
          - condition: state
            entity_id: sensor.bedroom_dot_next_timer
            state: unavailable
          sequence:
          - service: script.1639139959907
      - service: light.turn_on
        target:
          area_id:
          - bedroom
          - kitchen
          - office
        data:
          brightness_pct: 100
      - wait_for_trigger:
        - platform: state
          entity_id: sensor.bedroom_dot_next_timer
          attribute: status
          from: 'ON'
          to: 'OFF'
      - service: scene.turn_on
        data:
          transition: 1
        target:
          entity_id: scene.timer_flash_snapshot_two

And this is the contents of the blueprint I’m using:

blueprint:
  name: Do something when Alexa Timer has expired
  description: When a timer of an Echo or other Alexa device has expired, the defined
    actions will be executed.
  domain: automation
  input:
    echo_device_next_timer:
      name: Alexa Device
      description: Please select a sensor.*_next_timer entity to define the observed
        Alexa Device.
      selector:
        entity:
          domain: sensor
          device_class: timestamp
    target_action:
      name: Action
      description: What should be done, when the timer expires?
      selector:
        action: {}
  source_url: https://community.home-assistant.io/t/do-something-when-alexa-timer-has-expired/255827
variables:
  timestamp_sensor: !input 'echo_device_next_timer'
trigger:
- platform: state
  entity_id: !input 'echo_device_next_timer'
condition:
- condition: not
  conditions:
  - condition: state
    state: unavailable
    entity_id: !input 'echo_device_next_timer'
action:
- delay: '{% set index = (((state_attr(timestamp_sensor, ''sorted_active'') | from_json))
    | list | length) - 1 %} {{ ((state_attr(timestamp_sensor, ''sorted_active'') |
    from_json)[index][1].remainingTime/ 1000)| round(0) }}

    '
- condition: not
  conditions:
  - condition: state
    entity_id: !input 'echo_device_next_timer'
    state: unavailable
- condition: template
  value_template: '{{ as_timestamp(states(timestamp_sensor)) - as_timestamp(now())
    < 0| int}}'
- choose:
  default: !input 'target_action'
mode: parallel
max: 10

Can you try using the developer options to just call the scene.create and scene.turn_on actions and test them out? I’m thinking this may be an issue with the blueprint.

- service: scene.create
        data:
          scene_id: timer_flash_snapshot_two
          snapshot_entities:
          - light.bedroom_light
          - light.office_main_light
          - light.dining_room_light
          - light.kitchen_light
- service: scene.turn_on
        data:
          transition: 1
        target:
          entity_id: scene.timer_flash_snapshot_two

Very odd. It worked a couple of times, and then stopped working!

After some testing, it seems like it works in the developer tools section, but only for lights that are currently ON. Otherwise they’re not included.

But it still doesnt work in any scripts, or automations.

This is really weird. I just tested and it works perfectly for me-- if a light is OFF when I take a snapshot, it gets turned back OFF when I turn the scene on.

Really weird isnt it. Do you have alexa media?

I don’t. I simply tested scene creation/application in developer tools to confirm that it captured “off” state correctly for me.

AHA! I only tested with a single light entity. However, if I use two lights, where one of them if OFF and one of them is ON, it does not capture the state of the OFF light. You can go and look at the state of the scene entity and the OFF light is simply missing.

I think it’s time to submit a bug.

Edit: and now I can’t recreate this behavior-- everything is working correctly.

As a test, can you try changing the name of the scene you’re creating and activating?

I use this all the time, works perfectly. Are you sure your lights have states associated with them?

Does this help? Sorry, I’m new!