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

  • Topic Author
  • Posted

    You need to write

    @22:00

    with a colon.

    @22.00, is like 22s after midnight and will be scheduled first at 00:00, so that's why you don't see the timer

    Posted

    Sorry Jan for not reading well.

    If I create an error I get the message setup error(s) - fix and restart.

    In my case it stops running after posting test10=true

    My rule test3 is't executed.

    This is different as the QA "crash" earlier this was solved by re-starting the QA

    Please login or register to see this code.

     

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

    Sorry Jan for not reading well.

    If I create an error I get the message setup error(s) - fix and restart.

    In my case it stops running after posting test10=true

    My rule test3 is't executed.

    This is different as the QA "crash" earlier this was solved by re-starting the QA

    Please login or register to see this code.

     

    Yes, it seems you have spelled 'ruel' instead of 'rule' for some rule definition in main.

    Posted (edited)

    Jan I created the error to see what happends. THe QA stops instead of fix  and restrat.

    Does fix mean I need to correct the error and if done restart?

    Edited by Sjakie
    add fix
  • Topic Author
  • Posted
    24 minutes ago, Sjakie said:

    Jan I created the error to see what happends. THe QA stops instead of fix  and restrat.

    Does fix mean I need to correct the error and if done restart?

    Yes, if there is an error when setting up the rules it will exit the main() function and ask you to fix it.

    When you fix it and save, the QA restarts...

     

    If there is an error later when the rules are running, it should not stop.

    In the next version if a rule throws an error 3 times the rule will be disabled - and a message logged that the rule was disabled due to too many errors.

    Posted

    Great service Jan, thanks!

  • Topic Author
  • Posted
    21 hours ago, ChristianSogaard said:

    Hei Jan

     

    I tried to create a pair of rules.

    I have other rules for open/close of windows, so the close windows rule are linked to this open rule.

     

    Is there a better way to do this? (delay before closing the windows). - im not happy for the wait 30 min command.

     

    Please login or register to see this code.

     

     

    Well, in ER5 you should be able to do this

    Please login or register to see this code.

    You do all actions in one rule.

    The .mode('killOthers') at the end makes the rule so that if the rule is invoked again it will kill all versions of the same rule that is "sleeping". 

    So if you press it once it will close them to 50% and go into a 30min sleep.

    If you press again before the 30min the new instance of the rule will kill the first that is sleeping and set to 50% again (no problem if it's  already 50%, yes?) and then start a new fresh 30min wait.

     

    Was that what you wanted?

    Posted (edited)
    1 hour ago, jgab said:

     

    Well, in ER5 you should be able to do this

    Please login or register to see this code.

    You do all actions in one rule.

    The .mode('killOthers') at the end makes the rule so that if the rule is invoked again it will kill all versions of the same rule that is "sleeping". 

    So if you press it once it will close them to 50% and go into a 30min sleep.

    If you press again before the 30min the new instance of the rule will kill the first that is sleeping and set to 50% again (no problem if it's  already 50%, yes?) and then start a new fresh 30min wait.

     

    Was that what you wanted?

    Hi Jan

     

    yes, looks good, Ill test it right away :-)

    and setValue will be value, right

     

    And Thank You :)

     

    Edited by ChristianSogaard
    Typo
    Posted

    Hi Jan

     

    I have migrated 75/180 rules from Ev4=>5.

    I really like the rule and timer overview, Thank you :-)

    Is this this the right way to declare variables in EV5

    Please login or register to see this code.

     

    Would it be possible to have an exclude function in Ev4, like instead of u_ ?

    when having a lot of rules with rule([[ ... i cant use use the --[[ ]]-- to mark out

    image.png.4ea081b7f7d43ba87a316eff39df54ab.png

     

     

    Posted

    @jgabDoes it mean that event4 will not be updated in the future?

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

    @jgabDoes it mean that event4 will not be updated in the future?

    Yes, I will fix serious bugs in ER4, but no new features.

    • Like 1
  • Topic Author
  • Posted
    11 hours ago, ChristianSogaard said:

    Hi Jan

     

    I have migrated 75/180 rules from Ev4=>5.

    I really like the rule and timer overview, Thank you :-)

    Is this this the right way to declare variables in EV5

    Please login or register to see this code.

     

    Would it be possible to have an exclude function in Ev4, like instead of u_ ?

    when having a lot of rules with rule([[ ... i cant use use the --[[ ]]-- to mark out

    Please login or register to see this link.

     

     

     

    Well, one way is to enable and disable rules with the functions er.enable() and er.disable()

    If you declare the rules in a table, like this

    Please login or register to see this code.

    you end up with a table of rules, as the rule(...) function returns the rule object.

    By default the rules are enabled, but you can use the function er.disable(ruleSet) 

    to disable all the rule in the table directly after they are defined.

    The advantage with this is that you can use enable and disable from within rules so you could have another 

    rule that says 

    rule("@10:00 => enable(ruleSet); wait(03:00); disable(ruleSet)")

    in other words, enable the rules for a certain time during the day.

    I have used this to enable special Holliday rules in the past, lightning etc. (there is something similar for ER4)

     

    The other simple(r) approach is just the put the rules within an if-then-else

     

    in main where you load the modules you set up a table with the "rule sets" you want to enable/disable 

    Please login or register to see this code.

     

    Then in the local main in the modules you have an extra parameter, config

    Please login or register to see this code.

     

    end

     

    • Thanks 1
  • Topic Author
  • Posted
    11 hours ago, ChristianSogaard said:

    Hi Jan

     

    I have migrated 75/180 rules from Ev4=>5.

    I really like the rule and timer overview, Thank you :-)

    Is this this the right way to declare variables in EV5

    Please login or register to see this code.

     

     

    This makes 

    'matrix_kitchen' a global Lua variable

    It's better to make it an ER variable (only visible within rules) by declaring it as

    Please login or register to see this code.

    This assumes that in the beginning of main there is a declaration like

    Please login or register to see this code.

    There is still

    er.defvars(HT)

    to declare whole "home tables" with ER variables...

     

     

     

     

     

    • Thanks 1
    Posted (edited)

    Jan what I am doing wrong?

    Please login or register to see this code.

     

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

    Jan what I am doing wrong?

    Please login or register to see this code.

     

    You need to give me more info

    Please login or register to see this code.

    is a valid rule - what is the rest of the rule?

    Posted
    2 hours ago, jgab said:

     

    This makes 

    'matrix_kitchen' a global Lua variable

    It's better to make it an ER variable (only visible within rules) by declaring it as

    Please login or register to see this code.

    This assumes that in the beginning of main there is a declaration like

    Please login or register to see this code.

    There is still

    er.defvars(HT)

    to declare whole "home tables" with ER variables...

     

     

     

     

     

     

    from main

    Please login or register to see this code.

     

    from rule, and using var. 

    Please login or register to see this code.

     

    but i get this error, (line 63 is  var.HueLampID_1012 = 1012 -- Skrivebord L)

    it compiles with HueLampID_1012 = 1012 -- Skrivebord L

    Please login or register to see this code.

     

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

     

    from main

    Please login or register to see this code.

     

    from rule, and using var. 

    Please login or register to see this code.

     

    but i get this error, (line 63 is  var.HueLampID_1012 = 1012 -- Skrivebord L)

    it compiles with HueLampID_1012 = 1012 -- Skrivebord L

    Please login or register to see this code.

     

    Yes, in the example main(er) that I provide there is an argument 'er' that is a Lua table with some pre-defined Lua variables and functions.

    The function starts something like this

    Please login or register to see this code.

    Here we define a local function 'rule' that is the same as the function er.eval(...)

    This is the function we use to define rules.

    There is also a table, er.variables, that we define a local alias for named 'var'.

    If that is setup correctly we can do

    Please login or register to see this code.

    We could also use 

    Please login or register to see this code.

    but that's too long to type... ;-) 

     

    If you use your modules you need to set it up in each local main() that you have...

    Please login or register to see this code.

    and then use

    Please login or register to see this code.

     

    • Thanks 1
    Posted

    Hei Jan

     

    I have a usecase for Ev5 i want to hear you about.

     

    I using 25 pcs Matrix switches and each

    Please login or register to see this link.

    Switch have 4 LEDs 

    Im using the LEDs for background light and indicating different statuses - and the goal here is to avoid the background light (runs 4 times a day) overwrite the special status.

     

    I will maintain a Central Matrix LED Database from Scene 
    Identifying Matrix can be done like this - or just manual in the first version

     

    Store Matrix LED in database in Global Variable HTassets in JSON format.


    Fase One…
    Event runner 5 will be the brain to execute events.

    Usecase…
    When changing LED Color in a Logic Group Matrix button, when an external event like “Outdoor Light control goes from Automatic to Manually”, and this is indicated by a red Matrix LED. 

    Problem…
    Other Scenes/QAs like Day Color (Running 4 times a day) theme can overwrite this color. 

    Idea….
    When initiating EV5, it generates a working copy from Global Matrix HTassets (JSON)
    Matrix Switch the Day Color theme in the Matrix Led are addressed through the working copy.
        local HT = json.decode((fibaro.getGlobalVariable("HTassets")))
        Util.defvars(HT) 
        Util.reverseMapDef(HT)

    The LED asset value is removed from the working copy when Special status is given.
    [rule("fibaro.utils.remove(1000,rooms.all)") -- remove 1000]

    When the Light status goes back from Manually to Automatic. The LED asset value is added back to the working copy.
    [rule("add(rooms.all,1000)") -- add 1000]
    How can I add the Day Color theme to the LED asset, that was just copied back?
    My idea is - From the ROOM / Variable (Blue Color) I have the actual Color, that can be re-used for setting the right color to the LED asset.

    Like
    rule("add(rooms.all,1000)") 
    Rule(”terasse.lille.lys:isOff >> terasse.lille.Tryk1:color={$varrooms}; terasse.lille.Automation=false”)

    -- Day Color theme example
    rule([[$DayControl=='sleep' =>
            $varbaths = colorvalue.Normal;
            $varrooms = {0,0,0,16};
            $varcommon = colorvalue.Low;
            rooms.baths:color=colorvalue.Normal;
            rooms.rooms:color={0,0,0,16};
            rooms.common:color=colorvalue.Low;   
            ]])
     

    Would they be a good way to do this, or what do you think about this?

      

    Posted
    On 11/20/2023 at 8:44 PM, jgab said:

    In next version of ER5 there will be 2 variables defined

    'uptimeStr' that gives a string with uptime in days hour and minutes.

    Ex.

    Please login or register to see this code.

    and uptimeMinutes that return the number of uptime minutes as a number.

     

    So, a rule like

    Please login or register to see this code.

    should work...

    I tried on version 0.300 - and i get no trigger -uptimeMinutes 

    Posted

    Hi Jan

    How do i do Util.defTriggerVar - in ER5

    Please login or register to see this code.

     

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