Airflow - problem with script
Posted: Thursday 27 May 2021 19:00
Hi
i tried to adopt one of script to my purposes:
After I manualy switch on fans and temperature(inside) falls below 25 degrees script can switch off, but there is no way to automaticaly switch them on after reaching 25 degrees
The setup is:
2 temperature sensors, and 2 fans ... the trick is that need to compare temperatures inside room and outside not to pump warmer air inside room in that case need to run fan pumping air from basement
Believe you can help
regards
i tried to adopt one of script to my purposes:
Code: Select all
-- Temp control
local scriptVar = 'tempControl3'
return
{
on =
{
timer =
{
'every minute', -- domoticz events based on timers are triggered once a minute max.
},
customEvents = -- used to increase frequency to once every 30 seconds.
{
scriptVar,
}
},
logging = {
level = domoticz.LOG_DEBUG, -- If set to domoticz.LOG_ERROR you will only see something if dzVents encountered an error
-- So best to start with domoticz.LOG_DEBUG until your script works as expected.
marker = scriptVar,
},
data = {
lowTemperature = { initial = true },
},
execute = function(dz, item)
if item.isTimer then
dz.emitEvent(scriptVar).afterSec(30) -- this will trigger the customEvent in the On section and therewith increase the frequency to every 30 seconds
end
local insideTemperature = dz.devices('TempInside').temperature
local outsideTemperature = dz.devices('TempOutside').temperature
local stfan = dz.devices('FanIn')
local safan = dz.devices('FanOut') -- this second use of 'switch' as varname does overwrite the previous one.
local stfanIsOff = stfan.state == 'Off'
local safanIsOff = safan.state == 'Off'
local lowerTemperature = 25
local higherTemperature = 45
local comingFromLow = dz.data.lowTemperature
local temperatureInRange = insideTemperature > lowerTemperature and insideTemperature < higherTemperature
dz.data.lowTemperature = insideTemperature < lowerTemperature -- remember coming from low
if stfanIsOff and safanIsOff and temperatureInRange and comingFromLow then -- between 25-45 and coming from < 25 ==>> switchOn
if insideTemperature < outsideTemperature then stfan.switchOn()
elseif insideTemperature > outsideTemperature then safan.switchOn()
end
elseif not temperatureInRange then -- > 24 or < 20 switchOff
if not stfanIsOff or not safanIsOff then
safan.switchOff()
stfan.switchOff()
end
if insidetemperature > higherTemperature then -- No longer coming from low
dz.data.lowTemperature = false
end
end
end
}
The setup is:
2 temperature sensors, and 2 fans ... the trick is that need to compare temperatures inside room and outside not to pump warmer air inside room in that case need to run fan pumping air from basement
Believe you can help
regards