Sudden value_template error with HA 0.86.1

Hey friends!

I’ve had this value_template working for some time. However, it isn’t working with the latest update and I can’t figure out why. Any ideas?

  - condition: template
    value_template: '{{ (as_timestamp(now()) - as_timestamp(states.automation.notify_ios.attributes.last_triggered | default(0)) | int > 7200)}}'

I’d suggest this:

  - condition: template
    value_template: "{{ as_timestamp(now()) - as_timestamp(state_attr('automation.notify_ios', 'last_triggered'))|float > 7200 }}"

If automation.notify_ios is not in the state machine (for some reason) your template will fail, whereas this one will just use a value of 0.0 for that term of the equation (since the state_attr function will return none, and the float filter will change none to 0.0.)

Thanks pnbrucker. How do you know this stuff? Do you have a similar template or are you just a template expert? :slightly_smiling_face:

there’s a whole section that outlines these functions for templates

also, he’s an expert