I have 4 pumps, I want to configure for example pump 1 to run from 10:00 a.m. to 4:00 p.m. Monday, pump 2 from 10:00 a.m. to 4:00 p.m. Tuesday…
is there a solution?
Combine a Trigger: Daily Time Point with a Conditional Controller.
Use the Trigger (at 10:00 am) to activate the Conditional Controller.
In the Conditional Controller use weekday() Python Get the Day of the Week [5 Ways] – PYnative to get the day of week.
if weekday == 1 → run pump 1 for 21600 seconds
if weekday == 2 → run pump 2 for 21600 seconds
else → do nothing
as last action: deactivate the Controller by itself to ensure it runs only once.
Building upon what @mondgans said, you can also do this from a single Conditional Function, with one Output On/Off Action to turn the pump on and another to turn the pump off, and this as the Python Run Code (changing the Action IDs to the ones for your particular Actions):
from datetime import datetime, time action_id_pump_on = "asdf1234" action_id_pump_off = "qwer5678" now = datetime.now() day = now.weekday() # Day: Monday = 0... Sunday = 6 pump_on_date_times = [ day == 0 and time(10) <= now.time() <= time(16), # Monday 10 AM - 4 PM day == 1 and time(10) <= now.time() <= time(16), # Tuesday 10 AM - 4 PM ] if any(pump_on_date_times): self.logger.debug("Currently within the time to turn pump on") self.run_action(action_id_pump_on) else: self.logger.debug("Currently within the time to turn pump off") self.run_action(action_id_pump_off)
If you’re turning the pump on for the same time duration every day of the week, you can also just use a Daily Time Span Function with an Output On/Off Action to turn the pump on for your time range, then use a Daily Time Point Function to turn the pump off 1 minute after the time range to turn it off.
Using the Conditional, you can have some days not turn the pump on or have different time periods for different days of the week.
Thank you mondgans KyleGabriel for your help