Please help!
I am trying to use some inspiration from http://www.fibarouk.co.uk/five-things-to-do-with-your-new-home-center/to regulate my air heather pump, What I want it to do is that when any of my doors has been open for more than 45 sec, turn off the heater and then wait untill all the doors has been closed for 45 sec before turning on again. But unfortionatly i dont get it to work and cant se what the problem is. Sadly i am yet not experienced enought with lua butneed to learn, i now have 80 scenes reulating some 73 switches and sensors.
--[[
%% properties
93 value
%% globals
--]]
local Doorfront = 149 -- main door
local Doorback = 50 -- Rear door
local Doorside = 52 -- Side door
local heater = 218
local heatDelay = 45 -- 45 seconds (the value is in seconds)
local heatstart = 45 -- 45 seconds (the value is in seconds)
-- Only allow one instance of the current scene to run at a time
if (fibaro:countScenes() > 1) then
fibaro:abort()
end
local value, timestamp = fibaro:get(Doorfront, 'frontvalue')
local value, timestamp = fibaro:get(Doorback, 'backvalue')
local value, timestamp = fibaro:get(Doorside, 'sidevalue')
local value, timestamp = fibaro:get(Doorfront, 'frontvaluestart')
local value, timestamp = fibaro:get(Doorback, 'backvaluestart')
local value, timestamp = fibaro:get(Doorside, 'sidevaluestart')
if (frontvalue == '0') and (backvalue == '0') and (sidevalue == '0')then -- is the light off?
-- the doors are closed
-- keep looping until the door has been open for heatDelay time
while ((frontvalue ~= '0') or (rearvalue ~= '0') or (sidevalue ~= '0') or ((os.time() - timestamp) < heatDelay)) do
fibaro:sleep(1000) -- let other things happen for a second, just wait here
value, timestamp = fibaro:get(Doorfront, 'frontvalue')
value, timestamp = fibaro:get(Doorback, 'backvalue')
value, timestamp = fibaro:get(Doorside, 'sidevalue')
end
-- the doors has been open long enought
fibaro:call(heater, 'turnOff') -- turn off the fan
else
-- the doors are closed
while ((frontvalue = '0') and (rearvalue = '0') and (sidevalue = '0') or ((os.time() - timestamp) < heatstart)) do
fibaro:sleep(1000) -- let other things happen for a second, just wait here
value, timestamp = fibaro:get(Doorfront, 'frontvaluestart')
value, timestamp = fibaro:get(Doorback, 'backvaluestart')
value, timestamp = fibaro:get(Doorside, 'sidevaluestart')
end
fibaro:call(heater, 'turnOn') -- turn on the heater
end