Nesting states in templates - How far can you go?

Bear with me on this, I have a very rational explanation for what I am doing trying to do.

Following the demise of DarkSky I am experimenting with all the great new weather integrations that have popped up along with a few others I have found that have public APIs.

To make life simpler I now have an input_text set up for all the weather data items I am interested in and base my weather sensors on these. e.g.

input_text:
  weather_sensor_curent_temperature:

Now whenever i want the current temperature I can use:

{{ states(states('input_text_weather_sensor_curent_temperature') }}

and any time I choose to use a different weather provider I just change the input_text and it all happens dynamically.

So far so good…

I also have an irrigation package used by a few people that relies on weather sensors. This is where I first started using this idea so as to allow people to choose their own sensors. And it too, all works. This is self contained within the package and separate to my global config which only added recently.

To be clear, both work but are independent of each other but I would like to be able to use the sensors defined outside of this package within my instance of the irrigation package.

So to finally get to the point…

If I have an input_text which contains the string:

"states('input_text.weather_sensor_forecast_high_temperature')"

why doesn’t this:

{{ states(states('input_text.weather_sensor_forecast_high_temperature')) }}

work?

I would have thought that this would have resolved to:

{{ states(states('input_text.weather_sensor_current_temperature')) }}

which as seen above works.

Is there something I am missing?

I know this is convoluted but maybe this will help illustrate?

Because your original statement is actually:

{{ states("states('input_text.weather_sensor_forecast_high_temperature')") }}

You need the equivalent of the reviled exec() function in many languages, but I don’t think it exists here.