Caldav sensor template

So i’m struggling with caldav and a offset with the start time.
No my thermostat is turning on in the morning when someone is home. I want to make it smarter and only turn it on when someone is home and not leaving the house in the next 2 hours according to my calendar.
My calendar sensor is on when my appointment starts. I want it to be on 2 hours before my appointment starts without having to rename the title of the appointment.

Is this fixable and how?