How can I run my sprinkler script only on even-number days?

I am violating the “if it ain’t broke, don’t fix it” rule and moving my sprinkler controls from Node Red to Home Assistant.
(I break that rule often). I have the functions mostly finished and learned a bit about automations, scripts and helper entities along the way. (Not that that means I won’t continue to ask stupid questions in the future).

But, I have run into a wall. My town requires that my lawn irrigation can only be run on even-numbered days.
So, how can I run my sprinkler script only on even-number days?

The following template reports true when the current day (of the month) is an even number. Depending on how you have constructed your automation, it can be used in a Template Condition or in a Template Trigger (along with the scheduled time).

{{ now().day % 2 == 0 }}
1 Like

Adding, even seems a bit odd/off… when you run on say 30th July, then the next would be 2nd August…so maybe you mean every 2nd day?

I use garbage collection from hacs.

This is my watering schedule

  - name: Watering Days 
    frequency: "weekly"
    - tue 
    - thu
    - sun
    first_month: "apr"
    last_month: "oct"

I then trigger and use the following conditions

  - platform: time
    at: input_datetime.irrigation_valve_on_morning
  - platform: time
    at: input_datetime.irrigation_valve_on_evening
  - platform: time
    at: input_datetime.irrigation_valve_off_morning
  - platform: time
    at: input_datetime.irrigation_valve_off_evening
  - condition: state
    entity_id: sensor.watering_days  <--- From garbage collection
    state: '0'
  - condition: state
    entity_id: input_boolean.run_irrigation
    state: 'on'
1 Like

Nope, even/odd based on your address. So with a few 31 day months in the summer, we lose.

Thanks, this looks like it will work.

Kind of had the same problem and it grew into an integration. Check it out - it does odd/even days, days of week, days of month, months of year. GitHub - rgc99/irrigation_unlimited: ♒Irrigation controller for Home Assistant. Good luck.

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions. For more information, refer to guideline 21 in the FAQ.