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

Hi @jgab, thanks for the tip about the ER<id> tag, I had missed that.

 

I tried your suggestions about the child device.

 

First, just changing to 

Please login or register to see this code.

doesn't work (I wouldn't say it has no effect - it probably did change something - but it doesn't make the device work as intended). Clicking the (for example) 'open' command on the device shows this in the logs:

Please login or register to see this code.

 

However, the relevant rule above (which is defined as Rule 8 in this case) 

 

Please login or register to see this code.

 

is not triggered, or I would expect a trace with the ER293 tag similar to that Rule:1:1 trace above but for this rule.

 

If I also change UpdateProperty to :value, i.e.

 

Please login or register to see this code.

 

then I get more activity in the logs, but it doesn't result in the blinds opening or closing.

 

Please login or register to see this code.

 

(that's from one press of "open", I get similar for "close" except where "args":[1] it is instead "args":[0], which makes sense).

 

The corresponding rules to actually send the command to the blinds are still not triggered.

 

Any other suggestions I could try?

Posted
2 hours ago, jgab said:

 

So, in the later ER5's in the main file there is already a setup for loading modules from other files. You may not have updated the main file so you haven't seen it.

It's in the :onInit() setup part and looks like

 

Please login or register to see this code.

The commented part is the instructions.

Ex.

create a QA file named u_myRules1

with the content

Please login or register to see this code.

 

 

you also need to make sure that you have the module loading code in main

Please login or register to see this code.

 

The prio thing is so that you can decide in what order the modules should load if they have dependencies on each other...

@jgab Jan, but there is no such code in my main file, and  i am on the latest versioni 1.0

 

Please login or register to see this code.

 

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

    @jgab Jan, but there is no such code in my main file, and  i am on the latest versioni 1.0

     

    Please login or register to see this code.

     

    Yes, but main is not updated with QAUpdater (so your rules won't be overwritten) - so you probably don't have that code.

    In the main that comes with a clean install of ER5 the code is there.

    So either copy/paste from the main in GitHub or just copy the code in the previous post.

    Posted
    1 minute ago, jgab said:

    Yes, but main is not updated with QAUpdater (so your rules won't be overwritten) - so you probably don't have that code.

    In the main that comes with a clean install of ER5 the code is there.

    So either copy/paste from the main in GitHub or just copy the code in the previous post.

    Ahh okay , got it...so later on I dont even need to call  my other rules functions from other files. They will all become part of the global rules by their rule() function right?  

     

     

     

    Posted
    20 minutes ago, Neo Andersson said:

    Ahh okay , got it...so later on I dont even need to call  my other rules functions from other files. They will all become part of the global rules by their rule() function right?  

     

     

     

    Okay, I separated the files according to the setup instructions

     

    Please login or register to see this code.

     

     

    Now i got this

     

    Please login or register to see this image.

    /monthly_2024_01/image.png.f819238f73b2c12a59ac4cc906fc9ed5.png" />

     

    i dont get it.. 

  • Topic Author
  • Posted (edited)
    12 hours ago, bonhomme said:

    @jgab your suggestion worked, thank you!

     

    Now, I'm trying to make that child device work - it is triggering OnAction events 'open' and 'closed' but the :isOpen and :isClosed rules are not getting triggered. What's the correct way to pick up those actions?

     

    Please login or register to see this code.

     

    gives

     

    Please login or register to see this code.

     

    Setting the last two rules to watch Blinds_Upstairs instead of Blinds_Upstairs_D doesn't generate any errors, but the open/close events don't trigger the rules.

     

    Please login or register to see this code.

     

     

     

    Ok, It turned out that there is some issues with child objects. 

    This works

    Please login or register to see this code.

     

    The problem is that when we create a child object I inject code that intercepts all type defined actions to become #UI events that we can pick up in ER.

    Actions for rollerShutter are

    Please login or register to see this code.

    The problem is that <id>:value = x

    is translated to fibaro.call(id,"setValue",x)

    so it becomes an #UI event instead of actually setting the value/prop.

    So, in the code above we define a new method _updateProp(prop, val) that updates the property for the child and use that in the rule.

    I will add _updateProp to the next release but for now you can add it like I did in the example

     

    ...and rollerShutters want a value of 0 for closed and 99 for opened

    Edited by jgab
  • Topic Author
  • Posted
    1 hour ago, Neo Andersson said:

    Okay, I separated the files according to the setup instructions

     

    Please login or register to see this code.

     

     

    Now i got this

     

    Please login or register to see this link.

     

    i dont get it.. 

     

    So in the error message the ^^^ points at shs, so shs is not defined at the point when this module is loaded.

    You need to make sure that shs is defined.

    Put the shs definition in a module with prior < 3

    Posted (edited)
    8 minutes ago, jgab said:

     

    So in the error message the ^^^ points at shs, so shs is not defined at the point when this module is loaded.

    You need to make sure that shs is defined.

    Put the shs definition in a module with prior < 3

    Please login or register to see this code.

    Jan, i am loading all shs functions right in the main function..should not this be enough? shs functions are custom functions and do not contain any rules..

    So that means MODULES are loaded earlier than main function?

    Edited by Neo Andersson
  • Topic Author
  • Posted (edited)
    10 minutes ago, Neo Andersson said:

    Please login or register to see this code.

    Jan, i am loading all shs functions right in the main function..should not this be enough? shs functions are custom functions and do not contain any rules..

    Ok, that was a bug in the module loader so main (with prio 0)  was loaded after user modules.

    Change it to

    Please login or register to see this code.

    then it will load your main and setup shs before calling the modules.

    I will fix it in the next release

    Edited by jgab
    Posted

    @jgab you are amazing, that works beautifully.

  • Topic Author
  • Posted
    30 minutes ago, bonhomme said:

    @jgab you are amazing, that works beautifully.

    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

    Posted

    Please login or register to see this code.

     

    Jan, how it it possible that this file prio order does not complain about anything...

    All_rgbws is defined in file1, becuase it should be defined there to be accessable in a rule in file2

    However, in file 1 the HT table is not initialized yet, and still seem to work, so i can assign Stairs_LED and Kitchen_LED to All_rgbw  / at least no error message..

    So regarding  the HT table definition, it is not needed to get it created prior to using its element?

  • Topic Author
  • Posted
    6 minutes ago, Neo Andersson said:

    Please login or register to see this code.

     

    Jan, how it it possible that this file prio order does not complain about anything...

    All_rgbws is defined in file1, becuase it should be defined there to be accessable in a rule in file2

    However, in file 1 the HT table is not initialized yet, and still seem to work, so i can assign Stairs_LED and Kitchen_LED to All_rgbw  / at least no error message..

    So regarding  the HT table definition, it is not needed to get it created prior to using its element?

    check if you are not setting up the HT in main too - main has priority 0 - runs before 1 and 2

     

    When module 2 is loaded it will define the global lua variable HT with Stairs_LED and Kitchen_LED but who is actually doing er.defvars(HT) ?

    If that is done in main() that is already done by then...

    Posted (edited)
    4 minutes ago, jgab said:

    check if you are not setting up the HT in main too - main has priority 0 - runs before 1 and 2

     

    When module 2 is loaded it will define the global lua variable HT with Stairs_LED and Kitchen_LED but who is actually doing er.defvars(HT) ?

    If that is done in main() that is already done by then...

     er.defvars(HT) is done in MODULE2, but seems that even with this there is no error message, 

    Please login or register to see this code.

    does not trigger whith this module order..

    2 minutes ago, Neo Andersson said:

     er.defvars(HT) is done in MODULE2, but seems that even with this there is no error message, 

    Please login or register to see this code.

    does not trigger whith this module order..

    Goal is, to somehow separate these groupings to a standalone mondule..I have a lot of them, so they kinda just keep up the places..on the othere hand they are nothing else just simple grouping some existing HT table or rule defined elements into some groups, and these groups are used in rules...

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

     er.defvars(HT) is done in MODULE2, but seems that even with this there is no error message, 

    Please login or register to see this code.

    does not trigger whith this module order..

    Goal is, to somehow separate these groupings to a standalone mondule..I have a lot of them, so they kinda just keep up the places..on the othere hand they are nothing else just simple grouping some existing HT table or rule defined elements into some groups, and these groups are used in rules...

    Okay, i think there is only one way to get this working

    I need to define a complete standalone module just for HT table, or leave the HT table in the main functoin..

  • Topic Author
  • Posted

    Just to make it clear.

    In module 1 (that loads before module 2 because it has priority 1) you did

    Please login or register to see this code.

    this creates a ER variable All_rgbws that is {nil, nil} because Stairs_LED and Kitchen_LED is not defined yet (they are defined in module 2). It doesn't create an error because it's ok to assign a variable {nil, nil}

     

    In module 2 you did

    Please login or register to see this code.

    Which sets up the HT variables after module 1.

    All_rgbws is still {} and this creates an error (no trigger in rule).

     

    Solution. Setup HT in the module that runs before you use any HT variables in rules.

    In this example set it up in module 1 before you define All_rgbws

    or set up HT, as you suggest, in main() that is run first, before your modules.

    • Thanks 1
    Posted
    17 hours ago, jgab said:

    Just to make it clear.

    In module 1 (that loads before module 2 because it has priority 1) you did

    Please login or register to see this code.

    this creates a ER variable All_rgbws that is {nil, nil} because Stairs_LED and Kitchen_LED is not defined yet (they are defined in module 2). It doesn't create an error because it's ok to assign a variable {nil, nil}

     

    In module 2 you did

    Please login or register to see this code.

    Which sets up the HT variables after module 1.

    All_rgbws is still {} and this creates an error (no trigger in rule).

     

    Solution. Setup HT in the module that runs before you use any HT variables in rules.

    In this example set it up in module 1 before you define All_rgbws

    or set up HT, as you suggest, in main() that is run first, before your modules.

    @jgab Jan i need an urgent hellp..All the prioritirs of modules are set. HT table separated, and loaded as first. I am getting this error and i cant even identify it

    Last err: ./include/utils.lua:208: ./include/compiler.lua:140: attempt to index a nil value (local 'k')

  • Topic Author
  • Posted
    15 minutes ago, Neo Andersson said:

    @jgab Jan i need an urgent hellp..All the prioritirs of modules are set. HT table separated, and loaded as first. I am getting this error and i cant even identify it

    Last err: ./include/utils.lua:208: ./include/compiler.lua:140: attempt to index a nil value (local 'k')

    Can you share the rules you are creating (it's a rule that the compiler breaks on). Usually it's the next after the successful loaded rule.

    Just now, jgab said:

    Can you share the rules you are creating (it's a rule that the compiler breaks on). Usually it's the next after the successful loaded rule.

    Seems to be some array assignment.

    Posted
    3 minutes ago, Neo Andersson said:

    @jgab Jan i need an urgent hellp..All the prioritirs of modules are set. HT table separated, and loaded as first. I am getting this error and i cant even identify it

    Last err: ./include/utils.lua:208: ./include/compiler.lua:140: attempt to index a nil value (local 'k')

     

    2 minutes ago, jgab said:

    Can you share the rules you are creating (it's a rule that the compiler breaks on). Usually it's the next after the successful loaded rule.

    Seems to be some array assignment.

    Atteched the whoe fqa, this is very very urgent please. I am at customers house, where we used to have those problems with ER5

    Please login or register to see this attachment.

  • Topic Author
  • Posted

    This rule

    Please login or register to see this code.

    is missing commas after the R1 and R2 keys

    Please login or register to see this code.

     

    I will try to implement a better error message instead of crashing...

     

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