Help with template trigger

I’m trying to get an template trigger when an attribute sensor is not = at END.

I cant get it to work

’ platform: template
value_template: “{{ state_attr(‘sensor.nhl_sensor’, ‘time_remaining’) | int != END }}” ’

Keep in mind that there are more than a thousand integrations so it can make it a lot easier if you include a screenshot(Community Guidline #14) of the entity’s info from the Developer Tools > States page and you format code blocks properly (Community Guideline #11).

Some issues in your template:

  1. Words without quotes around them (like END) are treated as variables… but you have not set a value for the variable END.
  2. If you meant END to be a regular word (i.e. a string) then a value converted to an integer will never equal a string.
  3. As of 2021.10 many filters (including int()) require an explicit default argument.

The following is just a guess based on what you posted, if it doesn’t work please post the data/screenshot from the States tool.

trigger:
  - platform: template
    value_template: >
      {{ not is_state_attr('sensor.nhl_sensor', 'time_remaining', 'END') }}

That’s not entirely true.

they don’t require a default. But if the result of the sensor value conversion is not a number (none, unknown, unavailable…) then without the default it will not render the result and throw an error in the logs.

If the sensor in the template is never in one of those conditions then the template will work fine without a default.

I have many of my templates that I’ve never added a default to and they work fine.

I’m not saying that it is or isn’t a best practice but just that it isn’t required.