It would count up from seconds and then to minutes since the sensor was updated.
This has not been working for some time and I know there was a breaking change in one of the recent releases. On the website it looks like this relative_time(timestamp)
If I use that method the state remains unknown.
If I use my original template the state stays at 0 seconds but if I put my original template into the template dev-tool it shows that it is working as it used to. As you can see by the “23 seconds”
I know I’m resurrecting an old thread here, but I finally got around to trying this and used your setup as a model, but I am confused about the value result. Is it showing minutes? Seconds? ??
You can use the this to show Seconds: "{{(as_timestamp(now())-as_timestamp(states.sensor.power_line_watts.last_updated)) | int }} Seconds"
Or you can pass the unit_of_measurement: sec parameter for proper history graphing.
You can do this for Minutes: "{{(as_timestamp(now())-as_timestamp(states.sensor.power_line_watts.last_updated)) | int //60 }} Minutes"
Or this to have it change as it counts up. You will have to create a sensor to monitor that sensor * The entity used here is for a different sensor: "{% if states('sensor.derick_location_for') | int <= 60 %}{{ states.sensor.derick_location_for.state}} Seconds{%elif states('sensor.derick_location_for') | int < 3600 %}{{ states.sensor.derick_location_for.state | int // 60 }} Minutes{%elif states('sensor.derick_location_for') | int >= 3600 %}{{ states.sensor.derick_location_for.state | round(common) | int * 0.000277 | round(4) }} Hours{%else%}??{%endif%}"
If anybody is looking at this thread now, please be aware that the relative_time issue has been fixed in the recent versions.
This works great now.
sensors:
living_room_movement:
friendly_name: Living Room Movement
value_template: '{{ relative_time(states.sensor.aeotec_multisensor_burglar_2_10.last_changed)}}'```
Then what appears in Lovelace if i open the sensor:
What appears in Lovelace in the page:
And this is actually what I need… thing is it doesn’t update right?
I noticed it if I call a service to reload the template entities, it does update on the Lovelace page (still not in the entity state though, but that’s fine for me.
So yeah, every minute automation or node-red big timer or whatever you wanna use to call the service and it works for me.
Maybe I have something wrong in my template, can’t really figure it out