Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


Question

Posted

Hi,

 

I use the scene below (found on the web) for irrigating the garden. It works great, but i do miss the option to enable/disable (or set) the days of weeks on which this scene has to run. now it runs every day, and i don't want that.

I am not able to add this functionality, so can somebody help me with this? i would like to be able to set a day of week on or off. for example:

monday=1

tuesday=0

wednesday=1

thursday=1

friday=0

etc

 

thanks in advance..

 

Ronny

 

this is the scene:

--[[
%% autostart
%% properties
%% events
%% globals
--]]
local irrigators = {178, 190, 186, 44}; --sprinklers
local startTime = {"22:00"}; --spriklers start time
-- org: local startTime = {"23:00", "12:17", "20:26", "21:00"}; --spriklers start time
local sectionTime = 30*60*1000; -- 75 minutes by default
local timeModification = 1; -- might be for example 1.5 - when temperature is high
local temperatureSteps ={25, 30}; --25 and 30 degree as thesholds for modifying sprinkling time
local humiditySteps = {50,60}; -- 40% and 70% of humidity as threshlodls for modifying springling time
local modificationStep = 0.25; --25% of modification time for each step
local criticalHumidity = 30; 
-- org: local rainDetector = 64;
local rainDetector = 0;
local startSource = fibaro:getSourceTrigger();
local temperature;
local humidity;

fibaro:setGlobal("StartTimeSprinkler", '22:00')
function localTime()
    local currentDate = os.date("*t");  
    local localTime = currentDate.day .. "/" .. currentDate.month .. "/" .. currentDate.year .. " " .. string.format("%02d", currentDate.hour) .. ":".. string.format("%02d", currentDate.min) .. ":".. string.format("%02d", currentDate.sec) ..  ": "
    return localTime
end

function isRaining()
-- org:    if(tonumber(fibaro:getValue(rainDetector, "value")) > 0) then
    if(rainDetector > 0) then
        return true;
    else
        return false;
    end
end
  
function timeModify()
   local modification = 1;
    -- temperature modification
   for i in pairs(temperatureSteps) do
       if(temperature >= temperatureSteps[i]) then
           modification  = modification + modificationStep;
        end
    end
    -- humidity modification
     for i in pairs(humiditySteps) do
       if(humidity <= humiditySteps[i]) then
           modification = modification + modificationStep;
       end
    end
    fibaro:debug(localTime() .. "Sprinkler time modified by: " .. modification);
    return modification;
end

function sprinkling()
    fibaro:debug(localTime() .. "Start sprinkling.");
    for i in pairs(irrigators) do
        fibaro:debug(localTime() .. "Section " .. i .. " starts. Sprinkling for " ..sectionTime *timeModification/60000 .. " minutes");
        fibaro:call(irrigators[i], "turnOn");
        fibaro:sleep(sectionTime * timeModification); 
        --fibaro:sleep(2000); --for debug purposes (disable line above, enable this line)
        fibaro:call(irrigators[i], "turnOff");
        fibaro:debug(localTime() .. "Section " .. i .. " stops.");
    end
    fibaro:debug(localTime() .. "Stop sprinkling.");
    return true;
end

function mainLoop()
    temperature =  tonumber(fibaro:getValue(3, "Temperature"));
    humidity =  tonumber(fibaro:getValue(3, "Humidity"));
    fibaro:debug(localTime() .. "Current weather contition: temperature - ".. temperature .. " degree, humidity - " .. humidity .."%");
    timeModification = timeModify();
    sprinkling();
end


----------  Loop
if (startSource["type"] == "autostart") then
   fibaro:debug(localTime() .. "Scene started automatically");
    while true do
        currentDate = os.date("*t");
        Time = string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min)
        for i in pairs(startTime) do
            if (Time == startTime[i]) then
                if(isRaining() == false) then
                 fibaro:debug(localTime() .. "Sprinklers start automatically (no rain).");
                    mainLoop()
                else
                    humidity =  tonumber(fibaro:getValue(3, "Humidity"));
                    if (humidity <= criticalHumidity) then
                fibaro:debug(localTime() .. "Sprinklers start automatically (raining, low humidity).");
                        mainLoop()                 
                    end
                end
         end
        end
        fibaro:sleep(1000);
    end
elseif(startSource["type"] == "other") then
    fibaro:debug(localTime() .. "Sprinklers start manually.");
    mainLoop()
end

2 answers to this question

Recommended Posts

  • 0
Posted

you need to use this one ;-) 

Please login or register to see this link.

  • 0
  • Inquirer
  • Posted
    9 hours ago, emielstroeve said:

    you need to use this one ;-) 

    Please login or register to see this link.

    Hi Emiel,

     

    thanks for the advise. i will test it..

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...