Hour meter with trigger every 8 hrs

I have an industrial evaporative cooler which now has an 8266 controlling its operation.
It has a water dump valve which dumps all the water, flushing the dirt out that gets collected on dusty days. This is normally a manual switch but i would like to trigger it every 8 hours the cooler has been running. some days the cooler may not run for 8 hours so it would not need to dump until the next day.

I was hoping to use the History Stats integration with an automation to trigger the dump cycle and reset the meter, but History Stats doesnt have a reset function.

Is there another alternative for this?

if it helps the entity that i am monitoring to give the run time is:

switch.evap_water_pump

and the entity that needs to be turned on is:

switch.evap_dump_cycle

This just triggers a cycle turning on the valve for 5 mins and turning it off again.

appreciate any help.

Have a look at Time pattern triggers

thanks for your reply.
Would a time pattern that triggered every 8hrs - the last time triggered work maybe?

Im struggling to visualise it sorry.

Reset value


Or

I am a bit short on time at the moment.
The thing is that, in my experience, triggers in “state duration” are not reliable since a reboot or even an automation edit can influence them.

So, since you want something to run every 8 hours, I’d suggest having it run every 8 hours using a pattern. I guess you would not mind being it 7hr55min I guess. So a very simple example where the bulb replaces your switch.

Of course, I’d advice to make it more robust and have a choose to make sure it’s always toggling correct and not that it is pumping 8hrs and off for 5min.

alias: Bulb example
description: ''
mode: single
trigger:
  - platform: time_pattern
    hours: /8
    id: On each 8hrs
  - platform: state
    entity_id: light.dimmable_light_22
    to: 'on'
    for:
      hours: 0
      minutes: 5
      seconds: 0
    id: Off after 5min
condition: []
action:
  - service: light.toggle
    data: {}
    target:
      entity_id: light.dimmable_light_22

Is this of any help?

Since it’s every 1/3rd of a day, you might even just consider making it trigger on fixed times. If I am correct, one can even give the 8hr times the same trigger id, so a choose condition could be on one trigger id, and is dedicated on/off instead of toggle.

What about a combination of history stats and template sensor

sensor:
  - platform: history_stats
    name: evap on weekly
    entity_id: switch.evap_water_pump
    state: "on"
    type: time
    start: "{{ now().replace(hour=0, minute=0, second=0) }}"
    duration:
      days: 7
   
 template:     
   - name: "set run"
     unique_id: "set run"
     state: >-
       {% set t = (states('sensor.evap_on_weekly') | float(0)) % 8 %}
       {% if t < 0.03 %}
         run
       {% else %}
         stop
       {% endif %}

trigger:
  - platform: state
    entity_id: sensor.set_run
    to: 'run'

You also have the option to set it to the entire cooling season and then you will never miss a dump.

1 Like

Thanks, this has worked every time all year so far!
I do notice that it does still do a dump cycle at midnight sometimes even though its not run for 8 hours. not a deal breaker but it would be a nice refinement if it didn’t.