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

  • Topic Author
  • 4 hours ago, Neo Andersson said:

    @jgab Hello Jan..This "killOthers" functionality is more or less the substitution for truFor rule right?

    Because the goal of this rule 

    Please login or register to see this code.

    is to turn on the lamp on sensor breach and turn it off after 5 min, BUT if there is an inbetween motion detected, the rule will not turn off the lamp, so this is equivavlent of

    Please login or register to see this code.

    am I right?

    Yes, there are many ways to achieve similar results - like in any programming language.

    I wouldn't say that they are substitutions, sure they both can help in this case but have their separate uses too.

    Link to comment
    Share on other sites

  • Topic Author
  • Advanced topics

     

    Asynchronous functions

    Actually, how to make asynchronous functions look synchronous.

    In ER5 we can do

    Please login or register to see this code.

    We call http.get and the result is used as an argument to the log format function.

    We know that in QuickApps, net.HTTPCall().request() is asynchronous so we need to provide a success callback function.

    In ER5 though, our script pauses waiting for the http call to complete and then let http.get return the value...

    e.g. it looks like a synchronous call where we get the value directly. A bit like HC2's VD Net.FHttp.

     

    We can create EventScript variables by assigning (er.variable or just var) the variable and its value

    Please login or register to see this code.

    We can add a Lua function to EventScript by

    function var.myFun(x,y) return x+y end

    Please login or register to see this code.

     

    So, assume that we have a function that completes later (is asynchronous). Such a function usually needs some callback function to pass the computed values to. Think about net.HTTPClient()'s success and error callbacks.

    Please login or register to see this code.

    This function will wait for 2 seconds and then call the provided callback function with the result of the computation.

    Please login or register to see this code.

     

    We can easily make this into an "synchronous" EventScript function

    Please login or register to see this code.

     

    We define it on var.async and it will be added as an asynchronous function in ER,

    and we can use it like

    Please login or register to see this code.

    The script will pause for 2s and return 14 that will be logged

    The value, 3000, returned last in our asyncFun is the delay (in ms) before the async function times out. Asynchronous functions need some timeout so they don't hang forever if something goes wrong...

     

    This is very powerful mechanism that allow us to do interesting stuff.

    Ex.

    Please login or register to see this code.

    This creates a function that waits for an event before returning true.

    Then we can do

    Please login or register to see this code.

    Here our rule trigger on sensor1 being breached,

    then it pauses 10s waiting for an breached event from sensor2 and if it sees it, it proceeds to the action.

    This allows us to easily do rules that depends on certain events happening in sequence,

    like a burglar breaching sensors along an hallway...

     

    Custom objects and properties

    How to add your own :property functions...

     

    Custom Event print functions

    Customise how events are logged...

    Edited by jgab
    Link to comment
    Share on other sites

    Jan, the only possibility to se if all is working in ER5 is to go life!

    Therefor I will go life with my trigger QA's and Hue lights. If that works I wiil extend except arming will come at last because you mentioned it will be ....

     

    Link to comment
    Share on other sites

  • Topic Author
  • 3 minutes ago, Sjakie said:

    Jan, the only possibility to se if all is working in ER5 is to go life!

    Therefor I will go life with my trigger QA's and Hue lights. If that works I wiil extend except arming will come at last because you mentioned it will be ....

    Yes, the alarm is different. It's already there but I need to write a post how to use it.

    Link to comment
    Share on other sites

    Hi Jan,
    Very promising ER review, amazing !

    I have installed ER5 via the QAUpdater and running v0.027.


    I'm trying it by implementing some basic rules and getting error on this one, trying to take an action triggered on single (or double) press with a Fibaro button...
     

    Please login or register to see this code.

    Getting this error...
     

    Please login or register to see this code.

     

    Anything wrong with my rules ?

     

    Some others are working.

    Link to comment
    Share on other sites

  • Topic Author
  • 54 minutes ago, chelson said:

    Hi Jan,
    Very promising ER review, amazing !

    I have installed ER5 via the QAUpdater and running v0.027.


    I'm trying it by implementing some basic rules and getting error on this one, trying to take an action triggered on single (or double) press with a Fibaro button...
     

    Please login or register to see this code.

    Getting this error...
     

    Please login or register to see this code.

     

    Anything wrong with my rules ?

     

    Some others are working.

     

    Hi, my bad - a cut & paste error for the :central code

    Forgot to add :central test case so it was never spotted.

    Pushed v0.028 

    Thanks for finding the bug!

    • Like 1
    Link to comment
    Share on other sites

    Jan perhaps its me or I doubt ER5?

    Please login or register to see this code.

    hal.deuren_Utility does't work 

    Btw the log looks much better than ER4!

    Perhaps change color blue >> for me not readable in lightblue?

    Remark: from today all ER5 QA's are operational.

    Edited by Sjakie
    remarl debug
    Link to comment
    Share on other sites

  • Topic Author
  • 1 hour ago, Sjakie said:

    Jan perhaps its me or I doubt ER5?

    Please login or register to see this code.

    hal.deuren_Utility does't work 

    Btw the log looks much better than ER4!

    Perhaps change color blue >> for me not readable in lightblue?

    Remark: from today all ER5 QA's are operational.

    Blue, what log are you referring to?

     

    More specific, what with hal.deuren_Utility doesn't work?

    Does hal.deuren_Utility:breached report wrong?

    Test

    Please login or register to see this code.

    If any is breached, hal.deuren_Utility:breached should report true, otherwise false.

    2 minutes ago, jgab said:

    Blue, what log are you referring to?

     

    More specific, what with hal.deuren_Utility doesn't work?

    Does hal.deuren_Utility:breached report wrong?

    Test

    Please login or register to see this code.

    If any is breached, hal.deuren_Utility:breached should report true, otherwise false.

    Anyway, v0.030 uploaded. 

    Fixed some small bugs. push messages seems to work...

    Edited by jgab
    Link to comment
    Share on other sites

     

     

    Please login or register to see this code.

     

     

    [05.11.2023] [11:56:39] [TRACE] [QUICKAPP1064]: log will show nothing after this line

     

    [05.11.2023] [11:50:27] [TRACE] [ER1060]: [Rule:76:3]>> FALSE #device{"id":49,"v.. -> trueFor(00:30, appPhone.beveiligenAppa..

    Link to comment
    Share on other sites

  • Topic Author
  • 28 minutes ago, Sjakie said:

     

     

    Please login or register to see this code.

     

     

    [05.11.2023] [11:56:39] [TRACE] [QUICKAPP1064]: log will show nothing after this line

     

    [05.11.2023] [11:50:27] [TRACE] [ER1060]: [Rule:76:3]>> FALSE #device{"id":49,"v.. -> trueFor(00:30, appPhone.beveiligenAppa..

     

    Very strange, but my guess it's an error on the second line.

    To see that you need to select the tag "ER1064" in the console as the errors from QUICKAPP1064 logs under the tag ER1064

    (I see in the line below that you have selected the console tag  "ER1060"...)

    If you want "system logs" and "user logs" on the same tag "QUICKAPP<ID>"

    set 

    er.settings.systemLogTag=nil

    Link to comment
    Share on other sites

    Sorry I had selected all my QA's

    Error is also on hal.deuren={....

    I checked door by door in check.... and they all report

    [05.11.2023] [12:35:47] [TRACE] [QUICKAPP1064]: Posting #TV{test8=true} at Sun Nov  5 12:35:47 2023 (trigger variable)[05.11.2023] [12:35:47] [TRACE] [QUICKAPP1064]: log will show nothing after this line[05.11.2023] [12:35:47] [TRACE] [QUICKAPP1064]: Check - hal.deurVoor:breached >>>> false

     

    Please login or register to see this code.

     

    Edited by Sjakie
    other doors same error
    Link to comment
    Share on other sites

  • Topic Author
  • 47 minutes ago, Sjakie said:

    Sorry I had selected all my QA's

    Error is also on hal.deuren={....

    I checked door by door in check.... and they all report

    [05.11.2023] [12:35:47] [TRACE] [QUICKAPP1064]: Posting #TV{test8=true} at Sun Nov  5 12:35:47 2023 (trigger variable)[05.11.2023] [12:35:47] [TRACE] [QUICKAPP1064]: log will show nothing after this line[05.11.2023] [12:35:47] [TRACE] [QUICKAPP1064]: Check - hal.deurVoor:breached >>>> false

     

    Please login or register to see this code.

     

    So, they all report false, but in reality there are some of the doors that are opened?

    Link to comment
    Share on other sites

    Jan, if I open all the doors it show in debug true, I checked to see where the error comes from

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    Jan, this QA was? without errors >> selected in debug.

    These errors are not showed as error!

    I saw them because in out technical room light does't switch on

    Please login or register to see this code.

    Can the ; be the error!!!!

    The only errors I had where the ones we are working on.

    Edited by Sjakie
    add extra info
    Link to comment
    Share on other sites

    Jan strange behaviour

     

    In the same  QA I have:

    Please login or register to see this code.

    If I open the door it does't switch light on!

    When I copy in empthy QA if open door light goes on by open the door.

    Up to you I will send QA in pm

     

    Link to comment
    Share on other sites

  • Topic Author
  • 1 hour ago, Sjakie said:

    Jan, this QA was? without errors >> selected in debug.

    These errors are not showed as error!

    I saw them because in out technical room light does't switch on

    Please login or register to see this code.

    Can the ; be the error!!!!

    The only errors I had where the ones we are working on.

    Yes, don't end with ';' before '||'

    Link to comment
    Share on other sites

  • Topic Author
  • 1 hour ago, Sjakie said:

    Jan, this QA was? without errors >> selected in debug.

    These errors are not showed as error!

    I saw them because in out technical room light does't switch on

    Please login or register to see this code.

    Can the ; be the error!!!!

    The only errors I had where the ones we are working on.

     

    This rule throws an error (and yes, it's the trailing ';') . I don't think you are watching the right console tags. 

    If it's too tricky with many tags set er.settings.systemLogTag=nil to get everything under one tag. And then when you don't have errors you can switch back to get a cleaner log.

     

    Edited by jgab
    Link to comment
    Share on other sites

    Hi Jan, moving a bit further and trying to play with 'profiles' in ER5.
    Is it supported in ER5 already?


    I'm trying to use the same structure than here 

    But I get stuck with the 'enable' rule expression.

    Please login or register to see this code.

     

    Any advice about profiles management in ER5 ?

    Link to comment
    Share on other sites

  • Topic Author
  • 1 hour ago, chelson said:

    Hi Jan, moving a bit further and trying to play with 'profiles' in ER5.
    Is it supported in ER5 already?


    I'm trying to use the same structure than here 

    But I get stuck with the 'enable' rule expression.

    Please login or register to see this code.

     

    Any advice about profiles management in ER5 ?

     

    No, but I'm thinking about it :-) 

    There will be a similar model to group rules by tags and and enable/disable groups. 

    ...but I will read what I wrote in the post and see if I'm getting inspired ;-) 

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