panboy180
(Daniel Oliden)
January 30, 2019, 4:10am
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.)
panboy180
(Daniel Oliden)
February 1, 2019, 12:56am
3
Thanks pnbrucker. How do you know this stuff? Do you have a similar template or are you just a template expert?
petro
(Petro)
February 1, 2019, 1:06am
4
there’s a whole section that outlines these functions for templates
also, he’s an expert