-- Monitor the temperature and -- turn fans on and off as needed function monitor_temperature() local now=os.time() local TOO_HIGH_TEMP=80 local OK_TEMP=75 while true do local temperature=meter.values["sensors.0.temperature"] if temperature then local ftemp = kelvin_to_farenheight(temperature.value) if ftemp >= TOO_HIGH_TEMP and outlet[1].state == off then outlet[1].on() log.notice(string.format("Turning on fans - temperature is %gºF, current time is %s",ftemp,os.date("%H:%M:%S",now))) else if ftemp <= OK_TEMP and outlet[1].state == on then outlet[1].off() log.notice(string.format("Turning off fans - temperature is %gºF, current time is %s",ftemp,os.date("%H:%M:%S",now))) end end else LOG("No temperature meter found!") end delay(300) -- Check again in 5 minutes end end