Sensor template working in Developer Tools create error in configuration. yaml

To check if overnight backup was running well I intended to create a binary sensor. After some trial and error the Syntax check in the Developer was running well with result type: String and an expected “1”

{% if ("now().day", "states.sensor.samba_backup.attributes.last_backup[8:-6]") -%}
  1
{%- else -%}
  0
{%- endif %}

If I enter this as state in configuration.yaml under template / binary_sensor

 - name: samba_ba
   unique_id: binary.sensor_samba_ba_ok
   state: >-
    {% if ("now().day" , "states.sensor.samba_backup.attributes.last_backup[8:-6]") %}
     1
    {% else %}
      0
    {% endif %}     
   device_class: update

I get an error for the first state line starting: {% if (…

"missed comma between flow collection entries at line 178, column 10:
{% if (“now().day” , “states.sens …
^…”
Do you have an idea what is missing and why it works in the template check but not in the config ?
Thank you for your help.

Actually, it’s not “running well”. Your test is faulty because even this will report true

{% if "anything" -%}
  1
{%- else -%}
  0
{%- endif %}

This template is invalid:

   {% if ("now().day" , "states.sensor.samba_backup.attributes.last_backup[8:-6]") %}
     

Perhaps this is what you want to do?

   {% if now().day == state_attr('sensor.samba_backup', 'last_backup')[8:-6] | int(0) %}

Thank you Taras for quick response and helping to become a bit more familiar with the syntax.
Unfortunately same behaviour as before. Good in Syntax check (of course) but in configuration.yaml exactly the same message “error in column 10” ???. Do you know how is column 10 defined ? If I skip the spaces it is between the brackets of now() ???

Now it works. Don’t ask why is was wrong first. I don’t know

Glad to hear it works and solves the problem.

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic is resolved. This helps other users find answers to similar questions. For more information, refer to guideline 21 in the FAQ.

I will do so.

Additional finding:
Both versions give the right day “11” in the template check under Developer

{{ states.sensor.samba_backup.attributes.last_backup[8:-6] }}
= 11

{{state_attr(‘sensor.samba_backup’, ‘last_backup’)[8:-6] | int(0) }}
= 11

Nevertheless, your versions I have seen very often handling sensor attributes. So I will remember this for the future.