Can't activate scene selected from input_select

Hi,

this is probably an easy one but i’ve been breaking my head over it.

I have a button with the following code that works fine:

      - type: button
        tap_action:
          action: call-service
          service: hue.hue_activate_scene
          service_data:
            group_name: Living room
            scene_name: Movies
        icon: 'mdi:movie'
        name: Movies

Now i made an input_select with some names for the scenes called input_select.hue_scenes. I made sure the values are exactly the same as the names of the scenes.

Then i tried this code for my new button:

type: button
tap_action:
  action: call-service
  service: hue.hue_activate_scene
  service_data:
    group_name: Living room
    scene_name: {{states('input_select.hue_scenes')}}
icon: 'mdi:movie'

But this gives an error on the scene_name field.

if i use {{states(‘input_select.hue_scenes’)}} in the Template Editor it just gives me the selected state of the input_select.

I’m confused why this is not working, but i bet it’s something simple.

Your YAML isn’t valid for templating, though the docs don’t specify if templates work here, so this may or may not work

type: button
tap_action:
  action: call-service
  service: hue.hue_activate_scene
  service_data:
    group_name: Living room
    # the template must be quoted like this ⬇️ also it should be `state`, not `states`
    scene_name: "{{state('input_select.hue_scenes')}}"
icon: 'mdi:movie'

Your comment is wrong it has to be states(…) mot state(…), wee the docs here.

@CK77
You can’t template in lovelace without using a custom card such as 📝 100% Templatable Lovelace Configurations

Ah my bad. I was thinking is_state

So, I’m doing everything correct except for the type of card i’m using?
Great i’ll have a look at your suggestion.

I just assumed that you could Template anyting in the lovelace interface. I’m still very new at this :slight_smile:

Yeah, that did the trick, works like a charm now!
Thanks!

1 Like