Is it possible to get the time a service call was last made?

Hi,

I want to make an automation that can only run 40 mins since the last call to SERVICE CLIMATE.SET_TEMPERATURE

Essentially I use a motion sensor to turn off the thermostat 10 mins since the last motion… however when I set the temperature I want the heating to remain on for 40 mins regardless of the motion sensor.

This essentially revolves around the automation that turns off the thermostat… it needs to check the last time the temperature was set and only turn it off if it was over 40 mins ago.

I’ve searched around but can’t find any discussions around this.

Any ideas?

Cheers