Find error in HUe scene automation Template

HI,

This code is giving errors in the data fields, can you spot what im doing wrong? Thanks for checking:

automation:
- alias: Dining Table Scene
  trigger:
    platform: state
    entity_id: input_select.select_hue_scene_dining_table
  action:
    - service: hue.hue_activate_scene
      data_template: 
        group_name: dining_table
        scene_name: '{{ states.input_select.select_hue_scene_dining_table.state}}'


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'

I do something almost identical to this…

link removed

Input _select is at the top, automation and script near the bottom. And then the script can also be called from elsewhere.

Note that the scene name in the input_select has to match the scene name on the hub exactly (including case).

Hope this helps.

1 Like

NIce!

Always tricky to find the optimal solution between automations scripts and scenes … I like the script setting the scene and group from init_selects, exactly what i was looking for.

Cheers,
Marius

1 Like

so , just to economize, (ill leave the hand made scenes for later, and only use the Hue scenes)

ill only need this?:

input_select:
  dining_table_scenes:
    name: Scenes
    options:
      - Select
      - Arctic aurora
      - Bright
      - Concentrate
      - Dimmed
      - Energize
      - Nightlight
      - Read
      - Relax
      - Savanna sunset
      - Spring blossom
      - Tropical twilight
    initial: Select
    icon: mdi:creation

automation:
  - alias: Reset scene selector - Dining-table
    initial_state: 'on'
    trigger:
      platform: state
      entity_id: light.dining_table
      to: 'off'
    condition:
      condition: template
      value_template: "{{ not is_state('input_select.dining_table_scenes' ,'Select') }}"
    action:
      service: input_select.select_option
      data:
        entity_id: input_select.dining_table_scenes
        option: Select

  - alias: Trigger scene - Dining table
    initial_state: 'on'
    trigger:
      platform: state
      entity_id: input_select.dining_table_scenes
    condition:
      condition: template
      value_template: "{{ not is_state('input_select.dining_table_scenes' ,'Select') }}"
    action:
      service: script.set_hue_scene
      data_template:
        group: "Dining table"
        scene: '{{ states.input_select.dining_table_scenes.state }}'


script:
  set_hue_scene:
    sequence:
      - service: hue.hue_activate_scene
        data_template:
          group_name: '{{ group }}'
          scene_name: '{{ scene }}'

The group name makes we doubt, what should i put in the set_hue_scene {{group}} , this is my Hue group:

do i call the friendly_name between " " , or the entity name light.dining_table, or just dining_table.

In the latter case, it might interfere with the group name ive created for displaying in HA frontend…

46

group:
  dining_table_lights:
  name: Dining table
  icon: mdi:silverware
  entities: &dining_table_group_entities
    - input_select.select_hue_scene_dining_table
    - light.dining_table_lamp_1
    - light.dining_table_lamp_2
    - light.dining_table_lamp_3

…

this is the error i get on all groups, which is very odd, since i have only 1 entity per name:

run_scene: More than 1 group found by name light.dining_table

Cheers,
Marius

It’s the group name on your hue hub, which I would guess is “Dining table”.

correct. Go it working alright! Had to go into the Hub Api though to find out why some of the Hue scenes weren’t recognized. Some where in English and some in Dutch. Most of them both…

Created a translated setup and rebooting as we write.

Still figuring out if its best to use the group name if there;s only 1 lamp in it, and not use the lamp-name. Any thoughts on that?

Another code optimization i would strive for is an automatic group name template in the automations.
As it is now, i have both automations for all of my 6 groups, which seems a bit much.
I have a selector in each group, so in total i have 6 selectors, 12 automations, and 1 script…

I like the efficiency of the 1 script :wink:

Surely adding some sort of extra selector for the group, could render this to be more efficient?

Select group, then select scene, and run script.

Cheers,
Marius

Sure. I only have one group of lights that are coloured so that’s just what I ended up with.

If you wanted one card for all the groups and all the scenes the most efficient way would be to get rid of all the automations completely and have a card with 2 input_selects and the script on it,something like:

input_select:
  hue_scenes:
    name: Scenes
    options:
      - Arctic aurora
      - Bright
      - Concentrate
      - Dimmed
      - Energize
      - Nightlight
      - Read
      - Relax
      - Savanna sunset
      - Spring blossom
      - Tropical twilight
    icon: mdi:creation

  hue_groups:
    name: Group
    options:
      - Dining table
      - Bedroom
      - Living room
      - Kitchen
    icon: mdi:home


script:
  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:
  Light Control:
    - input_select.hue_scenes
    - input_select.hue_groups
    - script.set_hue_scene

Then you just set the scene, set the room and hit activate.

1 Like

well this turned out nicely.

Created the following small package, and all lights are behaving as they should.
Accordign to the Hue Api reporting, even the white ambiance lamps support the colored Scene, which is a bit surprising f course, but I havent bothered to create separate scripts or scenes for the colored and non colored lights because of that.

I would like to see if i can somehow manage to show a .png instead of an mdi:icon in the group, because i like that better…more obvious Hue also…

One other thing i’m looking for now is to have a sensor display the state of the currently activated scene on a group.
I can change scene on my iPhone, and would like to have that reflected in the HA frontend also.

01

Package:

30
##########################################################################################
# Small package for selecting and activating Hue scenes and groups
# 02102018
##########################################################################################

homeassistant:
  customize:
    script.set_hue_scene:
      icon: mdi:power

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_select:
  hue_scenes:
    name: Select Hue Scenes
    icon: mdi:creation #palette
    options:
      - Select
      - Arctische dageraad
      - Savanne zonsondergang
      - Tropische schemering
      - Lentebloesem
      - Concentreren
      - Gedimd
      - Energie
      - Helder
      - Lezen
      - Nachtlampje
      - Ontspannen
      - Relax
    initial: Select

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

Cheers,
Marius

1 Like

@anon43302295

hi, back for another question please:
next to the above i have a few scenes id like to trigger separately . They seem to reach the appropriate lights, but the colors aren’t set correctly .
The numbers are right, because taken from the reading the lights give me when i set them with the app.

What could be wrong do you think? do i need to enter it differently in the scenes? I’ve already commented out the rgb’s cause they conflict with the color_temp. Maybe put these back and take out color_temp? please have a look?

- name: Bedside naar bed
  entities:
    light.bedside_table:
      state: on
      transition: 4
      brightness: 37
      color_temp: 153
#      rgb_color: [171,58,22]

- name: Kist opstaan
  entities:
    light.kist:
      state: on
      transition: 4
      brightness: 199
      color_temp: 153
#      rgb_color: [255,93,42]

- name: Dining table selamat makan
  entities:
    light.dining_table_lamp_1:
      state: on
      transition: 4
      brightness: 206
      color_temp: 443
    light.dining_table_lamp_2:
      state: on
      transition: 4
      brightness: 206
      color_temp: 443  
    light.dining_table_lamp_3:
      state: on
      transition: 4
      brightness: 206
      color_temp: 443

- name: Kantoor aan de slag
  entities:
    light.bureau:
      state: on
      transition: 4
      brightness: 233
      color_temp: 370
    light.inside:
      state: on
      transition: 4
      brightness: 127
      color_temp: 370
#      rgb_color: [218,176,100]
    light.outside:
      state: on
      transition: 4
      brightness: 127
      color_temp: 397
#      rgb_color: [222,174,91]

Off th top of my head I don’t think you can set color_temp and color at the same time. Just set the color and see if that works?

testing now indeed, but it was the combi of brightness and color_temp giving me the unwanted settings.