With the developer tools I can set the attributes of input_text
. So there is an API behind.
I would like to do the same from a script. How to?
Input text does only describe how to set the value.
With the developer tools I can set the attributes of input_text
. So there is an API behind.
I would like to do the same from a script. How to?
Input text does only describe how to set the value.
The attribute you create using Developer Tools isn’t permanent. It disappears after a restart.
There is no service call available to create/set an attribute for an Input Text (or other helper).
There may be another way to achieve your goal but I would need to know what is your application. Why have you chosen an Input Text and why do you need to create an attribute?
If it’s to store data dynamically, it can be done with a Trigger-based Template Sensor. If you simply need to store a constant value as an attribute, it can be done with Manual Customization.
thx @123
It is dynamically and transitory, that’s why I ask for a script. Sounds like Trigger-based Template Sensor may be an answer. I have to look it up.
A Python script may be another solution like shown here. Contrary to the title the scripts also handles attributes.
hass.states.set()
is where the magic happens, if you want to do your own script.
Is the data you wish to save shorter than 255 characters in length?
Yes, that’s one reason it is longer. The other reason is, that the attributes support a JSON tree not just a string. It’s related to this:
I just confirmed that set_state.py
can create/set an attribute for an Input Text. However, the attribute disappears after a restart (so it behaves the same way as using Developer Tools).
I suggest you consider using the following Trigger-based Template Sensor which allows you to dynamically store data (list, dict, boolean, etc).
An alternative, that also uses a Trigger-based Template Sensor, is this one:
However, for your application that requires storing a dict, it would need to be modified slightly to store the value in an attribute as opposed to state
.