I have a numeric value helper (“desired_pool_min_temp”)
I’d like an automation to trigger when a sensor’s reported temperature goes above that helper value PLUS an offset. So if if desired_pool_min_temp is 90, i want the automation to trigger when sensor7 goes above 91.
The way you have it configured, the input number is being compared to an attribute of the sensor named value… is that correct? If you are unsure, go to Developer Tools > States and type in the entity ID to see what attributes are available for that entity.
For a Numeric state trigger, the template is evaluated whenever the state of the entity listed under entity_id changes. Unlike a Template trigger, changes to any other entity included in the template or above/below fields will not initiate the trigger.
Update: The Numeric state trigger’s template is no longer limited to updating based on the entity listed under entity_id. Both Numeric State triggers with value templates and Template triggers will be render following the same rules.
Both of the options I posted have been tested and work.
You will need to describe your testing method. As described in my earlier post, similar Numeric State and Template triggers will not always fire equivalently.
I’ve copied and pasted your YAML, then gone to developer tools to manually changed the sensor (temp7) states value to lower and then high the threshold (before and after the offset) and watched the logbook live. I have a mirrored automation that’s my template trigger to make sure it’s firing. Your suggestion did not work.
It’s not documented explicitly, it’s only lightly implied by the attribute-based examples in the Automation triggers docs. From there, the docs just expect you to have an understanding of HA state object structure…
Thanks, this helped me as well. What wasn’t clear from the example was that the value template "{{ state.state | float(0) - 1 }}" get’s the state from the entity defined in the trigger condition since this is not explicitly stated.
In my case I wanted to check when my EV state of charge reached the target state of charge (these are 2 different sensors), so for the trigger entity I selected to monitor the entity (using a numerical state automation):
The condition is when the above value statement is below 1, which means the evaluation is based on “target state of charge - the current state of charge = 0” (they’re the same).
This allows me to change the target state of charge in the car/app and not have to worry about it in the automation.
There doesn’t seem to be a reference to the current state of charge, so that condition will always be true… It is essentially asking if 0 is less than 1.
The issue I was trying to clarify seems to have just been a typo in your earlier post… you used the “target_state_of_charge” entity ID in both places in your description. But your actual trigger looks fine. You can use either of the template variations you posted, it shouldn’t change the functionality appreciably.