Came across this as an example:
{{ (now()) - as_timestamp(state_attr('automation.open_the_garage_door_when_shazz_or_jeff_arrive_home', 'last_triggered')) > 60 }}
But I get the error of:
ValueError: Template error: as_timestamp got invalid input 'None' when rendering template '{{ (now()) - as_timestamp(state_attr('automation.open_the_garage_door_when_shazz_or_jeff_arrive_home', 'last_triggered')) > 60 }}' but no default was specified
I assume there has been an update in how templating works, as a novice, anyone have a suggestion on how to rewrite this please?
Do you have A automation called?
automation.open_the_garage_door_when_…_arrive_home
If you do, has this been triggered, & what is the last triggered timestamp?
suggests that it can’t calculate it.
I would suggest you post more details.
Yes I do, however this is a condition in the automation, that has not run yes as the condition fails.
Let me try removing it and try again.
NB: Pixilating for the privacy of my family.
this is your clue.
you should specify a default
check the thread on that, it has been a while.
btw, if this has never been triggered, add this t the template for a first run:
{{now() - this.attributes.last_triggered > timedelta(hours=delay) if
this.attributes.last_triggered is not none else true}}
also, note the this.attributes.last_triggered
which you can use to reference the automation itself, without explicitly naming it
1 Like
Ok… I disabled it (the template condition), ran the automation and re-enabled it. Seems to be working now.
If you go to Developer tools > Services > Automation: Trigger
Select “Skip conditions”
You can execute the automation.
For future reference.