Irrigate every other day is irrigating every day

I am trying to get my automation to trigger every other day - it seem to be triggering every day.
Long term I will use soil water sensors, but I’m not there yet.
I’m using:
Home Assistant 0.109.4
in a docker container
on debian 10 - buster
I5 8GB ram
it ran well using the weekday condition below, but i needed to increase the watering for the summer.

  trigger:
  - at: 08:00
    platform: time
  condition:
  - condition: time
    weekday:
    - wed
    - sun

but this code seems to trigger every day even tho the value tempate portion alternates 1 and 0 correctly every other day.

- id: sprinkler_water_all
  alias: Sprinkler Water all
  trigger:
  - at: 08:00
    platform: time
  condition:
  - condition: template
    value_template: '{{ now().timestamp()|int % 2 == 0 }}'
  action:
  - data:
      entity_id: script.sprinkler_water_back
    service: script.turn_on
  - data:
      entity_id: script.sprinkler_water_front
    service: script.turn_on

what did I overlook?
tia
jim

{{ now().timestamp()|int % 2 == 0 }} isn’t going to do what you want. Its updating constantly based on UNIX time so at any given moment it could be even or odd. A couple of examples are 1588698878 and 1588698919 are what is being returned.

One option would be use {{ now().day|int % 2 == 0}}, but you will have an issue on 31 day months…

1 Like

thank you. I just change my automation to now().day…

I’ll worry about day 31 later if becomes an issue.

You could use %j to get day in year. That would reduce your conflict on the 31 to just December.

1 Like