@jhart003 wrote:
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’]
Here is the automation as I currently have it:
- alias: update sump pump daily runtime initial_state: True trigger: platform: time_pattern minutes: 59 seconds: 30 action: - service: input_number.set_value data_template: entity_id: input_number.cumulative_sump_pump_runtime value: "{{ states('sensor.current_hour_runtime')|int + states('input_number.cumulative_sump_pump_runtime')|int }}" - service: input_number.set_value data_template: entity_id: input_number.cumulative_sump_pump_runtime value_template: > {% if (now().hour == 23 ) %} 0 {% endif %}
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.
Posts: 9
Participants: 3