WTH Can't Variables systemwide be defined?

It makes it so hard to circumvent all those limitiations - either we need to set up helpers, or Variables can’t leave a scope, or are not accessible in triggers, or…
This makes it really really hard, in terms of Time needed.

It would be such a relief to define Variables at any Place, and use them at any place. I have very little to nothing programming knowledge, but where i did, i never such a limitating Factor

@smartin Can you provide a use case for this?
What are you using the variables for?

Sure @jameson_uk ! :+1:

  • If i am setting/changing a variable in a Sequence Block, and later in the Automation, or another Automation, want to change it:
    https://www.home-assistant.io/docs/scripts/#scope-of-variables

  • I set up 15x5 SQL Queries. The Results are just temporarily needed. I had to set up 75 input helper, aside the Factor Time they further consume Database.

  • Whenever i want to use dynamic values and dont want/need them stored in recorder (e.g. i want to template a cards setting, which isnt templateable by design).

Basically: Everywhere, where you would need to set up input_helper and/or where you need to use dynamic values.

Let me Dream: In an Automation, i can just set the Action "Update GlobalVar ‘TitleGauge555’ to ‘What the Heck’ ".
In the Dashboard, i just set up:

type: gauge
name: §§§TitleGauge555§§§
unit: '%'
entity: sensor.cpu_usage

And it gets rendered as

type: gauge
name: What the Heck
unit: '%'
entity: sensor.cpu_usage

Just thinking out loud…

I get the not storing stuff in recorder but presumably you would want these to persist a restart so would need to be stored at some level.

If you have 75 queries (which I don’t think it common to most users) then you are still going to have to create 75 variables are you not?. Are you suggesting that the variables would be dynamic and you would never actually define them just set a name and that name could be referenced anywhere else?

Just thinking that you would need some way of viewing and maintaining variables and potentially some sort of retention to ensure temporary ones are temporary and get cleaned up.

Just wondering whether an option against helpers to not store history combined with things like the set number / text actions having a create helper option would solve some of this.

isn’t the real solution to that to make the card setting allow templates?

1 Like

Do you know e.g. Tasker for Android?
You just declare a Variable by setting it.
If it is all lowercase, its a temporary, only for this Task/Scope.
If it contains Uppercases, it is permament.
Really, really easy.

Combined with an e.g. Wildcard delete, or sorting for metadata (where is it used) it should be really easy to Maintain.

And i dont speak against helpers! But it is really a brake sometimes and kicks me out if i am in ‘Developing’. And if you have the Need for more Variables, it can take you really Hours.

Fair enough. Probably not. I do it, because i want a function HA doesnt have.
E.g. the 15x5 Queries - it have it only, because there is no built in Option to query Historic States by Templates.
Why do i do this? Because it is, for me, Nonsense to group energy Consumption by Month. I can never tell by looking at it, how the actual Month is going. But this is, what matters to me. So i compare 7/31/365 Days with 7/31/365 Days.

Whatever.
Maybe many Users will never set up a Basic Jinja2 Template. Or give up frustrated. They presumable dont care about Helpers or Vars anyway.

Sure it would make it easier. But why not having Vars that get declared by just setting them, if that would make even those steps unneccesary?
If you forget to maintain Vars, you will forget about maintaining Helpers as well.
Maybe its not a Bug, but a Feature to make it so cumbersome to set Helpers, as you will think about it three times if you need it… :wink:

Real Solution? Maybe. Still, you would need to set up helpers. My personal Experience (which should not be a rant at all!), is that many Developers dont see thats Important, or dont have the Time, or abdoned the Project completely, or…
The Real Real Solution would be probably to learn programming, fork and offer Pull Requests for everything :slight_smile: But why - if there are examples in Wild life that prove how easy such Things can be solved.
By having global, self-declaring Variables that can be used just everywhere :slight_smile:

Just stumbled about:
I want to Display an entities current value in a Blueprint, so the User knows what he/she is changing the value from. Simple not possible.

If we’d have globale variables, i could just add it. No need for a FR and waiting (if ever someone wants to do it and the PR gets accepted).

I am pretty sure i will find another usecase soon, i think its not helpful if i post everytime i want to use a value where it is not designed for :smiley: But thought this is another quite good, as different, Example for Solutions such a Var could bring.

I agree, I would rather use variables instead of helpers. A lot of mij helpers are only used in automations. I do not need them in the recorder or the dashboard. They clutter up the list of helpers and make the automation less readable. I would be great to have global variable available in automations and scripts.

You can remove them from both.

Extra work. Even involves meddling with YAML.

“Helpers” are IMHO a mess for a newbie. They can be so many things.

Having dedicated variables would be a step into creating some order.

1 Like