Automation based on value template

Hi all,

I didn’t get an automation working.

Here is the code for it in yaml:

  - alias: 'Benachrichtigung wenn Schwarze Tonne'
    trigger:
     platform: state
     entity_id: calendar.mullabfuhr
     to: on
    condition:
      condition: template
      value_template: '{{ "states.calendar.mullabfuhr.attributes.message" = "Erinnerung: Abfuhr schwarze Restmülltonne morgen ab 6 Uhr" }}'
    action:
     service: notify.iphone
     data:
      title: "Schwarze Tonne:"
      message: "Rausbringen!"

I want to get a notification to my iphone if a calendar event is changing its state to on and based on the
message of the calendar i want to change the message of the notification. So basicly i try to check if the
value of states.calendar.mullabfuhr.attributes.message is equal to “Erinnerung: Abfuhr schwarze Restmülltonne morgen ab 6 Uhr”
But when I check the config, I get the following error:

Invalid config for [automation]: expected str for dictionary value @ data[‘trigger’][0][‘to’]. Got None
invalid template (TemplateSyntaxError: expected token ‘end of print statement’, got ‘=’) for dictionary value @ data[‘condition’][0][‘value_template’]. Got None
not a valid value for dictionary value @ data[‘condition’][0][‘condition’]. Got None
required key not provided @ data[‘condition’][0][‘entity_id’]. Got None. (See /config/configuration.yaml, line 12). Please check the docs at https://home-assistant.io/components/automation/

I’ve tried to use different " and ’ settings but nothing worked.

Can someone please help me?

Thanks.

You need to use ‘==’ to compare two things. You put your state object in quote, which turned it into a string. I believe the root cause of your issues was because you didn’t put quotes around ‘on’ in the trigger and having 1 equal sign in your value template.

  - alias: 'Benachrichtigung wenn Schwarze Tonne'
    trigger:
      platform: state
      entity_id: calendar.mullabfuhr
      to: 'on'
    condition:
      condition: template
      value_template: '{{ states.calendar.mullabfuhr.attributes.message == "Erinnerung: Abfuhr schwarze Restmülltonne morgen ab 6 Uhr" }}'
    action:
      service: notify.iphone
      data:
        title: "Schwarze Tonne:"
        message: "Rausbringen!"

Thank you petro, that solved my issue.

no problem!