Comparison is wrong somewhere

Hi,

I’m monitoring my Odroid on several specs.

When something is not OK, I get an e-mail. This works fine, except that I don’t get the values.

Must be something stupid, but I don’t know…

alias: Monitoring Odroid N2+
description: ''
trigger:
  - platform: template
    value_template: >-
      {{ states('sensor.processor_temperature') | float >=
      states('input_number.number_monitor_system_processor_temperature_max') |
      float }}
    for: '00:00:30'
condition: []
action:
  - service: notify.gmail
    data:
      message: >
        Systeem monitoring probleem ({{ trigger.to_state.object_id }}) : 

        {% if states('trigger.to_state.object_id') == "processor_temperature" %}
          {{ states('sensor.processor_temperature') }} (max : {{states('input_number.number_monitor_system_processor_temperature_max') }})
        {% endif %}

      title: Systeem monitoring probleem ({{ trigger.to_state.object_id }}) !

This is the email :

Schermafbeelding 2022-02-21 172141

change that to

{% if trigger.to_state.object_id == "processor_temperature" %}

Works, thank you !

I suppose my solution was a problem of spaces ?

If you want the technical reason, you took trigger.to_state.object_id, which is a state object where you’re accessing the object_id, and you turned that into a string by wrapping it in quotes. Then you took that string and asked the state machine for it’s state. So, you shouldn’t have made it a string, you should have just kept the object as-is.

This:

trigger.to_state.object_id → correct

vs this:

states('trigger.to_state.object_id') → incorrect

That’s clear, thank you !