Home Assistant Variables {{states.xxx.state}} in Configuration instead Hard Coded data!

Hello.
Very often i had to deal with Hard Coded Variables in Home Assistant.
Example:

Ping Sensor

  • platform: ping
    name: “Sensor Ping”
    host: 9.9.9.9
    count: 2
    scan_interval: 10

But everything could be setted in Home Assistant Variables, so in any moment i could change the data from GUI

  • platform: ping
    name: “Sensor Ping”
    host: “{{states.input_text.ping_ip.state | str}}”
    count: “{{states.input_number.ping_period.state | str}}”
    scan_interval: “{{states.input_number.ping_count.state | str}}”

But since long Time I’ve stucked with this because Could’t do this, It doesn’t work.
I’m think templating will not work here, because so I have no idea.

I think there’s a lot situations simmilar to this, like alarm_control_panel parameters: code, delay times etc.

I found some workaround. Theres way to use !secret instead the variable, and i wrote some script to read vaules from entities, clear secrets file and write everything what i defined in script to secrets file, but it’s stupid workaround i think.

Any Idea’s how to solve the problem but no with workaround ?

You have been a member of this forum for 3 years. I should not have to tell you to format your pasted configuration.

And no, templates are for script and automation services and service data. Only rarely are they available for integration configuration options, and when they are it is explicitly stated.

And yes it is a stupid workaround because configuration options are only initialised during starting of Home Assistant or reloading of the integration. So if you change the secret you have to restart or reload for it to take effect.

1 Like