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
    13 minutes ago, Neo Andersson said:

    Now you scared me to death...Why would my rule 25 have 75 instances running at the same time? Did i misunderstand somehitng?

    No, not running at the same time. It's just the 75th instance running. The previous ones have terminated. 

    You could see 74th and 75th running at the same time, if they had a wait in ex.

    Posted

    Jan, i am using the abbreviated version for central scene event handling

     

    Please login or register to see this code.

     

    how can i fomrulate in the same way a rule for Released attribute to be true for every button release ?

    In old fashion i used to do it like this, where i am not specifying the key ID, just the attribute "Released", so whatever button is released all shutters should stop..

    Please login or register to see this code.

     

  • Topic Author
  • Posted
    1 minute ago, Neo Andersson said:

    Jan, i am using the abbreviated version for central scene event handling

     

    Please login or register to see this code.

     

    how can i fomrulate in the same way a rule for Released attribute to be true for every button release ?

    In old fashion i used to do it like this, where i am not specifying the key ID, just the attribute "Released", so whatever button is released all shutters should stop..

    Please login or register to see this code.

     

    The operator === (3 '=') is the string match operator.

    Please login or register to see this code.

    or there is :key.id and :key.attr

    Please login or register to see this code.

     

    • Like 1
    Posted
    4 hours ago, ChristianSogaard said:

    Thank you Jan

     

    I tried the Value:bin yesterday but it didnt work out for me, I see the SUM does the difference, Thank you.

    Indeed I need the Names, but i didnt get that long yesterday. Feel fee to help me MAP the User to the Swiches that would really be great..

    So i can send messages to the mobile Phone

     

    Did you have a great idea of the mapping of usernames ?;-) 

    Posted

    Jan, i used to label my rules with numbers, just have better view of them, when some error occours, in case I can't read out from the debug logs which rule has the problem (the rules are often too long, and in the debug window they are abbreviated)

    But it seems to me that the numbers are not correct, as far as it concerns my order.. Like in the picture below you see, for example dor me the 21th rule is hall_pir_any:breached....however if i look at your logs, that ER5 shows different number. This applies ofcourse for all rules.

    How should I number them to match the ER5 numbers?

     

    Please login or register to see this image.

    /monthly_2023_12/image.png.c6d2d925d5e203b1db4c793196da10c2.png" />

  • Topic Author
  • Posted
    11 hours ago, Neo Andersson said:

    Jan, i used to label my rules with numbers, just have better view of them, when some error occours, in case I can't read out from the debug logs which rule has the problem (the rules are often too long, and in the debug window they are abbreviated)

    But it seems to me that the numbers are not correct, as far as it concerns my order.. Like in the picture below you see, for example dor me the 21th rule is hall_pir_any:breached....however if i look at your logs, that ER5 shows different number. This applies ofcourse for all rules.

    How should I number them to match the ER5 numbers?

     

    Please login or register to see this link.

     

    So, they are actually numbered in the order they are defined. Starting with one.

    But it only counts rules defined with "=>"

    If you run some expression with rule(...) that is not an actual rule (eg. setup, logging etc) it doesn't count as a rule. ER just evaluates it and forget about it....

    However rules, having a '=>' are stored starting with an index of 1.

    For non-rules I like to define

    Please login or register to see this code.

    and do

    Please login or register to see this code.

    so I differ them from real rules (and they get another color)...

     

    Having said that - there is a way to label rules yourselves - it's kind of experimental so let's see how it works.

    Please login or register to see this code.

    [11.12.2023] [08:46:51] [TRACE ] [ER5000 ]: Defined [Rule:myRule] 88:isOn => log('ok')

     

    So, a rule gets its id (as a string) as the label per default. But we can assign our own label.

    The label could be anything and doesn't even need to be unique (I still use the ids under the hood) - labels are only for logging.

    If you try it out let me know how it works...

     

    Posted

    Jan I have around 1000 rules to add the numbers is a bit a pain. Can you use instead of number first part of rule just as when there is an error?

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

    Jan I have around 1000 rules to add the numbers is a bit a pain. Can you use instead of number first part of rule just as when there is an error?

    But there is...

    Please login or register to see this code.

     

    What's not to like with this?

    Please login or register to see this attachment.

  • Topic Author
  • Posted (edited)
    19 hours ago, ChristianSogaard said:

    Did you have a great idea of the mapping of usernames ?;-) 

    Well, your (virtual) deviceIds has nothing to do with userIds so you need a mapping table

    Please login or register to see this code.

     

    So, USER(name) is an existing function that returns the HC3 user with the name name. It returns the whole struct, like you get from swagger.

    Then we just retrieve the .id that is the user Id and map it to the virtual device id

    Please login or register to see this code.

    should then work...

     

    Actually, there is a small bug - but it will work in v0.82 coming later this afternoon.

    Edited by jgab
  • Topic Author
  • Posted (edited)

    Pushed v0.84

     

    minor bugfixes and some better error messages.

     

    New is that we can escape ' and " in strings.

    rule("log('It\\'s 10 o\\'clock')")

    The Lua rule is that in strings defined with "" and '' next character is escaped with \, so for ER to see that the ' is escaped we need to "escape the escape character \

    \\'

    which becomes \' for ER to see and ER can the escape the ' character.

     

    In Lua strings that are defined with [[]] Lua does not escape characters. However, ER will do it when looking through the string.

    So the same expression with [[]] becomes

    rule([[log('It\'s 10 o\'clock')]])

    Edited by jgab
    Posted

    @jgab I added on one QA your number rules and it looks very good!

    Please login or register to see this attachment.

    Posted
    4 hours ago, jgab said:

     

    So, they are actually numbered in the order they are defined. Starting with one.

    But it only counts rules defined with "=>"

    If you run some expression with rule(...) that is not an actual rule (eg. setup, logging etc) it doesn't count as a rule. ER just evaluates it and forget about it....

    However rules, having a '=>' are stored starting with an index of 1.

    For non-rules I like to define

    Please login or register to see this code.

    and do

    Please login or register to see this code.

    so I differ them from real rules (and they get another color)...

     

    Having said that - there is a way to label rules yourselves - it's kind of experimental so let's see how it works.

    Please login or register to see this code.

    [11.12.2023] [08:46:51] [TRACE ] [ER5000 ]: Defined [Rule:myRule] 88:isOn => log('ok')

     

    So, a rule gets its id (as a string) as the label per default. But we can assign our own label.

    The label could be anything and doesn't even need to be unique (I still use the ids under the hood) - labels are only for logging.

    If you try it out let me know how it works...

     

    The expressen part doesnt work for me. I think you meant expr instead of expressen, but even with that i cant see anyting. Maybe i am missing something. The rule labeling works fine, but i still dont know how to change colors for custom labeling, or for the rules itself.

    Posted

    @jgab

    before rule numbers Rules setup time: 1.300 seconds (115 rules)

    with rule numbers Rules setup time: 1.738 seconds (225 rules)

     

    Posted (edited)

    @jgab Jan, how can I differentiate rules being logged on UI with some colors. I would like to see rules that are evoked but condition failed in red, and rules that met conditions and are triggered in green. Should i create a custom function for this or there is an inbuilt option for this in ER5?

     

    Please login or register to see this image.

    /monthly_2023_12/image.png.5aca5dc64fc74e68da0347e8998b2a08.png" />image.png.c5babaf74571d7ab389cbcaf415a5bf4.png

    Edited by Neo Andersson
    Posted

    @jgab

    woonkamer.Eethoeklamp;isOff  this typo did't report as error
    Posted
    8 hours ago, jgab said:

    Well, your (virtual) deviceIds has nothing to do with userIds so you need a mapping table

    Please login or register to see this code.

     

    So, USER(name) is an existing function that returns the HC3 user with the name name. It returns the whole struct, like you get from swagger.

    Then we just retrieve the .id that is the user Id and map it to the virtual device id

    Please login or register to see this code.

    should then work...

     

    Actually, there is a small bug - but it will work in v0.82 coming later this afternoon.

    Thank you Jan - Im getting messages to the Phone.

     

    Getting Logs like this...

    People at Home using Value [2120,2121,2122,2123]

     

    Can i use above mapping to replace the numbers with names ? I guess not - how to to that?
    Perhaps a new name table ? because the names in the "Access" dont allow spaces, and because of that a cant use that for TTS

  • Topic Author
  • Posted
    5 hours ago, Neo Andersson said:

    The expressen part doesnt work for me. I think you meant expr instead of expressen, but even with that i cant see anyting. Maybe i am missing something. The rule labeling works fine, but i still dont know how to change colors for custom labeling, or for the rules itself.

    Sorry, must have been autocomplete - it should be 'expr'

    2 hours ago, Sjakie said:

    @jgab

    woonkamer.Eethoeklamp;isOff  this typo did't report as error

    No, because it technically it isn't an error - it's just meaningless code. It's "woonkamer.Eethoeklamp" that returns the value of that and then "isOff" as a second statement that's interpreted as a variable, and probably returns nil.

  • Topic Author
  • Posted
    3 hours ago, Neo Andersson said:

    @jgab Jan, how can I differentiate rules being logged on UI with some colors. I would like to see rules that are evoked but condition failed in red, and rules that met conditions and are triggered in green. Should i create a custom function for this or there is an inbuilt option for this in ER5?

     

    Please login or register to see this link.

    Please login or register to see this link.

    No, not in the UI. The routine that logs this in the UI needs to be rather quick as not to slow down ER too much. 

    If we want to do more fancy stuff here the logic needs to be different - like buffering and update every 5s or something like that.

    4 hours ago, Sjakie said:

    @jgab

    before rule numbers Rules setup time: 1.300 seconds (115 rules)

    with rule numbers Rules setup time: 1.738 seconds (225 rules)

     

    Can you share the code? Seems very strange...

    1 hour ago, ChristianSogaard said:

    Thank you Jan - Im getting messages to the Phone.

     

    Getting Logs like this...

    People at Home using Value [2120,2121,2122,2123]

     

    Can i use above mapping to replace the numbers with names ? I guess not - how to to that?
    Perhaps a new name table ? because the names in the "Access" dont allow spaces, and because of that a cant use that for TTS

     

    1 hour ago, ChristianSogaard said:

    Thank you Jan - Im getting messages to the Phone.

     

    Getting Logs like this...

    People at Home using Value [2120,2121,2122,2123]

     

    Can i use above mapping to replace the numbers with names ? I guess not - how to to that?
    Perhaps a new name table ? because the names in the "Access" dont allow spaces, and because of that a cant use that for TTS

     

    Maybe something like this

    Please login or register to see this code.

    Please login or register to see this code.

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

    @jgab

    before rule numbers Rules setup time: 1.300 seconds (115 rules)

    with rule numbers Rules setup time: 1.738 seconds (225 rules)

     

    Yes, see my PM. The idea is to attach labels to the existing rules. Now you define an additional "log rule"

    • Like 1
    Posted (edited)

    @jgabJan, if i have a truefor rule, or a rule with wait function, and I restart the QA, should all these timers reset, or the timers will run off, and finish the job after QA has restarted?

     

    Edited by Neo Andersson

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