Activation time sensor

I have tried this method, but I can’t get it to work

https://community.home-assistant.io/t/real-state-last-changed/15928/9