Automation with is_state('trigger.to_state', 'on') not working

I have this automation, which sends a telegram message when a light was turned on or off.
But the automation doesn’t work, I always receive “Error for satus”
Has anybody an idea what I am doing wrong?

This is my automation:

- alias: notify_1_mqtt_light_status
  initial_state: True
  hide_entity: False
  trigger:
    - platform: state
      entity_id: 
        - light.kitchen_node_1_led_light_1
        - light.sonoff_basic_1_relay
        - light.sonoff_s20_1_relay
  action:
    - service: notify.notify_1
      data_template:
        title: "{{ trigger.from_state.attributes.friendly_name }}"
        message: >
          {% if is_state('trigger.to_state', 'on') %}  \ud83d\udca1 ON          
          {% elif is_state('trigger.to_state', 'off') %} \u26ab OFF 
          {% else %} Error for status
          {% endif %}
          
          {{ states.sensor.current_date_time.state }}

is_state('trigger.to_state', 'on')

should be

is_state(trigger.entity_id, 'on')

Same for the other.

Or you could use

trigger.to_state.state == 'on'

Thank you very much for your fast help.
It’s working now.

Thats my working code now:

- alias: notify_1_mqtt_light_status
  initial_state: True
  hide_entity: False
  trigger:
    - platform: state
      entity_id: 
        - light.kitchen_node_1_led_light_1
        - light.sonoff_basic_1_relay
        - light.sonoff_s20_1_relay
  action:
    - service: notify.notify_1
      data_template:
        title: "{{ trigger.from_state.attributes.friendly_name }}"
        message: >
          {% if trigger.to_state.state == 'on' %}
            {{ "\ud83d\udca1 ON" }}            
          {% elif trigger.to_state.state == 'off' %}   
            {{ "\u26ab OFF" }}
          {% else %}          
            {{ "Error for status" }}
          {% endif %} 
          {{ states.sensor.current_date_time.state }}
1 Like