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


  • 0

Scena - włącz się tylko raz o określonej porze


wojtas810

Question

Witam 

 

Potrzebuje stworzyć scenę która będzie codziennie rano pomiędzy 7.30 a 9.30 sprawdzała czy czujka ruchu jest naruszona, jeśli tak to wywoła ona jakąś reakcję, ale tylko raz dziennie.

Dlatego potrzebne na pewno jest zrobienie zmiennej która będzie zmieniała wartość po naruszeniu z 0 na 1 

Niestety moje początki z Lua są trudne czy ktoś by mi mógł pomóc w uporządkowaniu aby zaczęło działać ?

 

--[[
%% properties
%% events
%% globals
--]]
if fibaro:countScenes() > 1 then 
 fibaro:debug("SCENE ABORT --------------------------") 
end

function toMinutes(czasHHMM) 
local a 
if type(czasHHMM) => "07:30"
if type(czasHHMM) =< "09:30"

end 
      then 
      fibaro:setGlobal("rano", "0") 
      else 
      fibaro:setGlobal("rano", "1") 
    end 
  
fibaro:sleep(60*1000) 
    
end 
 

 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

The topic has been moved from "

Please login or register to see this link.

" to "

Please login or register to see this link.

".

 

Temat został przeniesiony z "

Please login or register to see this link.

" do "

Please login or register to see this link.

".

Link to comment
Share on other sites

  • 0
  • Inquirer
  • W razie czego dzięki koledze z forum udało się i działa to co wyżej chciałem @10der

    Problem pojawiał się ponieważ w jednej scenie nie dało się właczyć to czego chciałem dlatego trzeba po przez tą scenę uciekać do innej - może sie komuś to przyda. 

    Scena wywoływana jest tylko raz dziennie między 7.00 - 9.00 pod warunkiem ze motion wykryje ruch 

     

    Jeszcze raz dzięki @10der


    --[[
    %% properties
    602 value
    %% weather
    %% events
    %% globals
    --]]

    local motionId = 602;
    local morningTime = "07:00-09:00";

    local startSource = fibaro:getSourceTrigger();

    function between(str)
          -- get current time
        local t = os.date("*t", os.time())
        local h1,m1,h2,m2 = str:match("(%d+):(%d+)-(%d+):(%d+)")
        m1, m2, t = h1*60+m1, h2*60+m2, t.hour*60+t.min
        if (m1 <= m2) then
          return m1 <= t and t <= m2 -- 01:00-02:00
        else
          return m1 <= t or t <= m2 -- 23:00-21:00
        end
    end

    function isToday()
           local when = tonumber(fibaro:getGlobalValue('I_got_up', 0));
        local daysfrom = os.difftime(os.time(), when) / (24 * 60 * 60);
        local wholedays = math.floor(daysfrom);
          
        fibaro:debug(wholedays); -- 0 today > 0 next days

          if wholedays == 0 then
            return false;
        else
            fibaro:setGlobal("I_got_up", os.time())
            return true;
        end
    end

    if ( ( tonumber(fibaro:getValue(motionId, "value")) > 0 ) or
         ( startSource["type"] == "other" ) ) then
      
          fibaro:debug("Motion detected!");
          -- is morning?
        if between(morningTime) then
            fibaro:debug("Morning hours");
            if isToday() then
                  fibaro:debug("dowolne przejście lub właczenie inej sceny ");
              else
                  fibaro:debug("Do jutra");
              end
        end
    end

    • Thanks 1
    Link to comment
    Share on other sites

    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...