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



jgab

Recommended Posts

1 hour ago, jgab said:

Yes, it's very difficult case - solution depends on bathroom layout and family behaviour - and there are an infinite number of variations on these parameters  ;-) 

 

A simple case with a door sensor and a motion sensor that can detect if someone is moving in the bathroom.

Assumptions:

1. Motion sensor covers whole bathroom - also if someone is in the shower.

2. When door is open it's ok to turn off light if there is no motion. 

Please login or register to see this code.

 

In my usecase

Assumptions:

1. Motion sensor covers NOT whole bathroom - Only shower is not covered.

2. When door is open it's ok to turn off light if there is no motion, but door has to be detected closed before this rule can be active.

 

The Util.defTriggerVar makes it possible to use variable in the other rules - right?

Link to comment
Share on other sites

Shower not covered;

if you use openDoor.... it should not effect there is still some one in the bathroom!

//Sjakie

Link to comment
Share on other sites

  • Topic Author
  • 51 minutes ago, ChristianSogaard said:

    In my usecase

    Assumptions:

    1. Motion sensor covers NOT whole bathroom - Only shower is not covered.

    2. When door is open it's ok to turn off light if there is no motion, but door has to be detected closed before this rule can be active.

     

    The Util.defTriggerVar makes it possible to use variable in the other rules - right?

    Yes, Util.defTriggerVar makes the variable trigger rules when it changes value.

    In this case it makes the trueFor rule check its condition.

    2 hours ago, Sjakie said:

    Jan I still have an error and I have no clue how to solve it.

    If $Bezetting_xxxx is all zero or it's > 0 I get this error

    Please login or register to see this code.

    //Sjakie

    How does the rule look like?

    Link to comment
    Share on other sites

    Please login or register to see this code.

     

    The Util.defTriggerVar makes it possible to use variable in the other rules - right?

    Yes, Util.defTriggerVar makes the variable trigger rules when it changes value.

    In this case it makes the trueFor rule check its condition.

     

    Thank you ? and just to clarify 

    Creating the Rule(" aaa & bbb 

    The aaa part is the trigger and the bbb is a condition.

    using the defTriggerVar on bbb makes the bbb trigger the aaa  ?

    Edited by ChristianSogaard
    P
    Link to comment
    Share on other sites

  • Topic Author
  • 38 minutes ago, ChristianSogaard said:

    Please login or register to see this code.

     

    The Util.defTriggerVar makes it possible to use variable in the other rules - right?

    Yes, Util.defTriggerVar makes the variable trigger rules when it changes value.

    In this case it makes the trueFor rule check its condition.

     

    Thank you ? and just to clarify 

    Creating the Rule(" aaa & bbb 

    The aaa part is the trigger and the bbb is a condition.

    using the defTriggerVar on bbb makes the bbb trigger the aaa  ?

     

    Technically it triggers the rule to see if the whole condition (aaa & bbb) is true.

    rule("88:isOn & bbb => log('A')")

    When that rule is compiled/defined I inspect the condition and see that it checks 88:isOn which means the this rule should only be checked 

    whenever device 88 changes value. In theory I could check it only when it's value becomes true but then I miss a rule like

    rule("!88:isOn & bbb => log('A')")

    There is no reason to ever check this rule any other time. That's one of the reasons ER is quite efficient and can cope with a lot of rules - as rules are only checked

    when an event is happening that can possibly make the condition true.

    Other rule systems checks all rules continuously which is usually a waste.

     

    If we declare bbb as a trigger variable 2 things happens.

    First, whenever we change the value of bbb (ex. bbb=77) it will automatically post an event {type='variable', name='bbb', value=77}

    and secondly, it will note that our rule should also trigger on event {type='variable', name='bbb'}

    This means that whenever 88 changes value or bbb changes value we will run the rule and check the condition.

    If 88's value is true and bbb is ~= false/nil the rule will run it's action.

     

    Internally I have a hash map that maps events to rules which makes it very quick to find what rules to test for every type of event.

    Link to comment
    Share on other sites

  • Topic Author
  • Posted (edited)

    To add to the above explanation.

    If we do

    Please login or register to see this code.

    it will not work as expected.

    #foo is a user event (something we made up ourselves).

    The rule when compiled will note that when {type='foo'} or {type='variable', name='bbb'} is posted the rule should be checked.

    If it fires because the event {type='foo'} is posted it will run the action if the variable bbb is true.

    However, if we change the value of bbb it will run the rule but #foo will never be true (because the event was  {type='variable', name='bbb'})

    Unlike 88:isOn where we can check the state of device 88 and see if its value is true, a pure (user) event doesn't have a state - we don't remember it

    has been posted, we just use it to trigger rules "in the moment". If we could remember that it has been posted in the past when bbb triggers - how far back in time should we check? So, events don't have state, but stuff that have state can trigger events (like our trigger variable bbb, or device 88)

    Edited by jgab
    • Thanks 1
    Link to comment
    Share on other sites

    Please login or register to see this code.

     

     
     
    Link to comment
    Share on other sites

  • Topic Author
  • 2 hours ago, Sjakie said:

    Please login or register to see this code.

     

     
     

    but what rule is logging this

    Please login or register to see this code.

    ???

    Link to comment
    Share on other sites

    I did this to see the value of "bezetting_kamer"

    Please login or register to see this code.

    Neither the rule I have bezetting_kamer ~= $Bezetting_Appartement or = does't give any value

     

    How to pint the value bezetting_kamer?

    Edited by Sjakie
    forgot detail
    Link to comment
    Share on other sites

  • Topic Author
  • bezetting_kamer:value

    returns a Lua array of values, because bezetting_kamer is a Lua array of device ids.

    Do

    Please login or register to see this code.

    to see the list of values, or do

     

    Please login or register to see this code.

    to see the sum of the values.

    Link to comment
    Share on other sites

    Jan, thanks finaly I see the value.

    Error in :

     

    Please login or register to see this code.

     

    Edited by Sjakie
    data modified
    Link to comment
    Share on other sites

  • Topic Author
  • So, it seems like some device in bezetting_kamer doesn't exist?

    Try something like this

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    [19.06.2022] [08:26:03] [ERROR] [QUICKAPP1305]: Error in 'for i,id in ipairs(bezetting_kamer) do
             log("Trying device %s",id);
             log("device %s=%s",id,id:value)
             end': ./include/EventRunner.lua:1949: ./include/EventRunner.lua:1219: bad argument #3 to 'format' (no value)

    Link to comment
    Share on other sites

  • Topic Author
  • 14 minutes ago, Sjakie said:

    [19.06.2022] [08:26:03] [ERROR] [QUICKAPP1305]: Error in 'for i,id in ipairs(bezetting_kamer) do
             log("Trying device %s",id);
             log("device %s=%s",id,id:value)
             end': ./include/EventRunner.lua:1949: ./include/EventRunner.lua:1219: bad argument #3 to 'format' (no value)

    So, what id did it log just before? That's the id with no value.

    Link to comment
    Share on other sites

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • 2 minutes ago, Sjakie said:

    Please login or register to see this code.

     

    But wasn't it device IDs in bezetting_kamer ???

    You do call :value on the list.

    Please login or register to see this code.

     

    If it's the number of occupants you need to do things differently

    Yu can't pre-compute bezetting_kamer...

    Please login or register to see this code.

    Link to comment
    Share on other sites

    Jan, thanks!

    The rule with ~= is executing value 2

    the rule with = is wrong, wierd value 0 bezetting_kamer changes

    Please login or register to see this code.

    Please login or register to see this code.

     

    Edited by Sjakie
    value
    Link to comment
    Share on other sites

  • Topic Author
  • You can't use '=' as that is assignment. Use '==' for comparison.

    Just now, jgab said:

    You can't use '=' as that is assignment. Use '==' for comparison.

    I still have a hard time trying to understand what you try to achieve...

    Link to comment
    Share on other sites

    Indeed Jan now it's working! Thanks.

    I add $Bezetting_Appartment also as trigger so the check on how manny persons are in is now complete!

    Also I have 2 probs in IOS Locator but I will post thrm there.

    Thanks again,

    //Sjakie

    Link to comment
    Share on other sites

    How do I get the value of a sensor put into a variable ?

    Like Breached or Not Breached.

    Eg this line - When2turnLightOff=Badevarelset.door; - Where Badevarelset.door is a Sensitive door sensor

     

    Please login or register to see this code.

     

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