Virtual Thermostat explanation

Hi - I am new to smartthings and been trying to understand the virtual thermostat smartapp. Went through the code as well, but am a bit confused on the EMER temperature value.
My use case is to turn on a fan (connected to a ST smartplug) when the house gets too warm and to turn the fan off when the house gets to 18 degrees C. This should only happen in night and away modes as its for our dog. I don’t have a motion sensor in this area, just a ST multi-purpose sensor reporting temperature.
So i have put the set temp as 18. Left the motion, minutes and emer temp as blank. Set the mode to cool and set the specific modes as night and away. Do I need to have something in emer temp? Whats the minutes input for - motion or temp readings?
Currently the fan goes on, but never goes off, even though the mode changes from away/night to home.
Also I have noticed my multi-purpose sensor only reports temperature once every 1-3 hours (not minutes!) and this means the thermostat triggers the fan on after significant delays of several hours and I have never seen it go off! Is this normal? This is a new starter kit purchased just a week ago from amazon uk.
If someone can explain the how the virtual thermostat code works it would be great!
Thanks for your guidance!

I have noticed last night the fan does go off once the set temperature is reached and if the mode is night/away, but after the 2-5hr delay since my sensor is reporting temperature every 2-5hrs. If the sensor reports temperature when the mode has already changed to home, then the fan remains on, when ideally it should go off, the moment the mode changes to something not specified in the virtual thermostat app. Also I don’t see anything related to specified modes (away/night/home) in the virtual thermostat source code, and so unsure how it would influence the app!

Thanks - i agree if the sensors are reporting temperature every 2-5 hours (due to stable temperatures) that might explain the delays in the fan/switch going on and I can live with that limitation- however it does not explain why the fan/switch does not go off - when the mode changes to home. The source code has nothing on ‘home/night/away mode’ in it, even though the app definitely asks which specific modes you want it to run in and it definitely triggers while I am away/night just doesn’t turn off once I come back home.
Also I am not able to understand if I need to leave emer temp as blank or put something in there - as per the source code it is optional input - but unclear what it does.

Thanks for the advice on core! I’ve recreated the above use case with modes and temperatures in my first latching piston :slight_smile: lets see if that works better than virtual thermostat!

I can’t seem to find CoRE in the Smart Apps, looking in Climate Control folder. I’d like to give it a try because I have the problem of a fan not shutting off. I heat with a wood stove but also have forced hot water and oil furnace. There is a floor vent going into my bedroom. My bedroom will get really cold when using the wood stove, thermostat is in room next to the stove. I have a fan in the floor and running that pushes a lot of the heat into the bedroom. I have one of the first gen (I think) ST motion sensors in the bedroom for temp, I have the fan plugged into a WeMo (connected to ST) Outlet switch. I am using the Virtual Thermostat app at the moment. I finally got it to work last night but won’t shut off. I see there are some issues with how often the temp reports. Not sure what to do about that. I’ll give this CoRE a try if I can find it.