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

Event runner - trigger vs condition


Neo Andersson

Question

Hello Jan, i am moving the discussion here..

 

In a rule like this 

 

Please login or register to see this code.

 

i can understand, that 'once' statement is good for cases like this..when ext_lux_sensor value drops under 720, we don't want the action to be triggered every time, this is clear to me. But we don't want to use this lux checking part as a trigger!!! That is the problem. I want it to be a condition and not a trigger. Thats why i asked how to use it.

So i don't want the light to be turned on at all whatever the ext_lux_sensor value is, i just want it to be controlled in case of office_sensor is breached. So how to do that?  How to make a condition (NOT a trigger). I checked the logs you mentioned, and it says

Please login or register to see this code.

, meaning that the lux sensor changing will be used as trigger also.

And if using the 'once' statement, should i use it for the entire left part of the rule  e,g,.

Please login or register to see this code.

or just for the sensor part e.g.

Please login or register to see this code.

 

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0
1 hour ago, Neo Andersson said:

Hello Jan, i am moving the discussion here..

 

In a rule like this 

 

Please login or register to see this code.

 

i can understand, that 'once' statement is good for cases like this..when ext_lux_sensor value drops under 720, we don't want the action to be triggered every time, this is clear to me. But we don't want to use this lux checking part as a trigger!!! That is the problem. I want it to be a condition and not a trigger. Thats why i asked how to use it.

So i don't want the light to be turned on at all whatever the ext_lux_sensor value is, i just want it to be controlled in case of office_sensor is breached. So how to do that?  How to make a condition (NOT a trigger). I checked the logs you mentioned, and it says

Please login or register to see this code.

, meaning that the lux sensor changing will be used as trigger also.

And if using the 'once' statement, should i use it for the entire left part of the rule  e,g,.

Please login or register to see this code.

or just for the sensor part e.g.

Please login or register to see this code.

 

Well, stuff you only want to use as a condition you move to the right of the =>

Please login or register to see this code.

here we combine them with '&' so If the first test (ext_lux_sensor:lux < 720= is false the second is not run.

It's also possible to write as

Please login or register to see this code.

 

as a rule of thumb, 'once' is needed more seldom than one initially think... 

Link to comment
Share on other sites

  • 0
  • Inquirer
  • 8 minutes ago, jgab said:

    Well, stuff you only want to use as a condition you move to the right of the =>

    Please login or register to see this code.

    here we combine them with '&' so If the first test (ext_lux_sensor:lux < 720= is false the second is not run.

    It's also possible to write as

    Please login or register to see this code.

     

    as a rule of thumb, 'once' is needed more seldom than one initially think... 

    Well, this is what we were looking for..Unfortunatelly i could not find in any documentation or topic that we can use the condition on the right side. I always thought the right side is exclusively for actions to be run.

    Link to comment
    Share on other sites

    • 0

    No, the right hand side can do whatever - including calling your own lua functions. ER is also a pretty complete programming language with for loops, if-then-else, wait's etc.

     

    The last case could also be written as 

    Please login or register to see this code.

    even if the lux sensor will trigger the rule it still needs the sensor to also be in breached state to run the action. Just some unnecessary triggering of the rule but harmless.

    What could happen is that while the sensor is breached the lux value changes to something below 720 and runs the rule again - but then if the light is already on there is no harm.

    • Like 1
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • I have tried to look for some documentation, description of the entire framework. I am pretty sure there is somewhere, but i could find only some short use cases, and a few code examples. Is there by any chance some detailed description about all the functionality of ER4, all the way rules can be handled,  etc. I am pretty sure you have it somewhere, but i can not find it at one place.

    Example, how to create rules that should run on certain days of week at certain time (the time part i found, but couldn't find how to deal with days)

    Link to comment
    Share on other sites

    • 0

    Well, it's a bit lacking I guess. The best is probably

     

    • Please login or register to see this link.

       (and ER3) - TBD
    • Please login or register to see this link.

     

    and then maybe look at some examples from ER3 as the syntax is the same.

    • Please login or register to see this link.

      .
    • Please login or register to see this link.

    • Please login or register to see this link.

       (

      Please login or register to see this link.

      )

     

    The events in ER are the same as used by fibaroExtra so it integrates well. (ER is built onto of fibaroExtra)

    Ex.

    Please login or register to see this code.

     

    and the other way around

    Please login or register to see this code.

     

    Edited by jgab
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 1 hour ago, Neo Andersson said:

    I have tried to look for some documentation, description of the entire framework. I am pretty sure there is somewhere, but i could find only some short use cases, and a few code examples. Is there by any chance some detailed description about all the functionality of ER4, all the way rules can be handled,  etc. I am pretty sure you have it somewhere, but i can not find it at one place.

    Example, how to create rules that should run on certain days of week at certain time (the time part i found, but couldn't find how to deal with days)

    Also saw something about NODERED connection. What can it do? I am very interested in all functionality. I would not want to use a robust framework's 3-4 functions only, i want to utilize the entire framework power.

    Edited by Neo Andersson
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Jan, how to create a rule for a certain datetime?

     

    Please login or register to see this code.

     

    Edited by Neo Andersson
    Link to comment
    Share on other sites

    • 0
    17 hours ago, Neo Andersson said:

    Jan, how to create a rule for a certain datetime?

     

    Please login or register to see this code.

     

    So, the general idea is that the @-rule (I call them dailys) fire once a day and the time is expressed in 24 hour time. Ex.

    Please login or register to see this code.

    or if we also have seconds...

    Please login or register to see this code.

    If we only want to run the rule 15:00 on Wednesday and Thursday and Sunday we put in a guard for that

    Please login or register to see this code.

    if we only want that in March to July we add a month guard

    Please login or register to see this code.

    The rules will of course still try to run every day at 15:00, but only succeed when all the conditions/guards succeed. The performance hit for that is negligible. 

    Assume that you know that your rule only runs March to July and it needs to be invoked a lot to check if it should run you can have a rule that enables and disables the rule.

    Ex. 

    Please login or register to see this code.

    Here we have rules that run once a day to enable/disable another rule that runs every 5s when enabled. 

    Note that the rule have an added .start() to them so they will run when the QA is started. Otherwise we need to wait until midnight before it's decided if the rule is enabled/disabled.

    Still not a huge problem having rules running every 5s, but it may clutter the log a bit...

     

    There is a "long date" format, that gives you a value like os.time() would return, but it's not usable with @time as the @time only takes 24 hour time value.

    However, it's usable for guards and posts

    Ex.

    Please login or register to see this code.

    or

    Please login or register to see this code.

     

    This means that you could use ostime to post at a specific date

    Please login or register to see this code.

    but the long format is more convenient

     

    There is also a cron condition/guard that can be used called 'date'

    Please login or register to see this code.

    Here we run it every hour to check if we have a hit...

     

    Link to comment
    Share on other sites

    • 0
    20 hours ago, Neo Andersson said:

    Also saw something about NODERED connection. What can it do? I am very interested in all functionality. I would not want to use a robust framework's 3-4 functions only, i want to utilize the entire framework power.

     

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