Just add them via customize as I did here: home-assistant-config/config/customize.yaml at acb58a2b9d6cec24d2c5f2e88548df155ed43352 · pedrolamas/home-assistant-config · GitHub
This is only helpful if the attribute is fixed. If I’m not mistaken, you can’t set an attribute like e.g. “is_occupied: false” and then change it with a service to “true”.
you can with python scripts, but who wants to do that. Also, I usually do this with sensors in appdaemon. Only reason I haven’t left it behind for the built in automations.
I know that it’s possible, I use it a lot in AppDaemon, however not as simple as a service call.
Now that I’m thinking of it, one could write a generic python script and pass the attribute and desired value as parameters to create a “simple” service call to be used in automations.
Not to take away from the desire for the end result to be that variables get added to the core of HA but…
this can already be done using the hass-variables custom integration.
The reason I bring this up again is that, one, we know it can be done because it already is being done in a custom integration (and works splendidly as far as I’m concerned). And, two, the devs already have a blueprint to add it to core sitting there ready and waiting to be stolen implemented.
IOW, the barriers for setting this up should be as low as it will ever be to get a new integration added. All the work is pretty much done.
I have a use case for global variables (a float number that would persist through a reboot). Is a input_number
the simplest method for this? I’m aware that 3rd party integrations exist variables but prefer not to add more integrations and the associated overhead / dependency if things can be accomplished in core, even if I need to be a little creative.
I see this work was started…
… but it states “Closing this in favor of the work started in #39895.” and that new PR seems to be limited in scope to just scripts and automations… unless I’m missing something and those can be creatively used as global variables?
Personally I use this: GitHub - rogro82/hass-variables: Home Assistant variables component
Custom component to allow easy way to both set and retrieve variable values.
That’s the best method to have it persist through reboot without going the custom route or MQTT route. With MQTT, you can store the information in a topic with an automation. Then in MQTT’s config, add that topic as a sensor.