Our boat is in the water all year round (except for repairs and servicing), as we like to take her out a couple of times over the winter months we don't winterize the engine like you guys do in the US. The air temperature doesn't get "much" below zero for any length of time and the bay where we are is heated by the Gulf Stream.
The marina also has two rivers flowing through it which helps to keep the temperature up (and the salinity down) the lowest winter water temperature in the marina has been around 5deg C for the last few years which keeps the engine compartment around 3deg C
but we have a tube heater in the engine compartment just in case.
The heater has been controlled by a thermostat (a rather cheap affair) so with the help of my son an electrical engineer we made this one.


We used a stainless steel thermocouple probe connected to a digital programmable thermostat accurate to .3deg C with current temperature display, it is set to switch the heater on at 1deg C and off at 3deg C and also has an hour meter to record use.
I know it's not infallible but it should work in our situation. We also take measures regarding the rest of the boat.
Just thought I would share.