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
1 hour ago, jgab said:

Well, if you at the right hand do <expr> & <expr> & <expr> ... it will stop when the first expr becomes false.

My guess here is that broadcast() return nil - i.e. false, and the expression terminates and the CEO flag never gets set.

Make broadcast return true or rewrite 

Please login or register to see this code.

or alternatively

Please login or register to see this code.

or alternatively

Please login or register to see this code.

 

The second error doesn't make sense and I can't repeat it. You have some invisible unicode characters in that string?

The  global variable 

Please login or register to see this code.

contains a single string 'yes' or  'no'. And yes it makes no sense, as it complains about device ID, while in this rule there is no device at all..

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

    The  global variable 

    Please login or register to see this code.

    contains a single string 'yes' or  'no'. And yes it makes no sense, as it complains about device ID, while in this rule there is no device at all..

    So, I have seen similar strange errors like this when there have been (invisible)unicode characters in the string that throws off the parser. Try to rewrite it. If it doesn't work can you PM me a version that doesn't work?

    Posted
    Just now, jgab said:

    So, I have seen similar strange errors like this when there have been (invisible)unicode characters in the string that throws off the parser. Try to rewrite it. If it doesn't work can you PM me a version that doesn't work?

    Yes, i will try it, and come back to you with answer.

    Thanks

    Posted

    Jan, can you please give me som link where i could find some description of rule for UI element interactions?

    I have grinded through the entire topic,, ehhh pain in ass

    I have found only this line

    Please login or register to see this code.

    but this doesn't work for me. An what about other elements. How to use them?

    THanks

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

    Jan, can you please give me som link where i could find some description of rule for UI element interactions?

    I have grinded through the entire topic,, ehhh pain in ass

    I have found only this line

    Please login or register to see this code.

    but this doesn't work for me. An what about other elements. How to use them?

    THanks

    Well, you need to set the onReleased function to FEventRunner4

    and then you match against the ID of the button. Default in ER4 it's setup to turn on and off som debugging but you could of course add your own buttons.

    If you only need standard UI's, like a binary switch or multilevel switch, you could generate child QAs from within ER

     

    Posted (edited)
    10 minutes ago, jgab said:

    Well, you need to set the onReleased function to FEventRunner4

    and then you match against the ID of the button. Default in ER4 it's setup to turn on and off som debugging but you could of course add your own buttons.

    If you only need standard UI's, like a binary switch or multilevel switch, you could generate child QAs from within ER

     

    Kill me Jan, but i can't see a single line with description of FEventRunner4, also don't understand your question. I jsut want to create a UI element like slider, button, label, and interact with them, i mean with button and slider. What do you mean byt setting onReleased to FEventrunner? 

     

    Like in regualr way, i set the callback name of onReleased function, and i make my stuff in that function, so when the user presses that button, the callback runs.

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

     

    When you define a button/slider handler in the web UI you set the QA function that should be called on onReleased/onChanged, yes?

    Here you set all functions to FEventRunner4, and there is a builtin function defined

    Please login or register to see this code.

    that makes an ER event of it and posts it so that you can write a rule like

    Please login or register to see this code.

    where the 'name' is actually the ID of the button/slider.

    You could define your own button handler too, and post an event from that

    Ex.

    Please login or register to see this code.

     

    However, ER is supposed to handle 100's of rules and many use cases so it doesn't scale to put a lot of buttons on the ER QA (there are already a few for turning on/off debugging).

    The normal way to do it is to make a separate QA that posts events to ER to trigger rule, where the UI can be anything and dedicated to particular use-case.

    Alternatively, if you can do with "standard" QAs like binary and multilevelswitches (with sliders), you can create child QAs from ER that is easily integrated with the rules in the main ER QA according to the previous post.

     

     

    Edited by jgab
    Posted (edited)
    13 minutes ago, jgab said:

     

    When you define a button/slider handler in the web UI you set the QA function that should be called on onReleased/onChanged, yes?

    Here you set all functions to FEventRunner4, and there is a builtin function defined

    Please login or register to see this code.

    that makes an ER event of it and posts it so that you can write a rule like

    Please login or register to see this code.

    where the 'name' is actually the ID of the button/slider.

    You could define your own button handler too, and post an event from that

    Ex.

    Please login or register to see this code.

     

    However, ER is supposed to handle 100's of rules and many use cases so it doesn't scale to put a lot of buttons on the ER QA (there are already a few for turning on/off debugging).

    The normal way to do it is to make a separate QA that posts events to ER to trigger rule, where the UI can be anything and dedicated to particular use-case.

    Alternatively, if you can do with "standard" QAs like binary and multilevelswitches (with sliders), you can create child QAs from ER that is easily integrated with the rules in the main ER QA according to the previous post.

     

     

    Ohhh. So basically ER4 is not really suited for creating standalone QAs, like I used to do with help of Fibaroextra. This needs a completely different approach.  Isn't this inter-QA data change slowing down the system? I mean i have QAs for heating scheduling, that has thousands of lines of code using fibaroExtra. It has like 20 UI elements, mostly buttons, and labels.

    I was about to completely refactor these QAs using ER4, so the lot of codes of events in there could be cut into a shorter, more transparent bunch of codes. And that QA uses a lot of events, so sending event data from one QA to another should slow down the communication or not?

    So the basic question is, how to utilize ER4? What is the best approach. I thought i can wrap my entire system into one ER4 QA.

     

    For example we are using at all our customer's installation this QA, that is dedicated to replace Fibaro's climate scheduler, as sadly it does not have a YUBII representation, so users can not interact with their heating system in their mobiles. That is something that driving me crazy btw. SO we developed this QA.

    How to best harness ER4 functionality in such a complex QA?

    Please login or register to see this attachment.

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

    Ohhh. So basically ER4 is not really suited for creating standalone QAs, liek I used to do with help of Fibaroextra. This needs a completely different approach.  Isn't this inter-QA data change slowing down the system? I mena i have QAs for heating scheduling, that has thousands lines of code using fibaroExtra. It has like 20 UI elements, mostly buttons, and labels.

    I was about to completely refactor these QAs using ER4, so the lot of codes of events in there could be cut into a shorter, more transparent bunch of codes.

    No, the inter QA communication is fast enough. You could keep the UI in a separate QA and run the scheduling logic in ER.

    I wouldn't run a lot of ER4 QAs in the system. I have 4 now. Lightning, "Alarm", Presence, and Testing - and they communicate with each other.

    Heating could warrant a separate QA - especially if its' thousands of lines now..

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

    Ohhh. So basically ER4 is not really suited for creating standalone QAs, like I used to do with help of Fibaroextra. This needs a completely different approach.  Isn't this inter-QA data change slowing down the system? I mean i have QAs for heating scheduling, that has thousands of lines of code using fibaroExtra. It has like 20 UI elements, mostly buttons, and labels.

    I was about to completely refactor these QAs using ER4, so the lot of codes of events in there could be cut into a shorter, more transparent bunch of codes. And that QA uses a lot of events, so sending event data from one QA to another should slow down the communication or not?

    So the basic question is, how to utilize ER4? What is the best approach. I thought i can wrap my entire system into one ER4 QA.

     

    For example we are using at all our customer's installation this QA, that is dedicated to replace Fibaro's climate scheduler, as sadly it does not have a YUBII representation, so users can not interact with their heating system in their mobiles. That is something that driving me crazy btw. SO we developed this QA.

    How to best harness ER4 functionality in such a complex QA?

    Please login or register to see this attachment.

     

    You could also make and hybrid - where the UI QA gets time and actions inputs and post them to ER to schedule and run the rules.

    Alternatively is to post all UI buttons direct to ER and let ER update the labels in the UI QA - but if you have a lot of time settings etc in the UI QA

    it could be better (and more responsive) to keep that local in the UI QA.

    • Like 1
    Posted (edited)
    9 minutes ago, jgab said:

     

    You could also make and hybrid - where the UI QA gets time and actions inputs and post them to ER to schedule and run the rules.

    Alternatively is to post all UI buttons direct to ER and let ER update the labels in the UI QA - but if you have a lot of time settings etc in the UI QA

    it could be better (and more responsive) to keep that local in the UI QA.

    I hope for the best, that one day Fibaro creates a mobile access for climate scheduling, (like every single 100 eur IKEA wifi based smart system has.) Hard to explain to a customer, who has paid 20 000 for a system, that he can't access his scheduler from his mobile. They don't want to fumble in their PCs. So we will probably keep heating  in separate QA, 

    We will use ER4 for lights and some other stuff doors, gates, garages. - of course after i managed to learn all the stuff that is going there.

    Edited by Neo Andersson
    Posted (edited)

    Hello @jgab

    I want to get notified, when a global variable value changes, so i wrote the following rule

     

    Please login or register to see this code.

     

    It seems to work when variable is changed, however, it triggers also randomly without any interaction, or whatsoever, and the variable has the same value. Where can be the problem?

     

    I also noticed, that first time it reports the value correctly, then later without any change it sends a kinda table value like this 61f429e760754338b13c537e|18eda250f1c402eb31b07f72921fae18

     

    Edited by Neo Andersson
  • Topic Author
  • Posted (edited)
    20 hours ago, Neo Andersson said:

    Hello @jgab

    I want to get notified, when a global variable value changes, so i wrote the following rule

     

    Please login or register to see this code.

     

    It seems to work when variable is changed, however, it triggers also randomly without any interaction, or whatsoever, and the variable has the same value. Where can be the problem?

     

    I also noticed, that first time it reports the value correctly, then later without any change it sends a kinda table value like this 61f429e760754338b13c537e|18eda250f1c402eb31b07f72921fae18

     

    Well, you match against the raw event value for global variables. 

    The "normal" way would be to do

    Please login or register to see this code.

    why you got the strange values makes no sense - is 'ext_lux_limit' an variable pointing to the real global variable name? otherwise it will be nil and match all global variables.

    Edited by jgab
    Posted
    1 hour ago, jgab said:

    Well, you match against the raw event value for global variables. 

    The "normal" way would be to do

    rule("$ext_lux_limit  => log('Lux value has changed to %s', $ext_lux_limit) ")

    why you got the strange values makes no sense - is 'ext_lux_limit' an variable pointing to the real global variable name? otherwise it will be nil and match all global variables.

    Yes it is a regualr gloal variable holding the treshold limit of external light to trun inner lights on upon.

     

    Please login or register to see this attachment.

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

    Yes it is a regualr gloal variable holding the treshold limit of external light to trun inner lights on upon.

     

    Please login or register to see this attachment.

    Yes, but then you need to quote the name, otherwise it will be interpreted as a (Lua/rule) variable with value nil.

    Like this

    Please login or register to see this code.

    because it was nil it matched all global-variables and you may have had some global with other strange values...

    Posted (edited)

    @jgab Okay, thats clear. Here is another challange. If i use wait function, where the argument of the wait function is coming from a function, it never works. It complains that ..comparing number with string.

     

    Please login or register to see this code.

     

    Edited by Neo Andersson
  • Topic Author
  • Posted
    6 hours ago, Neo Andersson said:

    @jgab Okay, thats clear. Here is another challange. If i use wait function, where the argument of the wait function is coming from a function, it never works. It complains that ..comparing number with string.

     

    Please login or register to see this code.

     

    Rules never work with time expressed as strings. In rule there are time constants like 00:00:10 (without quotes) and they are compiled to an integer representing the number of seconds (10 in this case)

    If you send a string into ER rules they will treat it as strings...

    Either you send the value as an int from your Lua function.

    Ex.

    Please login or register to see this code.

    fibaro.toTime is coming from fibaroextra that ER uses.

    ..or you convert the time string to a time value with the time() function in ER.

    Please login or register to see this code.

     

    There is one kind of exception to this. If you store a time string in a global variable, it will automatically be converted to the corresponding int value of seconds when accessed.

    Ex.

    fibaro.setGlobalVariable('myTime','00:00:10')

    Please login or register to see this code.

    This type of automatic marshalling of values stored in globalVariables are quite convenient but can be turned off with a flag...

    Posted
    2 hours ago, jgab said:

    Rules never work with time expressed as strings. In rule there are time constants like 00:00:10 (without quotes) and they are compiled to an integer representing the number of seconds (10 in this case)

    If you send a string into ER rules they will treat it as strings...

    Either you send the value as an int from your Lua function.

    Ex.

    Please login or register to see this code.

    fibaro.toTime is coming from fibaroextra that ER uses.

    ..or you convert the time string to a time value with the time() function in ER.

    Please login or register to see this code.

     

    There is one kind of exception to this. If you store a time string in a global variable, it will automatically be converted to the corresponding int value of seconds when accessed.

    Ex.

    fibaro.setGlobalVariable('myTime','00:00:10')

    Please login or register to see this code.

    This type of automatic marshalling of values stored in globalVariables are quite convenient but can be turned off with a flag...

    Thanks. Ehh. Its a bit hard to gather all these detailed info piece by piece, and also I don't want to overload you with questions, but it is impossible to effectively find answers in topic (if there are any), so i don't have other way, just to bother you with questions.

    I have grinded through all the thousands of comments, and created a short helper file for myself, but there is a lot of things that is not even mentioned there. Like this that you answered now. (or maybe somewhere it is there, but really hard to dig it out when needed)

    I am pretty sure, that ER4 has so many unbelievably helpful, powerful functions, and they remain unutilized, as people don't know about it. Like this with global variables. Incredibly good idea, and nice help for us.

     

  • Topic Author
  • Posted
    On 9/18/2023 at 9:54 PM, Neo Andersson said:

    Thanks. Ehh. Its a bit hard to gather all these detailed info piece by piece, and also I don't want to overload you with questions, but it is impossible to effectively find answers in topic (if there are any), so i don't have other way, just to bother you with questions.

    I have grinded through all the thousands of comments, and created a short helper file for myself, but there is a lot of things that is not even mentioned there. Like this that you answered now. (or maybe somewhere it is there, but really hard to dig it out when needed)

    I am pretty sure, that ER4 has so many unbelievably helpful, powerful functions, and they remain unutilized, as people don't know about it. Like this with global variables. Incredibly good idea, and nice help for us.

    No problems asking questions :-) 

    Posted (edited)

    @jgab Hello Jan. Is there any abbreviation for IF ELSE syntax, where we can simplify multiple conditions check? Like if i am checking

    Please login or register to see this code.

     

    can we somehow simplify this, i don't know something like

    Please login or register to see this code.

    so we can get a rule like

     

    Please login or register to see this code.

     

    What is the operator syntax for AND, OR logical comparisons in the || <condition> >> <action> formula if we have multiple conditions?   This doesn't seem to work || <condition1> & <condition2> >> <action>

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