Variables not resolving

Hello All,

I am hoping someone can provide some assistance as I am tearing my hair out here trying to do something that should be quite simple!

I have done heaps of googling already and tried suggestions in other threads, but to no avail.

I am just trying to make a simple automation to cycle through an input select and apply the state of the input select to the colour of the rgb downlight. In short, letting me cycle through some colours.

What I am seeing however, is that the variable (which should return the state of the input select) is not resolving and is acting like a string literal?

I can confirm that the input select is cycling by checking the ‘Helpers’ section and I can see the logs showing that the state is not resolving.

See logs:

Am I using the variable wrong?

Please help!

Can only upload one image as I am a newbie so here are some additional:


Please learn how to properly format code. No one is going to rewrite your code by hand by copying it from an image.

Please check out this post to learn how to properly post and format code/yaml in a comment/post. Point 11 covers this.

Which version of Home Assistant are you using?

Starting with version 0.115, you can use data: with options containing templates. In all older versions, you have to use data_template: otherwise the template not be evaluated and simply handled literally as a string.

I see two reason for this not to work, first you mix GUI automations with templates, which doesn’t work and second which version of Home Assistant are you using?

Hey All,

Thanks for responding.

Sorry for not formatting properly, I’ll be sure to do that next time.

- id: '1606825972676'
  alias: Colour Cycle
  description: ''
  - device_id: 6c828f5f88504f48bff821e8ba9d471f
    discovery_id: 0x00158d00033ef2f1 click_double
    domain: mqtt
    platform: device
    subtype: double
    type: click
  condition: []
  - data:
      color_name: '{{ states(''input_select.colour_cycler'') }}'
      entity_id: light.master_bedroom_lights
    service: light.turn_on
  - entity_id: input_select.colour_cycler
    service: input_select.select_next
  mode: single

I am running version 0.113.1 - which might be the issue. I’ll update now.

Are you referring to the input select? I had previously defined this in the config files, but recently cut across to the helpers UI as I was following doco etc.

Welp, updating the version did it!

Thank you all, and sorry for wasting your time :hugs:

PS: Yay for dark mode!!!

1 Like

If youre running 0.113.1, then you need to change this action to use yaml in the editor

  - data:
      color_name: '{{ states(''input_select.colour_cycler'') }}'
      entity_id: light.master_bedroom_lights
    service: light.turn_on

After you do that, change data to data_template so that the full action looks like this

  - data_template:
      color_name: '{{ states(''input_select.colour_cycler'') }}'
      entity_id: light.master_bedroom_lights
    service: light.turn_on

In that case, all you needed to do was use data_template because, as I explained, data behaves like data_template starting with 0.115 and more recent versions.

Now that your original question has been answered, please consider marking my post above with the Solution tag (the post explaining how your older version behaves differently). By doing this it will automatically place a check-mark next to the topic’s title which signals to other users that this topic has an accepted solution. This helps other users find answers to similar questions.

1 Like

Thanks for clarifying that @petro

@123 cool, thanks! It doesn’t seem that long ago that I set it all up so I didn’t think I was that behind :expressionless:

Be sure to review the release notes because there have been many significant enhancements since 0.113. If you use templates (in triggers, automations, sensors, etc) you should familiarize yourself with the new ways they are handled ( entity_id has been removed, entities within templates are identified using an entirely new way, and templates now return native python types as opposed to only a string value)

1 Like