I’m trying to find a way to define global variable and reference it. I have in Helpers following numeric value: input_number.air_humidifier_on and would like to reference it:
alias: Artur - Air Humidifier - On at {{HERE}} %
conditions:
- condition: numeric_state
entity_id: sensor.artur_temp_humidity
below: {{HERE}}
Home Assistant doesn’t support the concept of global variables. It supports defining variables within an automation or script but they’re not global (i.e. cannot be referenced outside the automation where they’re defined).
The closest approximation to a global variable is a helper (such as Input Number, Input Text, etc).
A Numeric State Condition’s below option doesn’t support templates. Refer to the link I posted above to see what it does support.
You could install that custom integration. All the automations you create that use it will be forever dependent on it.
What exactly di you intend to store in a global variable? The entity_id of an Input Number helper?
I have five humidity sensors, one in each room. Each room also has a humidifier that should go on when humidity is below 43%. I’ve set automation for each room, and each yaml has a hardcoded value of 43. I would like to have the ability to set this value as a global variable, so when I change it, I have to do it in one place and do not have to edit five yam files.
I’ve read once again documentation, and this is the correct form:
That’s right; it’s exactly like the valid Numeric State Condition example I provided in my previous post. Please consider marking it with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.