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


Recommended Posts

Posted (edited)

@jgab

Jan i have another issue..This line used to work on my all installations

 

Please login or register to see this code.

Please login or register to see this attachment.

 

 

@jgab

Jan i figured out that variable office_controller_lastPressed can not be accessed inside the rule..that's why it doesn;t work, but this was working so far

Edited by Neo Andersson
Posted

Jan whats wrong? Test 5 result is gordijn_toestemming=false but triggers are true

I checked there are no other rulesor checks  with gordijntoestemming=false

I opend and closed window/ door to update again their status

Please login or register to see this code.

Please login or register to see this code.

 

  • Topic Author
  • Posted
    15 hours ago, Neo Andersson said:

    @jgab

    Jan i have another issue..This line used to work on my all installations

     

    Please login or register to see this code.

    Please login or register to see this attachment.

     

     

    @jgab

    Jan i figured out that variable office_controller_lastPressed can not be accessed inside the rule..that's why it doesn;t work, but this was working so far

    So, where do you update office_controller_lastPressed ? When the rule tries to do the subtraction it says that the value of office_controller_lastPressed is a boolean.

    So have a ook in other places you assign something to office_contrioller_lastPressed.

    If I add this it works for me

    Please login or register to see this code.

    office_controller_lastPressed = os.time()

    Posted

    Im trying to create a Rule that triggers when a count of minimum 4 breached from a PIR sensor within max two minutes.

    To "measure"  that someone is staying at a room, and not just passing.

     

    Something like this 

    rule("236:Breached & BreachedCounter >= 4 & @Now < (2 minutes since first breached of the last 4 breached) => Heater:on ; Reset BreachedCounter

    rule("236:Breached => BreachedCounter = BreachedCounter+1

     

    Getting the time from the last trigger of these 8 can gathered from the History. But is not trivi to get the oldest timestamp


     => api.get("/events/history?from=@now-120&objectType=device&objectId=236 (Then i need to count events, should be more than 4) actually it need to be 8, because the output is not separating Breached & Safe  
     => api.get("/events/history?objectType=device&objectId=236&numberOfRecords=8 (then i need to check last event is les then 120 sec old.) actually it need to be 8, because the output is not separating Breached & Safe 

    Will return eight almost identical data sets, were I need to check the oldest timestamp should not be older than @Now-120

     

    What is a good way of creating a Rule that triggers when a count of minimum 4 breached from a PIR sensor within max two minutes. ?

     

    Please login or register to see this spoiler.

     

  • Topic Author
  • Posted
    2 hours ago, Sjakie said:

    Jan whats wrong? Test 5 result is gordijn_toestemming=false but triggers are true

    I checked there are no other rulesor checks  with gordijntoestemming=false

    I opend and closed window/ door to update again their status

    Please login or register to see this code.

    Please login or register to see this code.

     

    So, if you run rule("test5=true") to test your check, it doesn't mean that the first  rule run and set gordijn_toestemming=true.

    Change the last rule to 

    Please login or register to see this code.

    to verify.

     

    I would suggest you add a .start() to the first two rules so they always run and update gordijn_toestemming to the correct value.

    16 hours ago, Neo Andersson said:

    @jgab

    Jan i have another issue..This line used to work on my all installations

     

    Please login or register to see this code.

    Please login or register to see this attachment.

     

     

    @jgab

    Jan i figured out that variable office_controller_lastPressed can not be accessed inside the rule..that's why it doesn;t work, but this was working so far

    Do you declare it local ?

    locally declared lua variables have never been accessible in ER rules.

  • Topic Author
  • Posted
    17 hours ago, Neo Andersson said:

    @jgabJan how can i access a nested table value in a rule?

     

     

    1.

    Please login or register to see this code.

     

    Please login or register to see this attachment.

     

     

    2.

     

    I cant wrap into one line nested II >> calls

     

    Please login or register to see this code.

    I have tried several ways..using {} for nested ||>, using ;;...ehhhh

     

     

     

    This works now?

    Posted
    25 minutes ago, jgab said:

     

    This works now?

    Jan, yes this works, but i still dont know how to do nested ||>> statements. I have tried many many combinations

    EX how to formulate this

     

    Please login or register to see this code.

    or should I aviod using ||>> when the code is more complex?

  • Topic Author
  • Posted
    20 minutes ago, ChristianSogaard said:

    Im trying to create a Rule that triggers when a count of minimum 4 breached from a PIR sensor within max two minutes.

    To "measure"  that someone is staying at a room, and not just passing.

     

    Something like this 

    rule("236:Breached & BreachedCounter >= 4 & @Now < (2 minutes since first breached of the last 4 breached) => Heater:on ; Reset BreachedCounter

    rule("236:Breached => BreachedCounter = BreachedCounter+1

     

    Getting the time from the last trigger of these 8 can gathered from the History. But is not trivi to get the oldest timestamp


     => api.get("/events/history?from=@now-120&objectType=device&objectId=236 (Then i need to count events, should be more than 4) actually it need to be 8, because the output is not separating Breached & Safe  
     => api.get("/events/history?objectType=device&objectId=236&numberOfRecords=8 (then i need to check last event is les then 120 sec old.) actually it need to be 8, because the output is not separating Breached & Safe 

    Will return eight almost identical data sets, were I need to check the oldest timestamp should not be older than @Now-120

     

    What is a good way of creating a Rule that triggers when a count of minimum 4 breached from a PIR sensor within max two minutes. ?

     

     

    You need some "sliding window" to keep the last 4 values. Usually one does that with a table but it's a bit clunky in ER (reminds me I should improve table handling in ER).

    Anyway, you can implement that window with 4 variables

     

    Here I replace you sensor with a keypress to test (bct1 stands for breached counter time 1...)

    Please login or register to see this code.

     

    of course, if you looking for 10 presses within x time this becomes clunky...

    then you make a queue data type that you can use . here called windows, that has a set size

    Please login or register to see this code.

     

    • Like 1
    • Thanks 1
    Posted
    1 minute ago, jgab said:

     

    You need some "sliding window" to keep the last 4 values. Usually one does that with a table but it's a bit clunky in ER (reminds me I should improve table handling in ER).

    Anyway, you can implement that window with 4 variables

     

    Here I replace you sensor with a keypress to test (bct1 stands for breached counter time 1...)

    Please login or register to see this code.

     

    of course, if you looking for 10 presses within x time this becomes clunky...

    then you make a queue data type that you can use . here called windows, that has a set size

    Please login or register to see this code.

     

    I think a way more convinient way is to set this in parameters of PIR sensor. Almost all PIR sensor do have this feature.

     

    Please login or register to see this image.

    /monthly_2023_11/image.png.fc03b21e0ba4bf32cf2cbb405d61a702.png" />

    Posted
    16 minutes ago, Neo Andersson said:

    I think a way more convinient way is to set this in parameters of PIR sensor. Almost all PIR sensor do have this feature.

     

    Please login or register to see this link.

    Thank you for sharing - i was looking at this also. But i need the "normal" breached and this extended at the same time.

     

  • Topic Author
  • Posted
    54 minutes ago, Neo Andersson said:

    Jan, yes this works, but i still dont know how to do nested ||>> statements. I have tried many many combinations

    EX how to formulate this

     

    Please login or register to see this code.

    or should I aviod using ||>> when the code is more complex?

    Yes,||>> is just a more convenient way to write if-then-elseif.....elseif...else end.

    When it becomes nested it doesn't work so well, as there is no way to tell the difference between '||' on top-level and '||' in a subexpression....

    if-then-elseif... you can nest to any levels...

    But, of course there was a bug in the code which prevented ||>> to be nested in anything else,

    ...so I pushed v0.52 where you can do either

     

    if test1 then

       || test2 >> dosomething2

       || test3 >> dosomething3

       :

    end

     

    or not so elegant

    || test1 >>

       (

          || test2 >> dosomething2

          || test3 >> dosomething3

       )

       :

     

     

    I will try to come up with a proper case expression, something like

    rule([[key fob:key =>

           case fob:key of

              '1:pressed' : <statements>

              '1:pressed' : <statements>

              '1:pressed' : <statements>

              default:        <statements>

           end

    ]])

     

    but haven't decided yet for the syntax...

     

     

     

    • Like 1
  • Topic Author
  • Posted
    On 11/29/2023 at 2:56 PM, ChristianSogaard said:


    Rules:

    Please login or register to see this code.

     

    Please login or register to see this code.

     

     

    Did you get a solution?

    I'm trying my best and I can't reproduce the problem. 

    2:tryArm is implemented as a api call  api.post("/alarms/v1/partitions/"..id.."/actions/tryArm") - so it's kind of Fibaro that handles it ....

    and shouldn't have any side effect. Unless of course you have some rules that trigger and start to arm the whole house - but it doesn't look like that, looking at your rules...

     

    Could you disable your alarm rules and just try

    rule("2:tryArm") and see if it still causes the other partitions to arm?

     

    Do all your partitions share common devices? That's the only difference I can think of is that I have unique devices in each partition - however it would be interesting of overlapping devices cause this "side-effect"....

     

    Posted (edited)
    45 minutes ago, jgab said:

     

    Did you get a solution?

    I'm trying my best and I can't reproduce the problem. 

    2:tryArm is implemented as a api call  api.post("/alarms/v1/partitions/"..id.."/actions/tryArm") - so it's kind of Fibaro that handles it ....

    and shouldn't have any side effect. Unless of course you have some rules that trigger and start to arm the whole house - but it doesn't look like that, looking at your rules...

     

    Could you disable your alarm rules and just try

    rule("2:tryArm") and see if it still causes the other partitions to arm?

     

    Do all your partitions share common devices? That's the only difference I can think of is that I have unique devices in each partition - however it would be interesting of overlapping devices cause this "side-effect"....

     

    I re-entered the rule, and now im getting this when triggered

    I also deleted all my Alarm rules in EV4 - but i didnt see any overlapping issues

    Please login or register to see this attachment.

     

    rule([[#Key951_2_Pressed2_4_Pressed2 => 
     || 0:armed >> 0:armed=false;   log('#Disarmed from Matrix as Keypad')
     || !1:armed >> 1:tryArm ; log('#Try to Arm the house from Matrix as Keypad')
    ]])

     

    2 and 1:tryArm is not working (Above error)
    0:tryArm is working

    Edited by ChristianSogaard
    Typo
    Posted

    Perhaps it will help?

    I did't use tryArm because it gave some difficulties at the beginning and regret I can't remeber why.

    partiton zero I also don't use because it messed in ER4 my alarm up, there I had 4 partitions. Now in Alarm my lowesst ID = 1

    I use 2 main arm partitons and 2 for guests

    if I activate tryArm partition 1 or partiton 2 in both cases it arm my appartment

    if I use common devices it will also both arm the partitions

     

    Posted

    Update...

    I created these rules

    Please login or register to see this code.

     

    They actually arms the right partitions

    but im getting errors when triggered...

    [02.12.2023] [09:44:15] [ERROR] [ER2047]: [Rule:4:2]>> [Rule:4:951:key == '2:Pressed' => 2:tryArm] Runtime: ./include/fibLib.lua:191: attempt to get length of a nil value (field 'breachedDevices') prop
    951:key == '2:Pressed' => 2:tryArm

     

  • Topic Author
  • Posted
    3 minutes ago, ChristianSogaard said:

    Update...

    I created these rules

    Please login or register to see this code.

     

    They actually arms the right partitions

    but im getting errors when triggered...

    [02.12.2023] [09:44:15] [ERROR] [ER2047]: [Rule:4:2]>> [Rule:4:951:key == '2:Pressed' => 2:tryArm] Runtime: ./include/fibLib.lua:191: attempt to get length of a nil value (field 'breachedDevices') prop
    951:key == '2:Pressed' => 2:tryArm

     

    Ok,  good we have an error :-) will check it later today. ,

    • Thanks 1
  • Topic Author
  • Posted

    Ok, there was a bug in tryArm if there were no devices breached.

    I've pushed v0.54 with a fix.

    • Thanks 1
    Posted
    45 minutes ago, jgab said:

    Ok, there was a bug in tryArm if there were no devices breached.

    I've pushed v0.54 with a fix.

    Thank You Jan :-)

    Posted

    Jan - simple one, thought this was working but getting an error.

    This is an example from your interval rules post
     

    rule("@{10:00,15:00} => log('It is 10:00 or 15:00')")


    Last err: [Rule:38:@{10:00,15:00} => log('It is 10:00 or 15:00')] Rule: Invalid daily time: table: 0xaaaae2595b10

  • Topic Author
  • Posted
    1 hour ago, Pica2017 said:

    Jan - simple one, thought this was working but getting an error.

    This is an example from your interval rules post
     

    rule("@{10:00,15:00} => log('It is 10:00 or 15:00')")


    Last err: [Rule:38:@{10:00,15:00} => log('It is 10:00 or 15:00')] Rule: Invalid daily time: table: 0xaaaae2595b10

    Sorry, it was a bug that snuck into one of the last versions.

    I pushed 0.56 with a fix and added your name to the official bug hunters :-) 

    • Like 1

    Join the conversation

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

    Guest
    Reply to this topic...

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