Condition Template evaluating false when dev tools evaluates true

I have the following conditional template in an automation:

value_template: >-
  "{{(state_attr('automation.waste_collection_yellow_bin_collected',"last_triggered")
  == none) or not
  (state_attr('automation.waste_collection_yellow_bin_collected',"last_triggered")|
  as_datetime|as_local()).day==now().day }}"

That is always evaluating to false, but if I copy paste the same template into the dev tools, it evaluates to true as expected.

Does anyone have any ideas why I am getting different behavior between the automation engine and dev tools?

You shouldn’t use quotes around the template when using the multiline string operator:

value_template: >-
  {{(state_attr('automation.waste_collection_yellow_bin_collected',"last_triggered")
  == none) or not
  (state_attr('automation.waste_collection_yellow_bin_collected',"last_triggered")|
  as_datetime|as_local()).day==now().day }}

:man_facepalming: Thank you, it works now.

It was a single line template originally, but either copy paste or the mixed quotes I mistakenly used has obviously broken it at some point.

If you’re interested, you can simplify the template like this:

value_template: >-
  {% set lt = state_attr('automation.waste_collection_yellow_bin_collected', 'last_triggered') %}
  {{ lt is none or (lt | as_local).day != now().day }}

Thanks for the tip. I was just trying to get it working so hadn’t really thought about simplifying it yet.