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

15 minutes ago, Neo Andersson said:

Oh you misundesrstood me...I want to get created these rule for every data int TTSDATA global.

 

rule(name = ip)

 

where name is coming from he global, an ip is the corresponding global. So we dont know the names, we cant compare them like if data.name == "Business"...

 

the data is there, but inside ER5 i cant do the comparison, as these names are always different in different installations.

 

This process should initialize for me all the rule(speakername = IP) rules automatically.

 

First we always create that global table when installing and later i would install ER5,so my goal is in ER5 all these name=ip deinifitions would be defined automatically accordint to the TTSDATA global table.

 

 

This is an exaple from one installations

 

 rule("business_speaker = '192.168.1.225'")
    rule("meeting_speaker = '192.168.1.238'")
    rule("kitchen_speaker = '192.168.1.239'")
    rule("ceo_speaker = '192.168.1.244'")
    rule("corridor_speaker1 = '192.168.1.217'")
    rule("corridor_speaker2 = '192.168.1.235'")
    rule("dining_speaker = '192.168.1.220'")
    rule("corridor_all_speakers = {'192.168.1.217','192.168.1.235'}")
    rule("wellness_speaker = '192.168.1.241'")
    rule("wellness_speaker2 = '192.168.1.216'")
 
 
I would like to have these rules to be created according to the global TTSDATA variable.

 

Okay i have found the way..thanks you fo the help

Link to comment
Share on other sites

  • Topic Author
  • Please login or register to see this code.

    I takes into account 'corridor_all_speakers' with the list of ip addresses. Only one level as it's kind of a hack to format it.

    I would have chosen the name as the key and ip and mac in the value...

    • Thanks 1
    Link to comment
    Share on other sites

    5 minutes ago, jgab said:

    I would have chosen the name as the key and ip and mac in the value...

    Yeas i would like too, but the logic of the entire code makes it more difficult if name is the key, and IP is just a parameter.

    Link to comment
    Share on other sites

  • Topic Author
  • So, for 'corridor_all_speakers' the key is a table of ip addresses? It's usually not good practice to have tables as keys as 2 similar looking tables are not the same key, but I guess it works in this case...?

    Link to comment
    Share on other sites

    Just now, jgab said:

    So, for 'corridor_all_speakers' the key is a table of ip addresses? It's usually not good practice to have tables as keys as 2 similar looking tables are not the same key, but I guess it works in this case...?

    Oh sorry...no..that corridor_all_speakers should not be shown to you in my example. I just copied pasted a cod snippet.. There are only 1 ip - 1 name tables in that Global table. Thise gropued tables are just for ER5 usage

    Link to comment
    Share on other sites

  • Topic Author
  • If you only have single strings (ip addresses) as keys you can simplify defineVar to

    Please login or register to see this code.

     

    • Thanks 1
    Link to comment
    Share on other sites

    @jgab Jan i have still these missing controls on ER5 web ui.

     

    Reinstalled, then it was visilbe for a while, then got lost again

     

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    @jgab Jan how to prevent a rule to break ER5 when fetching a Global fails?

     

    rule("$ER5_USER_IDS => user_ids = $ER5_USER_IDS").start()

     

    Here i am defining user ids coming from a global variable. Later in the code this variable is used in a lot of rules.

     

    But if this is a nill valule, ER5 obviously can not use it for sending user_ids:msg = 'whatever'

     

    I can prevent to break when defining rule("$ER5_USER_IDS => user_ids = $ER5_USER_IDS and $ER5_USER_IDS or {}")

     

    but in this case errors remain when it comes to user_ids:msg = 'whatever' because user_ids is not defined, so how to prevent this?

    Edited by Neo Andersson
    Link to comment
    Share on other sites

    This is a restart rule, maybe someone needs it
     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • On 10/4/2024 at 12:01 PM, Neo Andersson said:

    @jgab Jan how to prevent a rule to break ER5 when fetching a Global fails?

     

    rule("$ER5_USER_IDS => user_ids = $ER5_USER_IDS").start()

     

    Here i am defining user ids coming from a global variable. Later in the code this variable is used in a lot of rules.

     

    But if this is a nill valule, ER5 obviously can not use it for sending user_ids:msg = 'whatever'

     

    I can prevent to break when defining rule("$ER5_USER_IDS => user_ids = $ER5_USER_IDS and $ER5_USER_IDS or {}")

     

    but in this case errors remain when it comes to user_ids:msg = 'whatever' because user_ids is not defined, so how to prevent this?

    You can do

    Please login or register to see this code.

    Then it will send to user -1 that will do nothing...

    • Like 1
    • Thanks 1
    Link to comment
    Share on other sites

    5 hours ago, jgab said:

    You can do

    Please login or register to see this code.

    Then it will send to user -1 that will do nothing...

    getting this error

    Last err: [Rule:7:$ER5_USER_IDS => user_ids = $ER5_USER_IDS or (log('No user ids') and {-1})] Parser: bad expression $ER5_USER_IDS => user_ids = $ER5_USER_IDS or (log('No user ids') and {-1}) ^

    Link to comment
    Share on other sites

    Hi, I'm trying to set up child devices that will let me adjust threshold values without editing the QA code.

     

    something like the below, with the idea that I could change the sliders on the multilevel switch child devices to adjust the thresholds. these lux thresholds are used as conditions in other rules to determine things like lights coming on and blinds moving up and down. 

     

    Please login or register to see this code.

     

    However the UI event doesn't appear to have the arguments to setValue passed through?

    Please login or register to see this code.

     

    therefore that second rule crashes (tonumber can't handle an empty table {})

     

    I couldn't seem to devise a rule that would catch the action rather than the UI event.

     

    Any ideas?

    Link to comment
    Share on other sites

  • Topic Author
  • 4 hours ago, bonhomme said:

    Hi, I'm trying to set up child devices that will let me adjust threshold values without editing the QA code.

     

    something like the below, with the idea that I could change the sliders on the multilevel switch child devices to adjust the thresholds. these lux thresholds are used as conditions in other rules to determine things like lights coming on and blinds moving up and down. 

     

    Please login or register to see this code.

     

    However the UI event doesn't appear to have the arguments to setValue passed through?

    Please login or register to see this code.

     

    therefore that second rule crashes (tonumber can't handle an empty table {})

     

    I couldn't seem to devise a rule that would catch the action rather than the UI event.

     

    Any ideas?

    WIthout dealing into the code, I see that you set the rule to use 

    Please login or register to see this code.

    but the trace come as 

     

    #UI{id=598,action="setValue",args={}}

     

    ... no trailing '_ID'.  Is that the problem?

    Link to comment
    Share on other sites

    Well I assumed it resolved the name eg Lux_Morning_Light_ID to the numeric ID which is 598 for that child device (manually verified in the device list). Should it be logging something else?

    Link to comment
    Share on other sites

    @jgab Jan i have a global variable GLOBAL_LUX_TRESH_TABLE storing json string like {"3093":500, "234":555, etc} where the keys are device IDs.How can i access the elements in ER5. In example 3093 is the id of OfficeLight

    I have tried $GLOBAL_LUX_TRESH_TABLE[OfficeLight] doesnt work.

    Link to comment
    Share on other sites

  • Topic Author
  • OfficeLight is an integer but the keys in the table is strings so you need to convert the int to a string

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    1 hour ago, jgab said:

    OfficeLight is an integer but the keys in the table is strings so you need to convert the int to a string

    Please login or register to see this code.

     

    omg how could i miss that, thanks Jan

    Link to comment
    Share on other sites

    • 2 weeks later...

    Hi.

     

    Is there a way for eventrunner to control the Climate Panel of HC3? I have a couple of scenes that I would like to convert in to eventrunner. I haven been able to find any good examples. Is it supported?

     

    Here is an example of a rule I would like to convert. 

     

    Something like

    rule("SOVEROM1.HJEMME:isOff => {CLIMATE.1.ETG - SOVEROM1}:MANUAL:HEATING:HOLD == 19")

     

    Any help would be appreciated :)!

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 3 weeks later...

    @jgab Jan please..I am loosing the UI controls and labels of your ER5 QA all the time a save the ER5. When I reinstall they reappear..Can you tell where is the bug? I am attaching a little skeleton ER5 that i was testing this on.

     

    Please login or register to see this image.

    /monthly_2024_11/image.png.807cdfd568c53f9c84afc7cd0ded2de1.png" />

     

    Please login or register to see this attachment.

    Edited by Neo Andersson
    Link to comment
    Share on other sites

    @Nea, if you convert your scene into Lua you have the right sentence to write a rule with

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