




--[[ %% properties 3 Temperature --   85 value --  1 86 value --  2 87 value --  3 %% events %% globals tempSet --]] local temp1 = tonumber(fibaro:getValue(85, "value")) --   1 local temp2 = tonumber(fibaro:getValue(86, "value"))--   2 local temp3 = tonumber(fibaro:getValue(87, "value"))--   3 local tempOUT = tonumber(fibaro:getValue(3, "Temperature"))--     local IDCooler = 99 --  local IDCond = 100 --  local IDCondHeat = 102 --   ( ) local IDFloor = 23 --   local IDHeat = 24 --  local tempset = fibaro:getGlobalValue("tempSet") local workmode = fibaro:getGlobalValue("Workmode") local tempInside = (temp1 + temp2 + temp3) / 3 local date = os.date("!*t", now) local currtime = date.hour*60 + date.min --    local d = tempset - tempInside local w = tempset - tempOUT --globals: -- Workmode -- TempSet -- WinStatus -- Isventnow -- CHeating local cHeating = "on" local winStatus = "closed" print("Starting Climate Control") print("t   = "..tempInside..", t  = "..tempset) print("Workmode: "..workmode..", Windows: "..winStatus,", Central Heating: "..cHeating) --    if (fibaro:getGlobalValue("Workmode1") == "At work") then --  if (tempInside < 18) then --  if (cHeating == "on") then --   print(" ") fibaro:call(IDHeat, "turnOn") if(Isventnow == "no") then fibaro:call(IDCooler, "turnOff") end fibaro:call(IDCondHeat, "turnOff") fibaro:call(IDCond, "turnOff") fibaro:call(IDFloor, "turnOff") elseif (windows == "closed") then --    print("  ") fibaro:call(IDCondHeat, "turnOn") fibaro:call(IDCond, "turnOn") fibaro:call(IDFloor, "turnOff") if(Isventnow == "no") then fibaro:call(IDCooler, "turnOff") end fibaro:call(IDHeat, "turnOff") end --     elseif (tempInside > 21) then --  if(fibaro:getValue(IDHeat, value) >0) then print(" ") fibaro:call(IDHeat, "turnOff") else fibaro:call(IDCondHeat, "turnOn") fibaro:call(IDCond, "turnOn") fibaro:call(IDFloor, "turnOff") if(Isventnow == "no") then fibaro:call(IDCooler, "turnOff") end end end --     elseif d < 1 and d > -1 then print(" ") --  fibaro:call(IDCondHeat, "turnOff") fibaro:call(IDCond, "turnOff") --  if(Isventnow == "no") then fibaro:call(IDCooler, "turnOff") end --  fibaro:call(IDHeat, "turnOff") --   fibaro:call(IDFloor, "turnOff") --     elseif (cHeating == "on") then --   if (d >= 1) then -- if (d <= 3) then print("  ") --   fibaro:call(IDFloor, "turnOn") fibaro:call(IDCondHeat, "turnOff") fibaro:call(IDCond, "turnOff") fibaro:call(IDHeat, "turnOff") fibaro:call(IDCooler, "turnOff") elseif (d > 3) then print("    ") --   fibaro:call(IDFloor, "turnOn") --  fibaro:call(IDHeat, "turnOn") fibaro:call(IDCondHeat, "turnOff") fibaro:call(IDCond, "turnOff") if(Isventnow == "no") then fibaro:call(IDCooler, "turnOff") end end elseif (d <= -1) then -- print(" ") --   if(Isventnow == "no") then fibaro:call(IDCooler, "turnOn") end lastCondition = currTime end --    elseif (cHeating == "off") then -- if (d >= 1) then if (w <= 0) then print(" ") --   if(Isventnow == "no") then fibaro:call(IDCooler, "turnOn") end fibaro:call(IDCondHeat, "turnOff") lastCondition = currTime elseif (d < 4) then print(" ") --   fibaro:call(IDCondHeat, "turnOff") if(Isventnow == "no") then fibaro:call(IDCooler, "turnOn") end lastCondition = currTime elseif (winStatus == "closed") then print("   ") --     fibaro:call(IDCondHeat, "turnOn") fibaro:call(IDCond, "turnOn") if(Isventnow == "no") then fibaro:call(IDCooler, "turnOff") end end elseif (d <= -1) then -- if(w >= 0) then if(d > -4) then print(" ") --   if(Isventnow == "no") then fibaro:call(IDCooler, "turnOn") end fibaro:call(IDCondHeat, "turnOff") fibaro:call(IDCond, "turnOff") elseif (winStatus == "closed") then print(" ") --   fibaro:call(IDCond, "turnOn") fibaro:call(IDCondHeat, "turnOff") if(Isventnow == "no") then fibaro:call(IDCooler, "turnOff") end end elseif (winStatus == "closed") then print(" ") --   fibaro:call(IDCond, "turnOn") fibaro:call(IDCondHeat, "turnOff") if(Isventnow == "no") then fibaro:call(IDCooler, "turnOff") end end end end  function vent_forced() local workmode = fibaro:getGlobal('Workmode') local isventnow = fibaro:getGlobal('Isventnow') local lastModified = fibaro:getGlobalModificationTime('Isventnow') if ((os.time() - lastModified) < 10800) then print ("      "..(os.time() - lastModified)) print ("     3- ") end if ( workmode == 'At home' and isventnow == 'no' and (os.time() - lastModified) > 10800 ) then print ("      "..(os.time() - lastModified)) fibaro:call(99, "turnOn") fibaro:setGlobal('Isventnow', 'yes') print ("     3 ") print ("   ") fibaro:sleep(900000) fibaro:call(99, "turnOff") fibaro:setGlobal('Isventnow', 'no') print ("   ") end end local sourceTrigger = fibaro:getSourceTrigger() if (sourceTrigger["type"] == "autostart") then while true do fibaro:debug('  ') local currentDate = os.date("*t") if (currentDate.min >= 0 and currentDate.min <= 60) then vent_forced() end fibaro:debug(' ,    1 ') fibaro:sleep(3600*1000) end end Source: https://habr.com/ru/post/398391/
All Articles