I am making a template to try and help the family understand approximately how long the house batteries take to recharge from different appliance uses.
So if something takes 4 amp hours from the battery bank then:
FYI, the sensor.cerbo_battery_consumed_ah value is negative, which is possibly also a problem, don’t know how to fix that at the moment.
Separate idea, I have a counter helper that I was trying to see if I could use as a trigger if it hasn’t been changed in the last hour. But this doesn’t seem to be working, is this a possibility and I’m just doing it wrong or ???
To do arithmetic with it you first have to convert it from a string to an integer (int) or floating-point number (float). Which conversion you choose depends on whether you only want whole values (int) or with a decimal point (float).
I’m not sure why you are employing multiple intermediate round(2) filters within the calculation when you ultimately filter the final value with round(0).
Copy-paste this into the Template Editor and see if it works for you:
Thank you Taras, that works, and helped explain to me what some of it means. As for why the multiple filters… cause I’m making it up as I go and don’t really know what I’m doing.
After you created the automation containing that State Trigger, did the counter’s value remain unchanged or did it change and then hold its new state for over an hour?
Here’s my understanding of how it works:
If it didn’t change, in other words it had the same state value before and after you created the automation, I don’t see how it could trigger the State Trigger. A State Trigger is triggered by a state-change. The one you created looks for any change in the entity’s state value followed by holding that new value for 1 hour. If there’s no state-change, there’s nothing to start the 1-hour countdown.
I was hoping the trigger would be: “if this hasn’t changed in the last hour, then trigger.”
which I could then enable checking at certain times of the day
whereas it is more like: “trigger one hour after it last changed”
meaning in my use case, if the counter changed more than 1 hour before my time window then it doesn’t trigger.