Thermostat like rule

If you prefer python, take a look at the jython automation addon