Automated Conditional Input Boolean?

I´m trying out using Helpers for the first time so i might be way off on my solution here but basically i want to run a Automation each night to set a Input boolean that i can then use in other automations.

Idea is to set a bool if its Garbage day, the trigger is set for 01:00 every night, and depending on the weekday and week number it should set the bool to true/false.

Trigger

platform: time
at: '01:00:00'

Condition

condition: and
conditions:
  - condition: template
    value_template: '{{(as_timestamp(now())|timestamp_custom (''%U'') | int % 2) == 1 }}'
  - condition: time
    weekday:
      - tue

Now, this is where i´m a bit lost, how do i set the bool value depnding on the condition, i need a if else action in some way, otherwise the bool will only be set once and never reset.

service: input_boolean.turn_on
target:
  entity_id: input_boolean.isgarbageday

Any tips are welcome
Christian

You can use a choose in the action of the automation with your conditions there:

action:
  - choose:
      - conditions:
          - "{{(as_timestamp(now())|timestamp_custom ('%U') | int % 2) == 1 }}"
          - condition: time
            weekday:
              - tue                
        sequence:
          - service: input_boolean.turn_on
            entity_id: input_boolean.isgarbageday
    default:
      - service: input_boolean.turn_off
        entity_id: input_boolean.isgarbageday
1 Like

That is perfect, just what i was looking for. Really appreciate that Dennis, saved me a lot of headache.