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

11 minutes ago, jgab said:

Well, the ||>> is already an if-then-else

 

Please login or register to see this code.

...etc

 

Note, no ';' after last expression in then-do-this

okay, ELSEIFworks like this i know, but how ELSE works? If testvariable < 4 then testvariable = testvariable + 1 else testvariable = 1 end. How you write this with rule?

And if there is no ";" used after the actions on right side, how can i combine this pattern with some more actions. Like || condition >> action; hub.call(id, action) where the hub call should be completely independet from the IF part. Cant i use ; to separate them?

Edited by Neo Andersson
Link to comment
Share on other sites

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

    okay, ELSEIFworks like this i know, but how ELSE works? If testvariable < 4 then testvariable = testvariable + 1 else testvariable = 1 end. How you write this with rule?

    Please login or register to see this code.

     

    1 hour ago, Neo Andersson said:

    And if there is no ";" used after the actions on right side, how can i combine this pattern with some more actions. Like || condition >> action; hub.call(id, action) where the hub call should be completely independet from the IF part. Cant i use ; to separate them?

    Good observation. You can still have many expressions in the the action separated with ';' - just don't end with a ';'

    Please login or register to see this code.

    To break and have a statement after the the ||>> you use a double ';;' at the end (I know, a bit ugly but it gets the job done)

    Please login or register to see this code.

     

    Edited by jgab
    • Like 1
    Link to comment
    Share on other sites

    2 hours ago, jgab said:

    Please login or register to see this code.

     

    Good observation. You can still have many expressions in the the action separated with ';' - just don't end with a ';'

    Please login or register to see this code.

    To break and have a statement after the the ||>> you use a double ';;' at the end (I know, a bit ugly but it gets the job done)

    Please login or register to see this code.

     

    @jgabJan i have one more...

    How to break the execustion of a rule?

     

    rule("sensor:breached=> || $nobody_home == false >> exit;;... here comes som more code, that should not be run in case nobody_home is false. I know, it can be done with if else etc, but in the remaining code i have so many if end loops, that its better to exit the rule right at the beggining when nobody_home == false.

    Link to comment
    Share on other sites

  • Topic Author
  • 13 hours ago, Neo Andersson said:

    @jgabJan i have one more...

    How to break the execustion of a rule?

     

    rule("sensor:breached=> || $nobody_home == false >> exit;;... here comes som more code, that should not be run in case nobody_home is false. I know, it can be done with if else etc, but in the remaining code i have so many if end loops, that its better to exit the rule right at the beggining when nobody_home == false.

     

    rule("sensor:breached=> || $nobody_home == false >> return();;... here comes som more code, 

     

     

    It's 

    Please login or register to see this code.

    ER need the () as opposed to ex. Lua.

    Link to comment
    Share on other sites

    1 hour ago, jgab said:

     

    rule("sensor:breached=> || $nobody_home == false >> return();;... here comes som more code, 

     

     

    It's 

    Please login or register to see this code.

    ER need the () as opposed to ex. Lua.

    Thanks

    Link to comment
    Share on other sites

  • Topic Author
  • On 11/9/2023 at 4:45 PM, Neo Andersson said:

    @jgab Hello Jan

    What is the best way to add 14 day to a given date (using rules)

    Please login or register to see this code.

     

    It's a bit tricky with date arithmetic. In the best of worlds you want it to work with leap years and daylight time savings....

    The simple way is to do

    Please login or register to see this code.

    but that doesn't work if we cross leap year or daylight time savings.

    A bit safer is
     

    Please login or register to see this code.

    that only have an issue with leap years and Feb 29...

    In ER5 I'm thinking about some better date arithmetics...

    Link to comment
    Share on other sites

    @jgab Hello Jan, why is this rule throwing error?

     

    Please login or register to see this code.

     

     

    Please login or register to see this code.

     

    Edited by Neo Andersson
    Link to comment
    Share on other sites

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

    @jgab Hello Jan, why is this rule throwing error?

     

    Please login or register to see this code.

     

     

    Please login or register to see this code.

     

    What errors do you get?

    Link to comment
    Share on other sites

    17 hours ago, jgab said:

    What errors do you get?

    Hello

    I think i have found the source. First i was trying to use the same logic as in my example above for multiple radiators

    Please login or register to see this code.

    That was initially throwing errors, later as in my example above i am trying to use only single radiators, and that works. /sorry I copy pasted the example above with single radiator, and that did not show error so far

    When i used table for radiators, it htrew an error like no trigger found in head

    This doesnt work if i am using table for radiators?

     

     

    Link to comment
    Share on other sites

    53 minutes ago, Neo Andersson said:

    Hello

    I think i have found the source. First i was trying to use the same logic as in my example above for multiple radiators

    Please login or register to see this code.

    That was initially throwing errors, later as in my example above i am trying to use only single radiators, and that works. /sorry I copy pasted the example above with single radiator, and that did not show error so far

    When i used table for radiators, it htrew an error like no trigger found in head

    This doesnt work if i am using table for radiators?

     

     

    @jgab Jan this is another examle giving me the same error.

    Please login or register to see this code.


    [18.11.2023] [13:14:19] [ERROR] [QUICKAPP2311]: Error in 'testval==30=>mobiles:msg='test'': ./include/EventRunner.lua:1802: ./include/EventRunner.lua:1460: no triggers found in header[18.11.2023] [13:14:19] [ERROR] [QUICKAPP2311]:

    Main() ERROR:./include/EventRunner.lua:1904: ./include/EventRunner.lua:1802: ./include/EventRunner.lua:1460: no triggers found in header[18.11.2023] [13:14:19]

    [ERROR] [QUICKAPP2311]: QuickApp crashed[18.11.2023] [13:14:19]

    [ERROR] [QUICKAPP2311]: Unknown error occurred: basic_string::_S_construct null not valid

     

     

    I have tried it with real device (not a test value)

     

    Please login or register to see this code.

    This doesn't trigger either, but here no errors occurs. So maybe the syntax for message sending to a phone is corrupt?

    Edited by Neo Andersson
    Link to comment
    Share on other sites

  • Topic Author
  • Table of radiators works for me (and should work). Also assigning a table of radiators with a roomTemp value.

    Sure you didn't misspell something?

    Link to comment
    Share on other sites

    1 minute ago, jgab said:

    Table of radiators works for me (and should work). Also assigning a table of radiators with a roomTemp value.

    Sure you didn't misspell something?

    I am pretty sure, but will give it a try agian with tripplechek of spelling.

    Link to comment
    Share on other sites

    @jgabHello Jan..Please check this rule below. I have transposed several client's systems to ER4 recently, and many of them had a functionality that when open window was detected they used to get notifications. And it was working nicely while i was using fibaroExtra event handling.

    So now i have created a rule , but this never seems to trigger.

    Do you see anyhting that should not be as it is?

    Please login or register to see this code.

     

    I have tried something like this to check for one radiator if we cen get windowOpened value directly

     

    Please login or register to see this code.

    This doesn't work for me so thats why i decided to go for the device event solution below.

     

     

    Please login or register to see this code.

     

     

     

     
    Edited by Neo Andersson
    Link to comment
    Share on other sites

  • Topic Author
  • but :windowOpened is not a valid check in er4.

    do :breached  or :isOn

     

    A window sensor that is opened sends a device event with property 'value' set to true

    #device{id=<id>, property='value', value=true} -- sensor breached/opened

    #device{id=<id>, property='value', value=false} -- sensor safe/closed

    Edited by jgab
    Link to comment
    Share on other sites

    4 minutes ago, jgab said:

    but :windowOpened is not a valid check in er4.

    do :breached  or :isOn

     

    A window sensor that is opened sends a device event with property 'value' set to true

    #device{id=<id>, property='value', value=true} -- sensor breached/opened

    #device{id=<id>, property='value', value=false} -- sensor safe/closed

    Thats not a sensor Jan

    Its the inbuilt propeorty of a Fibaro radiator head

    2 minutes ago, Neo Andersson said:

    Thats not a sensor Jan

    Its the inbuilt propeorty of a Fibaro radiator head

    Please login or register to see this image.

    /monthly_2023_11/image.png.327031e509e06f078fb31dd5617b400a.png" />

    Link to comment
    Share on other sites

  • Topic Author
  • 3 minutes ago, Neo Andersson said:

    Thats not a sensor Jan

    Its the inbuilt propeorty of a Fibaro radiator head

    Please login or register to see this link.

    Ok, sorry, thought we talked about a window sensor.

    Yes, there is no code for :windowOpened in er4 so you have to use the device event approach

    Link to comment
    Share on other sites

    Just now, jgab said:

    Ok, sorry, thought we talked about a window sensor.

    Yes, there is no code for :windowOpened in er4 so you have to use the device event approach

    Is my event approach correctly formed? Bacuase it never seems to trigger

    Link to comment
    Share on other sites

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

     

    It should work IF the HC3 sends an event when the property changes.

    Can you see in the log if you get a sourceTrigger of type

    Please login or register to see this code.

    when you open the window?

     

    Is the radiator associated with a window sensor? or how/when does it update the windowOpened property?

     

    Link to comment
    Share on other sites

    5 minutes ago, Neo Andersson said:

    Is my event approach correctly formed? Bacuase it never seems to trigger

    okay i realaized that month (oct-may) was incorrect, so i changed to (oct - mar) but it didn help

    1 minute ago, jgab said:

     

    Please login or register to see this code.

     

    It should work IF the HC3 sends an event when the property changes.

    Can you see in the log if you get a sourceTrigger of type

    Please login or register to see this code.

    when you open the window?

     

    Is the radiator associated with a window sensor? or how/when does it update the windowOpened property?

     

    first of all, i relaized that i had bad month restriction. Obviously may-oct is not correct. I have changed it to oct-mar, as it should trigger only in winter season.

    On the other hand, windoOpened event is fired by Fibaro when there is a steap temerature drop near to radiator head. It holds this windowOpened property in 'true' state for 15 min, then it jumps back to false.

    Yes, it is throwing this event for 100% as i was using it very nicely with fibaroExtra.

    So now i should do some more checks, after i have changed to month restriction to oct-mar.

    My only question is at this moment, is my rule correctly formed? Using the month restriction with an event?

     

    Link to comment
    Share on other sites

  • Topic Author
  • 3 minutes ago, Neo Andersson said:

    okay i realaized that month (oct-may) was incorrect, so i changed to (oct - mar) but it didn help

    first of all, i relaized that i had bad month restriction. Obviously may-oct is not correct. I have changed it to oct-mar, as it should trigger only in winter season.

    On the other hand, windoOpened event is fired by Fibaro when there is a steap temerature drop near to radiator head. It holds this windowOpened property in 'true' state for 15 min, then it jumps back to false.

    Yes, it is throwing this event for 100% as i was using it very nicely with fibaroExtra.

    So now i should do some more checks, after i have changed to month restriction to oct-mar.

    My only question is at this moment, is my rule correctly formed? Using the month restriction with an event?

     

    Yes, that should work.

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