home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.75k stars 30.87k forks source link

Scenes with a light group snapshot do not activate correctly #126263

Open Airblader opened 1 month ago

Airblader commented 1 month ago

The problem

This is a follow-up for #122165 which has been fixed & closed, but I think something is still not working correctly.

I have an automation that creates a scene using a snapshot, dims the lights, and reactivates the scene later on (to dim the lights while the balcony door is open). In my specific case, they are all Hue lights.

When I create the scene as a snapshot of a light group (with each light having a different color), activating the scene turns on the lights, but sets them all to the same (white, for me) color instead of the correct individual settings.

If, however, I create the scene specifying the individual lights rather than a light group, everything works correctly.

I am attaching an automation that I can trigger manually to reliably reproduce the issue.

What version of Home Assistant Core has the issue?

core-2024.9.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Philips Hue

Link to integration documentation on our website

https://www.home-assistant.io/integrations/hue/

Diagnostics information

No response

Example YAML snippet

- id: test_hue_group_scene
  alias: Test Hue Group Scene
  trigger:
    # Dummy trigger
    - platform: state
      entity_id: media_player.apple_tv
  action:
    - action: scene.create
      data:
        scene_id: hue_group_test
        snapshot_entities:
          - light.couch
          # Using individual lights instead works:
          # - light.couch_1
          # - light.couch_2
          # - light.couch_3
          # - light.couch_4

    - delay: '00:00:03'
    - action: light.turn_off
      entity_id: 
        - light.couch 

    - delay: '00:00:03'
    - action: scene.turn_on
      entity_id: scene.hue_group_test
    - action: scene.delete
      data:
        entity_id: scene.hue_group_test

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 month ago

Hey there @balloob, @marcelveldt, mind taking a look at this issue as it has been labeled with an integration (hue) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `hue` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign hue` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


hue documentation hue source (message by IssueLinks)

Grandma-Betty commented 1 month ago

Same problem here.

marcelveldt commented 1 month ago

If you want to have different colors in a scene, you need the individual lights in the scene and not the group.

Airblader commented 1 month ago

Is that a hard limitation, or just a feature request rather than a bug?

Grandma-Betty commented 1 month ago

Here is my specific example which is facing the issue: I have an automation where a light scene is being generated dynamically as soon as someone hits the main door ring bell. This scene is taking a snapshot of the Hue light bulbs current state. After the scene is being created, the lights starts to blink using the “breathe” effect (which is done via mqtt.publish action). After blinking the lights should get into their previous state at the moment when the snapshot was taken.

(Just for explanation: The idea behind this is that the Hue lights should singalize optically whenever someone is ringing the main door bell because there are some areas in our house where you just cannot hear the main door ring bell.)

As suggested by @marcelveldt, for taking the dynamic scene snapshot, I use the individual lights instead of the group, but this does not solve the issue I am facing. The automation works so far but the ugly limitation here is that when the scene is being activated at the last step of the automation, the color and brightness do not match the previous state.

Here's the code of the script which is being triggered by the automation after someone hits the main door ring bell:

alias: ScriptLightNotifications
sequence:
  - action: scene.create
    data:
      scene_id: scene_scriptlightnotifications_lights_previous_state
      snapshot_entities:
        - light.huecolorlightstripplus02
        - light.huecolorlightstripplus03
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - action: mqtt.publish
    data:
      qos: 0
      retain: false
      topic: zigbee2mqtt/Z2MGroup_huecolorlightstripsplus/set
      payload: "{\"scene_recall\": 1, \"effect\": \"breathe\"}"
  - delay:
      hours: 0
      minutes: 0
      seconds: 8
      milliseconds: 0
  - action: scene.turn_on
    data: {}
    target:
      entity_id: scene.scene_scriptlightnotifications_lights_previous_state
mode: single
TylonHH commented 1 month ago

This is my scene.yaml

- id: '1728732702977'
  name: Flur Hell
  entities:
    light.flur_gruppe:
      brightness: 255
      color_temp_kelvin: 2700
      state: 'on'

The brightness change as expected. But the color_temp is not set.

The attributes of this group

min_color_temp_kelvin: 2202
max_color_temp_kelvin: 6535
min_mireds: 153
max_mireds: 454
effect_list: blink, breathe, candle, channel_change, finish_effect, okay, stop_effect, stop_hue_effect
supported_color_modes: color_temp
effect: null
color_mode: color_temp
brightness: 150
color_temp_kelvin: 3649
color_temp: 274
hs_color: 27.037, 41.629
rgb_color: 255, 196, 148
xy_color: 0.444, 0.371
entity_id: light.hue_flur_1, light.hue_flur_2, light.hue_flur_3
icon: mdi:lightbulb-group
friendly_name: Flur Gruppe
supported_features: 44

Setting the color_temp_kelvin to 2700 manual works fine. But when turn_on scene the color_temp_kelvin is set 3649