Scenes and Groups

Hi Everyone,

I’m not sure if I’m doing this wrong – I checked the help for ‘Entities’ and ‘Scene’ to make sure I’m doing this right but it appears it’s not working (no errors, even if formatting looks wonky here); here’s my config:

configuration.yaml

scene:
- name: Cool White
  entities:
    light.living_room_east_lamp: on
    light.living_room_west_lamp:
      state: on
      rgb_color: [255,207,120]
      brightness: 255
      color_temp: 153
      xy_color: [0.4575,0.4099]
- name: Relax
  entities:
    group.livingroom_lights:
      state: on
      rgb_color: [243,179,80]
      brightness: 144
      color_temp: 447
      xy_color: [0.5019,0.4152]

Can scenes be applied to groups? In this case, here’s the group I’m targetting:

groups.yaml

group:
  livingroom_lights:
    name: Living Room Lights
    entities:
      - light.living_room_east_lamp
      - light.living_room_west_lamp

I tried both by specifying individual lights and the group that contains both lights but I can’t get the scene to trigger any change for those lights.

Do I need an automation to trigger the scene change? I do have a group/card in the default view with the scenes listed and I figured if I click “Activate” it would do something but it doesn’t do anything.

Not sure what I’m missing here.

I think having xy_color, color_temp & rgb all in the config is the issue.

If you just want a color, then set just the brightness and rgb value like this (one of my scenes);

- name: Evening Lights
  entities:
    light.steps:
      state: on
      brightness: 60
      rgb_color: [225,167,255]
      transition: 3
    light.table:
      state: on
      brightness: 60
      rgb_color: [225,167,255]
      transition: 3

For just “white” type lights, use this;

- name: Kitchen On
  entities:
    light.k1:
      state: on
      brightness: 230
      color_temp: 204
      transition: 3
    light.k2:
      state: on
      brightness: 230
      color_temp: 204
      transition: 3

Tried as you suggested; clicking activate on the scene doesn’t do anything. Doesn’t matter if it’s group-based or individual light based; I’m going to try a single light and see how it works out.

Actually you’re right – once I dropped all THREE of the statements you mentioned, the scenes now activate :slight_smile: Now to get it working from input_select :slight_smile: Thanks!

1 Like

Awesome, glad it is working! Mark as solved if you can as well.

Just in case anyone is interested, found this in another post on the forum to switch scenes based on input_select list (I copied all the Hue scenes from the Android app into HASS; ie: Relax, Arctic Aurora, etc):

automations.yaml

- alias: Living Room Scene
  trigger:
    platform: state
    entity_id: input_select.livingroom_scene
  action:
    - service: scene.turn_on
      data_template:
        entity_id: scene.{{ states.input_select.livingroom_scene.state | replace(' ', '_') | lower | string }}

configuration.yaml

input_select:
livingroom_scene:
name: Scene
options:
  - Arctic Aurora
  - Bright
  - Concentrate
  - Cool White
  - Dimmed
  - Energize
  - Nightlight
  - Read
  - Relax
  - Savanna Sunset
  - Spring Blossom
  - Tropical Twilight
initial: 'Cool White'
icon: mdi:palette

Works great!

edit: added input_select code for reference.

3 Likes

HI @chrisw

how do you set the hue.scene with this code, and, where’s you’re connection to the actual lights?

I have several Hue groups i would like to add this selector to but need the interlinking logic…

there must some hue.set_hue_scene code but cant seem to find it?

Cheers,
Marius

I don’t use the hue.set_hue_scene, I manually created HA scenes using the hue app on my phone and watching the config change in HA dev panel. In the first post you can see two scenes I’ve copied. From there, I use the snippets above (input_select) and the automation to dynamically select the scene based on value from input_select

ok ill hav a look.

tw this is what i was looking for:

scene_[scene_name]:
  alias: Name
  sequence:
    - service: hue.hue_activate_scene
      data:
        group_name: "[group_name]"
        scene_name: "[scene_name]"

use the known scenes:

  • Arctic Aurora
  • Bright
  • Concentrate
  • Cool White
  • Dimmed
  • Energize
  • Nightlight
  • Read
  • Relax
  • Savanna Sunset
  • Spring Blossom
  • Tropical Twilight

no need to create manually anymore

I know I can use the scenes from the hub but I read somewhere that to make room, the hub will remove least-used objects to make space meaning they could be deleted. Was easier to copy them plus it allows me to alter them as I see fit from within HA rather than the app.

thanks,

interested to see what you’ll end up with as a full set. Maybe create a package?

would be cool to have the same logic automatically work based on the group_name, and not have to code it all for all groups separately. some extra templating would be needed.

I may try to adapt the existing stuff to use hue built-in scenes but based on what’s in the thread, you may be able to beat me to it (everything is here) – I’m pretty happy with what it is now but I have noticed it doesn’t update with what is currently on the hub (ie; my wife changes it with the app, HA doesn’t adapt display-wise) so I may need to refactor it anyways :slight_smile:

testing this as we type for each group i have:

automation:
- alias: Dining Table Scene
  trigger:
    platform: state
    entity_id: input_select.select_hue_scene_dining_table
  action:
    - service: hue.hue_activate_scene
      data: 
        group_name: dining_table
      data_template:
        entity_id: scene.{{ states.input_select.select_hue_scene_dining_table.state | replace(' ', '_') | lower | string }}

input_select:
select_hue_scene_dining_table:
  name: Hue Scene Dining table
  icon: mdi:palette
  options:
  - Arctic Aurora
  - Bright
  - Concentrate
  - Cool White
  - Dimmed
  - Energize
  - Nightlight
  - Read
  - Relax
  - Savanna Sunset
  - Spring Blossom
  - Tropical Twilight
  initial: 'Relax'

lets see what happens

----edit-----

hmmm. nothing much yet, other than kill Hassio…?? suddenly getting a supervisor error ive never seen before.

quickly turning back…

1 Like

Try perhaps:

action:
    - service: hue.hue_activate_scene
      data:
        group_name: dining_table
        scene_name: scene.{{ states.input_select.select_hue_scene_dining_table.state | replace(' ', '_') | lower | string }}

should be a template shouldn’t it? Better this?

action:
    - service: hue.hue_activate_scene
      data_template:
        group_name: dining_table
        scene_name: scene.{{ states.input_select.select_hue_scene_dining_table.state | replace(' ', '_') | lower | string }}

Try both :slight_smile: I’m still pretty new to HA and learning as I go! If you find a solution, that’d be great.

edit: I was reading this which is why I did it in the syntax I did:


edit: also states the group_name is not the HA group name we’d use but the name in the Hub. In my HA, it pulls in the Hub groups, ie: light.kitchen or light.mudroom

this is better, though im having an error reporting more groups with the same name. Which might be true, cause the Hue Hub creates its own groups. Have t check those, will be for tomorrow though :wink:

data_template: 
        group_name: dining_table
        scene_name: '{{ states.input_select.select_hue_scene_dining_table.state}}'

I’m wondering if this is working for anyone else. I was able to get the config to change the scene, but only certain scenes work when triggered from HA.

The working code:
data_template: group_name: Office scene_name: {{ states.input_select.office_scene.state }}

In my case Read, Concentrate, Savanna sunset, Tropical twilight, and Spring blossom all work fine, but Energize, Relax, Dimmed, Arctic aurora, and Nightlight do not work.

talking Philips Hue now:
as of the latest Hassio firmware upgrades, the hue.hue_activate.scene in Hassio is crippled (among other issues) and has something to do with identically named scene for multiple groups.

Your issue sounds very close to that…

Since it works perfectly from within the Philips Hue App, we can be at least assured the Hue system itself works just fine

maybe you can use this, which works perfectly, when Hue is well integrated in Hassio (which it now isnt…)

script:
  set_hue_scene:
    alias: Set Hue scene
    sequence:
      - service: hue.hue_activate_scene
        data_template:
          group_name: '{{ states.input_select.hue_groups.state }}'
          scene_name: '{{ states.input_select.hue_scenes.state }}'

group:
  hue_light_control:
    name: Hue Light Control
    icon: mdi:spotlight
    entities:
      - input_select.hue_scenes
      - input_select.hue_groups
      - script.set_hue_scene
      - input_boolean.party_mode

input_select:
  hue_scenes:
    name: Select Hue Scenes
    icon: mdi:creation #palette
    options:
      - Arctische dageraad
      - Savanne zonsondergang
      - Tropische schemering
      - Lentebloesem
      - Concentreren
      - Gedimd
      - Energie
      - Helder
      - Lezen
      - Nachtlampje
      - Ontspannen
    initial: Savanne zonsondergang

  hue_groups:
    name: Select Hue Group
    icon: mdi:group
    options:
      - Buffet
      - Dining table
      - Terrace
      - Auditorium
      - Hall
      - Corridor
      - Master bedroom
      - Mobile
2 Likes

I know this is an older thread, but I would be interested in knowing if anyone has worked out the formula Hue use to create scenes, or at least the XY Color codes per globe?
I am interested in migrating all the scenes into Home Assistant, not just for use with Philips Hue globes, but also so they are available with other color globes, including WiFi ones, that can not utilise the Hue Bridge at all.

Ultimately, I want to use the scenes purely in HA so I can actually decommission the Hue Bridge fully given the ZHA component supports Hue Globes and there are components to use the REST API and other options for all Hue accessories to work in HA without a Hue Bridge.