thermostat for cooling and heating
Posted: Thursday 11 October 2018 15:45
hi, i created a lua thermostat that is able to menage:
hysterisys modificable
set if it's heating or cooling mode
i simply created:
1) dummy device named "temp dummi mqtt" with a ds18b20 that is the probe to read the temperature
2) dummy device as switch named "prova termostato" (that is the switch connected to the room that i want to cool or heat)
3) a summy device as thermostat named "termostato mansarda" that is the set point
now i would like to implement in dzvents adding:
1) i have every room of my house that is indipendent (every room has one temperature sensor, and every room is able to heat/cooling without triggering the other) so using a code that could be mody adding rooms
2) the possibility to plan the days and hours where i want to have different set point for every room
is it possible to have only one dzvents to perform that?
hysterisys modificable
set if it's heating or cooling mode
i simply created:
1) dummy device named "temp dummi mqtt" with a ds18b20 that is the probe to read the temperature
2) dummy device as switch named "prova termostato" (that is the switch connected to the room that i want to cool or heat)
3) a summy device as thermostat named "termostato mansarda" that is the set point
Code: Select all
--
-- Domoticz passes information to scripts through a number of global tables
--
--
--
--
local heating_probe = 'temp dummi mqtt'
local thermostat_setpoint = 'termostato mansarda'
local heating_unit = 'prova termostato'
-- Use when a combined sensor (e.g. temperature and humidity) is used
-- Replace in "otherdevices[heating_probe]" to "otherdevices[heating_probe]" by "temp_only" (in the 2nd "if" and in the "elseif".
-- Remove the -- in the next two lines:
--local naartekst = (tostring (otherdevices[heating_probe]))
--local temp_only = (string.sub(naartekst,1,4)) -- the digits (1,4) do point out what characters of the string are needed.
local hysteresis = 0.5
local season = 2 -- 1=winter(heating) 2=summer(cooling)
commandArray = {}
-- loop through all the devices
for deviceName,deviceValue in pairs(otherdevices) do
if (season ~= 2) then
if (deviceName== thermostat_setpoint ) then
if tonumber(deviceValue) < tonumber(otherdevices[heating_probe]-hysteresis) then
if (otherdevices[heating_unit] == "On") then
-- commandArray['SendNotification']='Heating is off'
commandArray[heating_unit]='Off'
print("Heating is Off")
end
elseif tonumber(deviceValue) > tonumber(otherdevices[heating_probe]+hysteresis) then
if (otherdevices[heating_unit] == "Off") then
commandArray[heating_unit]='On'
-- commandArray['SendNotification']='Heating is on'
print("Heating is On")
end
end
end
elseif (deviceName== thermostat_setpoint ) then
if tonumber(deviceValue) > tonumber(otherdevices[heating_probe]+hysteresis) then
if (otherdevices[heating_unit] == "On") then
-- commandArray['SendNotification']='Cooling is off'
commandArray[heating_unit]='Off'
print("Cooling is Off")
end
elseif tonumber(deviceValue) < tonumber(otherdevices[heating_probe]-hysteresis) then
if (otherdevices[heating_unit] == "Off") then
commandArray[heating_unit]='On'
-- commandArray['SendNotification']='Cooling is on'
print("Cooling is On")
end
end
end
end
-- loop through all the variables
for variableName,variableValue in pairs(uservariables) do
end
return commandArray
1) i have every room of my house that is indipendent (every room has one temperature sensor, and every room is able to heat/cooling without triggering the other) so using a code that could be mody adding rooms
2) the possibility to plan the days and hours where i want to have different set point for every room
is it possible to have only one dzvents to perform that?