I’m close but I can’t seem to figure out this automation.
I have a PLC that provides the hourly runtime of my sump pump. This value appears in HA as sensor.current_hour_runtime. It resets to zero at the start of each hour.
I have an input number that I want to use to track how long my sump pump has run each day (input_number.cumulative_sump_pump_runtime).
I wrote a small automation that adds the current hour runtime to the cumulative runtime at 59 minutes and 30 seconds past the hour. This seems to be working well.
I want to reset the daily runtime value at 11:59:30 each day. I can’t seem to master how the reset value should be configured in the automation. I get these errors in my log:
Error while executing automation automation.update_sump_pump_daily_runtime. Invalid data for call_service at pos 2: extra keys not allowed @ data[‘value_template’]
I’ve tried Value: 0 and {{ states(‘input_number.cumulative_sump_pump_runtime’) = 0 }} but neither seem to work even though they pass the built in configuration validation.
Thank you in advance for your help formatting that if/then in the Value_template section.
you already told it that a template was forthcoming in the data section by using “data_template”. Try changing “value_template:” to just “value:”.
You also might have to move to a single line template but try it multi-line first.
The other issue is going to be what happens when the hour isn’t “23”? the template will fail at that point on an invalid service call for no “value” information given. try to come up with a satisfactory “else” statement that will always be valid if now =/= 23.
Help me understand the role of the condition in your example. Is it tied to the first service call or designed to prevent the second service call from running when it isn’t 11 PM?
I always want the first service call to execute, even during the 11 PM hour. At the 11 PM hour, I want both services to execute in order.
Thank you for your post, it is always good to learn different methods; even it only to help people adapt code samples to their project.