I had a look to the Thermostat_Control wiki and because it was intend to be use to maintain a certain temperature, while my need is to handle 2 different temps at different times
I'm not a professional programmer, so maybe I've used a dirty way to reach the same result... please feel free to clean the code


THE PURPUSE:
- Have my COLD bathroom maintain a minimun temperature
- Have my COLD bathroom warm on working days (Mon->Fri) in the morning
THE REQUIREMENTS:
Because I do not have a thermostat, I've used some variables for setting up temps and tollerance, while the local temperature is gathered via an Oregon Scientific probe
of course, you need also something to power on to heat the room

the variables used are:
Bagnetto_Debug int 0
used for debugging in the code
Bagnetto_tDelta float 0.3
temperature tollerance
Bagnetto_tMin float 18.5
Min temperature to maintain
Bagnetto_tSet float 21.7
temperature in the morning

THE SCRIPT (type: DEVICE)
Code: Select all
debugger = tonumber(uservariables['Bagnetto_Debug'])
tSet = tonumber(uservariables['Bagnetto_tSet'])
tMin = tonumber(uservariables['Bagnetto_tMin'])
tDelta = tonumber(uservariables['Bagnetto_tDelta'])
tAct = tonumber(devicechanged['T. Bagnetto_Temperature'])
startTime = {"6","40"} -- Inizio T1 6:40
stopTime = {"7","00"} -- Fine T1 7:00
-- Acquisizione dell'orario
cTime = os.date("*t")
gTime = tonumber(os.date("%w")) -- Giorno della settimana 0-6 Domenica - Sabato
-- Conversione in decimale degli orari per la comparazione successiva
cTimeDec = (tonumber(cTime.hour) * 60) + tonumber(cTime.min)
startDec = (tonumber(startTime[1]) * 60) + tonumber(startTime[2])
stopDec = (tonumber(stopTime[1]) * 60) + tonumber(stopTime[2])
if debugger == 1 then
print ('>>> [TB] DEBUG >> start/stop:'..tostring(startTime[1])..':'..tostring(startTime[2])..'/'..tostring(stopTime[1])..':'..tostring(stopTime[2])..' vs real: '..tostring(cTime.hour)..':'..tostring(cTime.min))
print ('>>> [TB] DEBUG >> '..startDec..':'..stopDec..':'..cTimeDec)
end
commandArray = {}
if devicechanged['T. Bagnetto'] then
if ((gTime ~= 0) and (gTime ~= 6)) and (cTimeDec >= startDec and cTimeDec <= stopDec) then
tUse = tSet
pPfx = ">>> [TB] SVEGLIA >>> "
else
tUse = tMin
pPfx = ">>> [TB] MINIMO >>> "
end
if (tAct < (tUse - tDelta)) and (otherdevices['Presa Bagnetto'] == 'Off') then
commandArray['Presa Bagnetto'] = 'On'
print (pPfx..'Temperatura Attuale/Impostata: '..tAct..'/'..tUse..' (±'..tDelta..') Accensione Caldobagno')
elseif (tAct > (tUse + tDelta)) and (otherdevices['Presa Bagnetto'] == 'On') then
commandArray['Presa Bagnetto'] = 'Off'
print (pPfx..'Temperatura Attuale/Impostata: '..tAct..'/'..tUse..' (±'..tDelta..') Spegnimento Caldobagno')
else
if debugger == 1 then
print ('>>> [TB] NTD >>> Temperatura Attuale/Impostata: '..tAct..'/'..tUse..' (±'..tDelta..') Nessuna Azione da intraprendere ['..otherdevices["T. Bagnetto"]..']')
end
end
end
return commandArray
I use to convert time minutes and then compare them (i found this way the easier one... having a variable set as time does not allow me to compare with present time...)
Code: Select all
startTime = {"6","40"} -- Inizio T1 6:40
stopTime = {"7","00"} -- Fine T1 7:00
this way I have the bathroom at 22° when it's time to use it and at 18 during the rest of the day
It works fine to me...
I would like to implement a physical thermostat for the min temp in the room (rfxcom433 or ZWave)... any ideas about what to use?


ciao
M