All sensors in one place in secrets.yaml file. Possible?

I try to put sensors inside secrets.yaml (I would like to have them all one place like options) without success. Is this possible?

Here is example:

Now I have this:

{% set st1 = states('sensor.bathroom_wifi_sensor_temperature') %}
{% set sh1 = states('sensor.bathroom_wifi_sensor_humidity') %}
{{ st1 }}°C / {{ sh1 }}%

What I wanna achive?

secrets.yaml

bathroom_temperature: sensor.bathroom_wifi_sensor_temperature
bathroom_humidity: sensor.bathroom_wifi_sensor_humidity

not working template example

{% set st1 = states('!secret bathroom_temperature') %}
{% set sh1 = states('!secret bathroom_humidity') %}
{{ st1 }}°C / {{ sh1 }}%

Not sure if it can work, but try to move the ’ over to the secret file too.

You can’t use secrets inside templates. The only option is to put the whole template in the secret.

1 Like

The only option is to put the whole template in the secret.

Do you mean I can add it like this in secret?

bathroom_temperature: {% set st1 = states('!secret bathroom_temperature') %}

Is there any other way?

Rereading the question I come to think you might want to use includes instead.
There are different kind og includes and you can see it in this video.

2 Likes