Dynamic scene - save state of all lights from Hue room

I have several Hue lamps in a room that are controlled as a group to turn on/off, but several lights can also be separately controlled with Tap Switch. Mostly for brightness, sometimes also color.

  • I use Hue integration in the HA, with Hue bridge
  • I mostly control rooms/zones exposed via Hue integration. Reason is that HA integration isn’t the best when you have to control several lights at once, and it is better to define room/scene in the Hue and control the room/zone from HA instead.

When automation happens, I’d like to put all lights in a room to defined state, and beforehand save the state (dynamic scenes) that can be restored after the automation expires.

In the below automation, light.home represent zone of several lights. These can be nicely controlled as a group to turn on/off from HA.

Problem is that when I save the dynamic scene, restoring it will put all lights to the same state (same color, brightness, …) and not each back to the state it was just before automation fired.

  • Is it possible to capture the state of full room/zone in the HA (maybe with the help of Hue bridge?) or do I simply need to list all the targets one-by-one at the capturing state?
  • Is it possible to use the HA room (not the Hue exposed room) entity, that would capture all lights from that room?

My test automation:

trigger:
  - platform: device
    domain: mqtt
    device_id: 58b9e3172644e53a8d0883a42b5bc80e
    type: action
    subtype: button_3_press_release
condition: []
action:
  - service: scene.create
    metadata: {}
    data:
      scene_id: temporary_scene_current_state
      entities: {}
      snapshot_entities:
        - light.home
  - service: light.turn_on
    metadata: {}
    data:
      rgb_color:
        - 0
        - 170
        - 255
      brightness: 255
    target:
      entity_id: light.home
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - service: scene.turn_on
    target:
      entity_id: scene.temporary_scene_current_state
    data: {}
mode: single