Unless I am missing some requirements, I think that you could do this in a much “cleaner” way.
If you can get a temperature sensor into home assistant, you could use the generic thermostat component and then you would have temperature control.
If you can’t do that for some reason, and you want to have a button that turns something on for a certain period of time, I would just make a script that has three actions: turn on the switch, run a delay of the desired length (which could be stored in an “helper” input), and then turn off the switch. You could then put that script on an entity button on lovelace. If you want to automatically have this happen on some occasions, you could write an automation that just turns on the script when necessary.
An automation fires automatically based on some trigger, checks some conditions, and then runs an action. A script is just the action portion of an automation.