Get state attributes from entity by input_select

Hi,

I have a IKEA Strybar (4 button remote) which I want to use to toggle between lights, turn them off and on and adjust their color temperature. Therefore I have created an input_select entity containing the light entities, which I’m toggling through using the remote.

My problem is that I can’t get the current color temperature of the current selected light from input_select:

Light from input_select: {{states('input_select.selectedlight')}}
Color Temp: {{state_attr('{{states('input_select.selectedlight')}}', 'color_temp')}}

Somehow those queries cannot be nested, since the query seems to result in a string.
I was searching a lot for nested attributes, get entitity attributes by string etc. but couldn’t find anything.

I would be glad if someone could help.

Thanks!
Steffen

You are attempting to nest entire templates and that’s invalid.

Copy-paste this into the Template Editor and confirm it reports what you want.

{{state_attr(states('input_select.selectedlight'), 'color_temp')}}
1 Like

Works like a charm! Thank you very much!

1 Like