Create Scene too slow

When creating automations, especialy for light management in particular situations, I run into some dependency issues that are hard to solve.

For instance:

I have a light automation that automaticaly switches on the light in my livingroom, depending on wether my input_boolean.overrule is not ON. My outdoor hue motion sensor registeres the number of lux, and if that is below 850 my lights switch on.
the input_boolean.overrule is turned on when we go to bed and it is switched off 6 hours after sunset.
So far so good.

Now if I want to watch a movie during the day I want to dim the lights when I press Play on my Google TV chromecast ultra in the Netflix or Videoland or Ziggo app.
Because I do not know what the state of my lights is (as it is dependend from the lux sensor) I take a snapshot with scene.create woonkamerlichtstaat. And dim the lights with with scene.beamer_scene.

Now here is the deal:
When I press pause (someone needs to go to the bathroom or so) it should restore the state of the lights with activate scene.woonkamerlichtstaat. But if I am too soon with pressing play again it takes a new snapshot with the wrong (dimmed) settings!

And how is HA managaing lights that are in transition when I use a transistion of (lets say) 45 seconds and in the mean time I take a snapshot?

Can anyone help me out?

This is my current automation yaml:

alias: Beamer_Automation
description: ""
trigger:
  - platform: state
    entity_id:
      - media_player.android_tv_192_168_68_112
    id: Off2On
    from: "off"
  - platform: state
    entity_id:
      - media_player.android_tv_192_168_68_112
    to: playing
    id: Any2Playing
  - platform: state
    entity_id:
      - media_player.android_tv_192_168_68_112
    to: paused
    id: Playing2Paused
  - platform: state
    entity_id:
      - media_player.android_tv_192_168_68_112
    to: "off"
    id: Any2Off
condition:
  - condition: template
    value_template: >-
      {{ now() - as_datetime(states('sensor.uptime')) >
      timedelta(days=0,hours=0,minutes=15) }}
    enabled: false
  - condition: not
    conditions:
      - condition: or
        conditions:
          - condition: state
            entity_id: media_player.android_tv_192_168_68_112
            state: unavailable
          - condition: state
            entity_id: media_player.android_tv_192_168_68_112
            state: unknown
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - Off2On
        sequence:
          - service: scene.create
            metadata: {}
            data:
              scene_id: woonkamerlichtstaat
              snapshot_entities:
                - light.woonkamer_koof_1
                - light.woonkamer_koof_2
                - light.woonkamer_koof_3
                - light.woonkamer_koof_4
                - light.woonkamer_koof_5
                - light.woonkamer_koof_6
                - light.woonkamer_koof_7
                - light.woonkamer_koof_8
                - light.woonkamer_hoek_lamp
                - light.woonkamer_servieskast_lamp
                - light.woonkamer_staande_lamp
      - conditions:
          - condition: trigger
            id:
              - Any2Playing
        sequence:
          - service: scene.turn_on
            data: {}
            target:
              entity_id: scene.beamer_scene
          - service: notify.mdb055
            metadata: {}
            data:
              message: >-
                Playing:  {{
                state_attr('media_player.android_tv_192_168_68_112', 'app_name')
                }} now!
          - service: input_boolean.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: input_boolean.overrule
      - conditions:
          - condition: trigger
            id:
              - Playing2Paused
        sequence:
          - service: notify.mdb055
            metadata: {}
            data:
              message: >-
                Pausing:  {{
                state_attr('media_player.android_tv_192_168_68_112', 'app_name')
                }} now!
          - service: scene.turn_on
            metadata: {}
            target:
              entity_id: scene.woonkamerlichtstaat
          - service: input_boolean.turn_off
            target:
              entity_id:
                - input_boolean.overrule
            data: {}
      - conditions:
          - condition: trigger
            id:
              - Any2Off
        sequence:
          - service: scene.turn_on
            data: {}
            target:
              entity_id: scene.woonkamerlichtstaat
mode: single

It doesn’t care about the transition it will record the scene exactly as is when triggered. So if you’re in transition and you trigger the scene… You get what you’re seeing

Im assuming you have a rather long transition here because home theater magic?

How about some kind of mechanism to debounce multi triggers of the scene record. If it was less than 45 seconds (Your longest transition plus margin) since. Last fired ignore the scene storage… It’s 99% sure probably good.

To be clear, I do not make use of a transition of 45 seconds, but that was for a matter of speak to get my question clear. :wink:

However, I have an automation for my home theater and need to make use of android_debug_bridge for my Chromecast Ultra, and that is ‘rather’ slow with updating it’s state, and therefor my scenes are sometimes not snapshotted the right moment, what results in wrong light settings for the wrong moments. Very annoying.

Then your issue isn’t that the scene create is too slow. It’s that the android debug bridge is slow.

There’s nothing that the scene create service can do about that - it’s triggering when it’s supposed to.

Having said that, you have the scene create action tied to the Off2On trigger id, however that trigger will actually trigger when if goes from off to any state, since there’s no to: defined:

  - platform: state
    entity_id:
      - media_player.android_tv_192_168_68_112
    id: Off2On
    from: "off"
    to:   <--- this part is missing

Are you sure it’s not going from off to another state (idle, maybe?), giving you the impression that the scene should be created later?
Can you maybe post the logbook entries from when your Chromecast is in an off state up to when it’s playing?

1 Like

Hi. Thanks for your thoughts.

No, it is correct that the scene snapshot is taken at the moment of Off2On as that is the moment that the status of the lights are ‘as they should on that moment without media playing’.