Alternating workday sensors

I’m trying to figure out the best way to implement an alternating work_day binary sensor into an automation conditional statement.
I have 2 workday binary sensors, binary_sensor.workday1 and binary_sensor.workday2. On week 1 I would like it to use binary_sensor.workday1 and then on the monday of the following week I would like it to start using binary_sensor.workday2 and continue alternating in that fashion every week.
I would like to limit the amount of automations I’m creating if possible and contain all logic within the conditional statement or possibly altering the binary_sensor to contain conditional statements for the workday list.
I don’t see an ifonce function available, I feel that would make this much easier.

Checking if it is an odd or even week:

1 Like

Oh wow very simple, thank you! This is my final condition statement I ended up implementing and it seems to work at least in the template editor for anyone else interested

condition: template
value_template: >-
  {% if ((now().strftime("%W") | int) % 2) == 0 and (states('binary_sensor.nick_workday1') == 'on') %}
    true
  {% elif ((now().strftime("%W") | int) % 2) != 0 and (states('binary_sensor.nick_workday2') == 'on') %}
    true
  {% else %}
    false
  {% endif %}
1 Like