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

@jgab Perhaps my HC3  speaks another language?

 it's still not restarting no error message

Please login or register to see this code.

 

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

    @jgab Perhaps my HC3  speaks another language?

     it's still not restarting no error message

    Please login or register to see this code.

     

    Hmm interesting - works for me. 

    Sure about the user/pwd?

    You have enabled https access to the box?

    What else could be the difference?

    Posted

    use/pwd is in third instance copied from loggin to be sure no typo or error

    http/https is ticked

    fw 5.150.18

    ER5 1.0

    macOS Sonoma 14.2.1

  • Topic Author
  • Posted
    16 minutes ago, Sjakie said:

    use/pwd is in third instance copied from loggin to be sure no typo or error

    http/https is ticked

    fw 5.150.18

    ER5 1.0

    macOS Sonoma 14.2.1

    Ack!, I was just about to paste&copy your rule to test again when I saw that I had spelled wrong

    It should be

    Please login or register to see this code.

    as in "credentials", not

    Please login or register to see this code.

    Posted

    @jgab Thanks this works!

    • Like 1
  • Topic Author
  • Posted (edited)

    v1.02 of ER5 is pushed.

     

    Lot's of minor fixes. I would recommend to upgrade.

     

    Changes to var and triggerVar.

    Please login or register to see this code.

    creates a ER variable 'x' with value 42.

    We can now use that in our lua code as

    Please login or register to see this code.

    as var.x now return the value of x. In the past we got a "boxed" value.

     

    The same is true for triggerVar, but a triggerVar is automatically also defined as a var.

    In the past.

    triggerVar.x = 42 would update the var to 42 but not create a trigger that triggers rules.

    Normally we don't want that because we only want to initialise variable.

    However, we can now create a trigger event by wrapping the value in TVAL(value)

    Ex.

    Please login or register to see this code.

     

    Lastly, in main I have moved the MODULE handling to another file.

    Please remove the MODULE code in main or copy over your rules to the new main format

    Please login or register to see this link.

     

     

    Edited by jgab
  • Topic Author
  • Posted (edited)

    A general reflection on the use of ER5.

    If one needs to create large data tables with values it is probably easier to do that in Lua than to try to do it in a rule.

    Ex.

    Please login or register to see this code.

    This is not a large table but for illustration.

    The problem, we have is that we don't get any help from Lua to syntax check the code (ex. like if we written it in VSCode) and also when the rule creates the table, the ER engine is not as good as Lua to catch errors and we may end up strange error messages or even with a strange table.

     

    The advantage with defining it with a rule is of course that we have access to other ER variables, like 'light1', 'light2', 'red', and 'white' in the example above.

    These variables are also (from v1.01) available in var now.

    We can alias 'var' to 'V' (to make the typing 2 letters shorter) and use that to setup the table in Lua instead.

    Please login or register to see this code.

    the advantage is that we get good error/syntax checks from Lua.

    In next version of ER5 there will even be an option so that if V.red is not defined before accessed in an example like above, we will get a warning.

     

    Edited by jgab
    Posted

    @jgab New error in alll QA's

    [09.01.2024] [11:56:42] [ERROR] [QUICKAPP1246]: No main/modules to load

  • Topic Author
  • Posted (edited)
    9 minutes ago, Sjakie said:

    @jgab New error in alll QA's

    [09.01.2024] [11:56:42] [ERROR] [QUICKAPP1246]: No main/modules to load

    Dang, I thought I fixed that.

    In main file at the bottom of the file remove the line

       self:main(er) 

    and it will be ok. I believe that you get an error but it loads the file as usual so it should work anyway.

     

    I will make an 1.02 update later today/evening.

    Edited by jgab
    Posted
    On 1/7/2024 at 11:27 PM, jgab said:

    It turns out that I was overcomplicating it. updateProperty is not intercepted so this works

    Please login or register to see this code.

    As long as we use 0/99 as values

     

    That's why I was not seeing that second UI event with this config before - the issue was actually my incorrect use of true/false values 🙄

     

    thanks again!

  • Topic Author
  • Posted
    22 minutes ago, Sjakie said:

    @jgab New error in alll QA's

    [09.01.2024] [11:56:42] [ERROR] [QUICKAPP1246]: No main/modules to load

    Ok, I just pushed 1.02 with a fix so the error message is not displayed by mistake. 

    Posted (edited)

    @jgab Jan in this rule

    Please login or register to see this code.

    it is obvious that Main_door_sensor:breached is a trigger

     

    what about the & 07:00..21:00 , is it a triggerr too???

     

    so for example..main door got breached at 06:59..the lamp does not get triggered, thats clear..but as the time goes by..and gets to 7:00 will it trigger ? will it turn on the light if the door sensor is still breached?

     

    Second question...will every light1:on action start a paralell waiting loop and turn off the light1 when loop finishes?

    1 minute ago, Neo Andersson said:

    @jgab Jan in this rule

    Please login or register to see this code.

    it is obvious that Main_door_sensor:breached is a trigger

     

    what about the & 07:00..21:00 , is it a triggerr too???

     

    so for example..main door got breached at 06:59..the lamp does not get triggered, thats clear..but as the time goes by..and gets to 7:00 will it trigger ? will it turn on the light if the door sensor is still breached?

     

    Second question...will every light1:on action start a paralell waiting loop and turn off the light1 when loop finishes?

    Should i use the killOthers action here? Because we can't find the reason, why just light1 gets randomly turned off. We dont have any other rule linked to light1, so i was thinking, maybe it is becuase all these paralell loops behind the curtain

    Edited by Neo Andersson
    Posted
    4 minutes ago, Neo Andersson said:

    @jgab Jan in this rule

    Please login or register to see this code.

    it is obvious that Main_door_sensor:breached is a trigger

     

    what about the & 07:00..21:00 , is it a triggerr too???

     

    so for example..main door got breached at 06:59..the lamp does not get triggered, thats clear..but as the time goes by..and gets to 7:00 will it trigger ? will it turn on the light if the door sensor is still breached?

     

    Second question...will every light1:on action start a paralell waiting loop and turn off the light1 when loop finishes?

    Should i use the killOthers action here? Because we can't find the reason, why just light1 gets randomly turned off. We dont have any other rule linked to light1, so i was thinking, maybe it is becuase all these paralell loops behind the curtain.

    So how would the correct rule look like with killOthers usage?

     

  • Topic Author
  • Posted (edited)

    Please login or register to see this code.

    Yes, the wait 2min can allow the sensor to trigger a parallel instance that will turn on wait 2 and urn off again.

    killOthers with kill the previous waiting rule and probably get the effect you want (restarting a 2min period before turning off)

     

     07:00..21:00 will trigger the rule at 07:00 and at 21:00:01

    The reason is that if your sensor is breached 06:59:59 the rule will trigger but not be true. However it's probably still breached at 07:00 when the rule triggers again (depending on breached period) so then it will be true. Trust me, this is the semantic you want for interval tests...

    Edited by jgab
    • Thanks 1
    Posted (edited)
    3 hours ago, jgab said:

    07:00..21:00 will trigger the rule at 07:00 and at 21:00:01

    Jan, how to format the rule, that 07:00..21:00 will act only as a condition and never as a trigger?

    Should I put the check on the right side of the rule? like below

     

    Please login or register to see this code.

     

    Edited by Neo Andersson
  • Topic Author
  • Posted
    4 minutes ago, Neo Andersson said:

    Jan, how to format the rule, that 07:00..21:00 will act only as a condition and never as a trigger?

    Should I put the check on the right side of the rule? like below

     

    Please login or register to see this code.

     

    Yes, thats the general approach.

     

    but add parenthesis around the rest to execute

    Please login or register to see this code.

    or make it an if-then

    Please login or register to see this code.

     

     

    • Thanks 1
  • Topic Author
  • Posted (edited)

    ER5 v1.03 pushed

    -fixed killOthers behaviour

    Please login or register to see this code.

    will kill other instances of the rule if <cond> is true and it is continuing to the <actions>.

    Previous behaviour killed others as soon as the rule was triggered which created unwanted/unexpected effects...

    Now, the shortest rule to trigger a light with a sensor and extending the light period if sensor is re-triggered is

    rule("sensor:breached => light:on; wait(00:05); light:off").mode('killOthers')

     

    What killOther do is that it cancel all timers that a rule have started - for all instances of that rule.

    Timers are started when a rule does wait(<time>) - a timer that resumes the rule after <time>

    A timer is also started when a rule does a post(<event>,<time>) - to post something in the future

    And finally timers are started for @<time>, and @@<time> (daylies and intervals) - for the next invocations

     

    Rule instances can't run in (real) parallel, but they let others run while they wait for a timer.

    killOthers will thus kill all other instances that are waiting to run, and only the rule instance doing killOthers will continue.

     

    .mode('killOthers') should be avoided for @,@@ rules, and frankly it doesn't make much sense to use it for these types of rules.

     

    Edited by jgab
    Posted (edited)

    @jgab Jan, i bet there is a rnd function (or similar) in ER5, but i could not find in this topic.

    How can i pick a random device ID from a list? Lets say i have a list of devices rule("mimicLights = {105,106,107}"), i want to pic randomly a number in every 2 minutes and turn on that device.

    1. What is the random function definition?

    2. How to run a rule in a loop

     

    goal is, pick a random light from mimicLIghts, then turn it on, wait 2 min, than  pick another and turn it ON (but turnoff the previous one), and so on, doing this until user doesnt stop it.

    We want to mimic that someone is at home

     

    Edited by Neo Andersson
  • Topic Author
  • Posted (edited)

    Yes, the function is rnd(n) or and(n,m).

    First gives random value from 1..n inclusive, the latter gives random value between n...m inclusive.

     

    A presence simulation could be implemented like this

    Please login or register to see this code.

     

    Edited by jgab
    • Thanks 1
  • Topic Author
  • Posted

    The problem with the above presence rules is the statement

    Please login or register to see this code.

    id:value = x is translated to fibaro.call(id,'setValue',x) which is not always supported by devices.

    multilevelSwitches do support 'setValue' but a generic binarySwitch do not.

     

    I'm contemplating keeping up-to-date device info so :value could be more intelligent and choose appropriate action for devices...

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