I try to create an automation which stops charging of my car above a value which is stored in a variable. I read a lot of in the forms/blogs but I am still not understand how I have to setup this.
I have defined a
helper: input_number.i3_ladegrenze type number:
and I tried to replace the ABOVE value of 75 with the input variable but I failed.
Perhaps someone has an idea how it works. Many thanks in advance - Roland
When you say you “failed”, what was your testing methodology? Numeric state triggers only fire based on the value of the entity in the entity_id field… adjusting the entity used in the above field will not have an immediate effect. The comparison will not be re-evaluated until the state of the battery percentage sensor updates.
If you need it to be re-evaluated when either entity is changed, you can use two Numeric state triggers or a single Template trigger.
I put in the input helper variable but the system complaint that I have to use a float variable. How I can convert the input_number.i3… into a float? Do you have some example coding for me?
many thanks for your help. I changed the trigger but how I have to code that the trigger is true if the input_number.i3_ladegrenze >= sensor.i3_rex_remaining_battery_percent?
For your Numeric state trigger to fire, the value of the battery sensor’s state must change in such a way that the comparison’s evaluation switches from false to true. You cannot just change the input number and expect the automation to fire.
To test if the trigger works, you have two options:
Wait for the battery charge to drop below the your input number through use, then recharge it.
Use the “Set State” function on the Developer Tools > States tool to set the state below your input number, then above.
Ok, I understand now that I can’t use a state for trigger comparing. The charging percentage is state (in this example 50). How can I convert it into an attribute?
This is incorrect. States are the most common source of triggers in Home Assistant.
For comparisons, state triggers are used when comparing an entity’s state to an absolute value. Numeric state triggers are used to perform “greater-than” and/or “less-than” comparisons between an entity’s state and a numeric value, which can be supplied by the state of another entity if desired. As stated previously, this type of trigger only fires on changes of the entity listed under the entity_id key.
Alternatively, you can use template trigger. This type of trigger works slightly differently. The “greater-than” comparison will be reevaluated every time the state of either entity changes. When one of those state changes causes the evaluation of the comparison to change from “false” to “true”, the trigger will fire and the conditions block will then be evaluated.
Hi Drew,
HAPPY BIRTHDAY!
I dried your 1. suggestion a few days ago but it didn’t work (Perhaps I made a mistake). Now I try the template suggestion but the i3 is away for a week. You will get a replay next weekend.
Cheers
Thanks for the great input here Drew, Im picking up on this thread with a similar question. Put differently…
Are you saying (as I suspect) that a state trigger will only trigger once the state passes the set threshold whereas templates dynamically poll the sensor for its ongoing state.
I have a similar situation where I want my geyser to come on when the batteries are above say 60% (using the battery sensor) BUT also want the total PV to be above a level. This means that as the batteries are being charged during the day they may go over the 60% but not meet the set minimum PV condition and therefore will not switch on the geyser, if however later the PV increases because the trigger has already been “passed” no event will trigger ?
Is this the case and in which case should I then opt for a template trigger ?
Yes and No… As you wrote, a Numeric state trigger only triggers when the state of the entity crosses the defined threshold and the automation will not wait around for other conditions to be satisfied. In the case of your geyser, the actions would not be executed.
However, a Template trigger doesn’t exactly “poll” the entities’ states, it is simply recalculated every time the state changes.
You can certainly use a Template trigger. Another option is to use two Numeric state triggers with two corresponding Numeric state conditions.