Fix thermostats sql script