The dzvents-script below (ventilator-switch based on a humidity-sensor) worked fine under domoticz-version 3.87. After an update to version 4,97 this script and some others (also based on humidity) do not work anymore. In domoticz version 4.97 the versionnumber of dzvents is not visible anymore.
Th script has a test-mode, but also the test-mode does not work anymore!
Probably something small, but i cannot find the solution.
Can anybody help?
Thanks
Paul
Code: Select all
return {
active = true,
on = {
timer = { 'every 30 minutes' }
},
data = {
HumidityBefore = { initial = 50 }
},
execute = function(domoticz)
local debug = true
function debug_print(MyLine)
if debug then print(MyLine) end
end
--------------
local Vent = domoticz.devices('VentSchakelaarSL1-') -
SENSOR_NAME = 'Zolder TH_ch2'
TEST_MODE_HUMVAR = 'testHumidity' .. SENSOR_NAME
vochtpercentage = 60
PRINT_MODE = true
Temp = domoticz.devices('').temperature
--local Humidity = domoticz.devices('Zolder TH_ch2').humidity
--print(' hum ================================= :' ..Humidity)
if (tonumber(uservariables[TEST_MODE_HUMVAR]) > 0) then
current = tonumber(uservariables[TEST_MODE_HUMVAR])
if PRINT_MODE == true then
print('Current Humidity Test Mode: ' .. current)
end
else
current = domoticz.devices('Zolder TH_ch2').humidity
if PRINT_MODE == true then
print('Current Humidity: ' ..SENSOR_NAME .. current)
end
end
if (current == 0 or current == nil) then
print("dzVents: Zolder Humidity: current is 0 or nil. Skipping this reading")
else
print('Current Humidity: ' ..current)
print('hum before: ' ..domoticz.data.HumidityBefore)
if ( current >= vochtpercentage) then
debug_print ("dzventz: Zolder Humidity > dan: " ..vochtpercentage)
debug_print ("dzVents: Humidity: " .. tostring(current) .. " domoticz.data.HumidityBefore: " .. tostring(domoticz.data.HumidityBefore ))
local StartNeeded = ( ( current > vochtpercentage ) and ( Vent.state == 'Off' ) )
if StartNeeded then
print ("dzVents: Zolder Humidity: Fan off ==>> Switching fan on for 50 minutes")
Vent.switchOn()
domoticz.notify('vocht% >= 60(script VV-on_off): ', 'Vent. aan 50min: vocht%: ' .. current .. ' Temperatuur: ' ..Temp, domoticz.PRIORITY_LOW)
Vent.switchOff().afterMin(50)
end
domoticz.data.HumidityBefore = current --Humidity
end
end
end
}