Adding Days to an input.datetime

Having some issues with script logic that will see if I need to do a task when the script runs. This always evaluates to False, even if it shouldn’t. I have been unable to figure out how to debug what these values are at runtime so I am at a loss.

The point of this is to flip on a toggle switch when today is past last task date and the duration (21 days in this case)

sequence:
  - if:
      - condition: template
        value_template: >-
          "{{(states('input_datetime.last_changed_silver_cartridge') |
          as_datetime | as_local + timedelta(days= 21 )).date() < now().date()
          }}"
    then: null
    else:
      - action: input_boolean.turn_on
        metadata: {}
        data: {}
        target:
          entity_id: input_boolean.silver_cartridge_toggle
alias: Maintenance Daily Update Script
description: ""

All help appreciated!

Remive the double-quotes that wrap the template. They’re not needed (in fact, they’re counter-productive in this situation; they’re treated as literal characters) when you use a line-continuation character (the >- at the end of value_template: >-).

Thank you, yes that did it! I did not understand what the >- and " " did

1 Like