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

2PIR 1 dimmer2


julesmartens

Question

Hi,

 

In our hallway of about 8m long we have lights that we want to be activated by motion detection. I have two PIR’s installed to make sure I get acurate motion detection at any location in the hallway. Lights are connected to a dimmer2 (pulse switched).

 

when PIR is breached a scene is triggered. Scene will switch on the light at predefined level and loop until PIR is safe and timer that I set reached 0. At 0 lights will be switched off. This works.

 

Problem1;

When motion is detected (Seen by the light of the mulitisensorPIR) it takes 1-2seconds before lights switches on. I read online that delay can be caused because communication between dimmer2 and PIRs goes thru HC2.

Can I link 2 pir to one dimmer2 and have a timeout function? Goal is to have communication without hc2 being involved(faster).

 

Problem2

I sometimes have a 5 secs late response.

even if I just arrive home and nothing is in use yet.

any ideas?

 

problem3

In hc2 I set max scenes to 4 instances for this scene, though still I get the ‘error too many tuns.’

in the code I abort when scene is triggered while lights on, though still I get notifications that max amount of a running instance for this scene has reached. What to do to get rid of scene errors max instances reached? Note increase the number of simultanious instances results in strange behavior, late on, off when needed. 

 

 

Thanks

jules

 

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hello,

 

If you only need to turn on-off the lights try associating the group 2 and setting the parameter 6 depending on the time you want the lights to turn on.

 

The drawback is that you will not be able to turn on the lights only when it is dark.

 

Also could you share the scene that you are running?

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Hi Axeman and 10der,

     

    @Axeman

    I have never changed the groups but will look into this.

    You asked for my current code, I pasted it at the bottom op my reply.

    FYI: my hallway is without windows so the PIRs should always work.

    Your suggestion might work but I have to figure out how to set group 2 as you proposed.

    Any idea how to tackle problem #3? I have in the scene set the max number instances is 5 and in the code I added a line to abort when the scene is running so I dont understand why I keep on getting these notifications "too many instances" in my notification center.

     

    @10der

    Its clear to see that you are very familiar with code. Unfortunately that's not the case for me. I normally re-use the code shared by other users.

    See below the code I used (based on Thomas his input).

    I normally only re-use code if the code makes (a little bit) sense to me. 

    If I have to troubleshoot my system I don't want to be fully reliable on support from others. 

    I'm afraid your code is a bit too complex for me so I'm reluctant to use it.

     

     

     

     

    =================================================================================================

    my current code

    =================================================================================================

    --[[                         
    %% autostart
    %% properties
    263 value
    269 value
    %% globals
    --]]

    -- This program use a PIR to turn on light. If there is movement during this period
    -- the timer is reset. If the switch for the light is used manually the light will be
    -- turned off as it will when the program terminates.
    -- As standard the light is on for 50 seconds - but that can be changed in the
    -- variable section below.
    -- Made in Denmark by Thomas G. Nielsen 2017.

     

    -- standard headers ----------------------------------
    local Debug = false

    Debug = function (debug,color, message )
      if (debug) then
          fibaro:debug(os.date("%x")..string.format('<%s style="color:%s;">%s</%s>', "span", color, message, "span")); 
      end
    end

    if (fibaro:countScenes() >1) then
    Debug(true,"purple", " too many instances --> abort ");
    fibaro:abort()
    end


    local trigger = fibaro:getSourceTrigger()

    if         (trigger['type'] == 'property') then Debug(true, "Grey", ' scene triggered by - Source device = ' .. trigger['deviceID'])
    elseif (trigger['type'] == 'global')     then Debug(true, "Grey", ' scene triggered by - Global variable source = ' .. trigger['name'])
    elseif (trigger['type'] == 'other')     then Debug(true, "Grey", ' scene triggered by - Other source')
    end

     

    ----hometable setup----------------------------------
    local jT = json.decode(fibaro:getGlobalValue("HomeTable"))
    --syntax--jT.room.device

    -- used devices and its id
    fibaro:debug("device: gang - PIR1 = ID: " ..jT.gang.PIR1GANG)
    fibaro:debug("device: gang - PIR2 = ID: " ..jT.gang.PIR2GANG)
    fibaro:debug("device: gang - ganglamp = ID: " ..jT.gang.ganglamp)

     

    ----Main scene----------------------------------------

    local PIR1 = jT.gang.PIR1GANG --263
    local PIR2 = jT.gang.PIR2GANG --269
    local dimmer = jT.gang.ganglamp --110

    local starttimer = 50; -- Time for light to be on in seconds
    local timer = (starttimer); -- timer
    local dimlevel = 10 -- dim level

     

    ------------- Do not edit program below this line -----------------------------------------------
     
    -- Turn on / off light---------------------------------
    if ( (tonumber(fibaro:getValue(PIR1, "value")) > 0) or (tonumber(fibaro:getValue(PIR2, "value")) > 0) and (tonumber(fibaro:getValue(dimmer, "value")) < 1)) then 
        fibaro:call(dimmer, "setValue", (dimlevel)); 
        Debug(true,"Orange", " Lights on") -- - dimlevel set to: "..(dimlevel)"%");
    end
     
    ------------------ Starting loop ----------------------------------------
    repeat
            timer=timer-1;
            fibaro:sleep(1000);
     
    -- if movement then restart timer------------------
           if ( (tonumber(fibaro:getValue(PIR1, "value")) >0) or (tonumber(fibaro:getValue(PIR2, "value")) >0) )  then
                timer=starttimer;
                Debug(true,"Yellow", "movement detected , Timer reset");
                if(tonumber(fibaro:getValue(PIR1, "value")) >0) then  
                  Debug(true,"lightYellow"," movement @PIR1 ") else
                  Debug(true,"lightyellow"," movement @PIR2 ") 
                end
           end
     
    -- Turn off light if switch used manually----------
      --if (tonumber(dimmer) < 1 then
         
              if (tonumber(fibaro:getValue(dimmer, "value")) <1) then
                 Debug(true,"red", " Switch used manually - Light off");
                   timer=0
            end
    until (timer<1)
     
    ---------------- Program terminates. Light off ----------------------
    if ( (tonumber(fibaro:getValue(PIR1, "value")) <0) and (tonumber(fibaro:getValue(PIR2, "value")) <0 )) then
        while( dimlevel > 10 ) 
              do 
              fibaro:call(jT.gang.ganglamp , 'setValue' , dimlevel) 
            fibaro:sleep(20)
            dimlevel = (dimlevel -0.4)
          end
    end  

    fibaro:call(dimmer, 'turnOff' )
    Debug( true,"Green",' hal verlichting uitgeschakeld')    

    =====================================================================================================================

     

    Link to comment
    Share on other sites

    • 0

    the current code is not my current code.

    but if you wish you can look here 

    for complete solution!

     

     

    Edited by 10der
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • thanks!

    Funny to see it refers to the same source as what I used in my scene. (I mainly added my json hometable as reference for the device IDs).

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