Time elapsed from entity state change

Hello.

I would like to make a sensor which shows how much time elapsed from when I turned off a light or a switch, or a state change of an entity.

Can anyone help me? I am not a programmer.

Thank you very much.

Here’s one I prepared earlier:

It will only work for past events. You want

states.domain.object_id.last_changed as the entity. e.g.

value_template: "{{ relative_time(states.light.my_light.last_changed) }}"
1 Like

Thank you very much. This works perfectly as well.