Domoticz thermostat script for tv-bench cooling

Hi

This is my first LUA-script for Domoticz. I have a TV-bench where I have all my media devices, media-computer, av-receiver and game consoles…

The bench is rather small, which led to it become very hot in it. My solution was to mount PC-fans to ventilate out the hot air.

To control my fans I used a 433Mhz switch. I also added a temperature sensor and wrote a small thermostat script for Domoticz.

In my Domoticz web-page I added:

  • Dummy thermostat and named it “TV-Bänk”
  • Dummy switch and named it “TV-Bänk kylning”

And I already had the temperature sensor “Förstärkare” and the fan-switch “Fläkt tv-bänk”

 

 

-- Thermostat script for Domoticz
-- To control my fans in my tv-bench
-- Author: Christoffer, christoffer@cwesystems.com


-- Variables --
local hysteresis = 10  --5 degree hysteresis
local sensor = 'Förstärkare' --Temperature sensor
local thermostat = 'TV-Bänk' --Dummy-thermostat in domoticz
local cooler = 'Fläkt tv-bänk' --The cooler to control
local thermostatControl = 'TV-Bänk kylning' --Thermostat control signal

-- Control script --
commandArray = {}

if (devicechanged[sensor]) then
	if(otherdevices[thermostatControl] == 'On') then
		if (tonumber(otherdevices[sensor]) > tonumber(otherdevices[thermostat])) then
			commandArray[cooler] = 'On'
		elseif ((tonumber(otherdevices[sensor])) < (tonumber(otherdevices[thermostat] - hysteresis))) then
			commandArray[cooler] = 'Off'
		end
	else
		commandArray[cooler] = 'Off'
	end
end
return commandArray

Leave a Reply

Your email address will not be published. Required fields are marked *