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
  • The way to activate a rule at 07:00 or sunrise if sunrise comes before 07:00

    rule("@min(sunrise,07:00) => log('Wake up')")

     

    To activate a rule at sunset or 22:00 is similar

    rule("@min(sunset,22:00) => log('Go to bed')")

     

    Sometimes you use max(...) if you want to select the later time.

    • Like 1
    Link to comment
    Share on other sites

    Hi @jgab

     

    What's the best way to post or start a rule every full hour during the day. With the truefor loop you can set something to start every 60 min but not exactly at a specific time.

    I thought something like this but unfortunately it doesn't work.
     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    Every hour between 07:00-23:00

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    Hi @Sjakie

     

    Thank for your response!

     

    I tried this with a 10 sec interval but I think it's a bit the same as with @truefor. It starts the interval from the moment the rule is activated. I would like it to start exactly at 10:00, 11:00 etc. Instead of 10:20, 11:20 etc. 
     

    Please login or register to see this code.

     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    Hi If you test a rule you must give the rule the possibility to start!

    If yo chofes 10 second the rule should not activate after save but 10 seconds later

    you will notice it work.

    save this rule before 20:30 

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    Ah that will be it. I'll test it when I get back home.  

    Thanks!

    Link to comment
    Share on other sites

  • Topic Author
  • It's correct that the time loops (@@) starts immediately so @@01:00 will run every hour but the exact when in the hour depends in when it started.

    The good news is that @@ is drift free, so it will run exactly every 3600 seconds in this case.

     

    If you want it to run exactly on the hour you can do

    Please login or register to see this code.

     

    or factor out the action

    Please login or register to see this code.

    (I just realised that there is no good way to do integer division in ER4 - will probably introduce the // operator in next version)

     

    If you are not so picky about the exact second, but want it to run in the first minute of the hour you can use the date() function that is a bit like unix cron - and the cron in HC3 scenes

     

    Please login or register to see this code.

    Here we set _debugFlags.rule=false, or you will get a log every minute when trying the rule - a bit annoying..

    Edited by jgab
    Link to comment
    Share on other sites

  • Topic Author
  • Another way is to list the hours explicitly in the @ command.

    Ex-

    rule("@{00:00,01:00,02:00,03:00,...} => ...")

    Unfortunately, it's a bit tedious to list 24 times - and we are not allowed to use ...

     

    What we can do is generate the list to @

    Please login or register to see this code.

    A time constant is translated to number of seconds since midnight, 01:00 becomes 3600, 02:10 becomes 2*3600+60*10 (that is also why we can easily do math with time constants in ER)

    So, our HOUR list needs to contain {0, 3600, 7200, ... }

    Link to comment
    Share on other sites

    Jan, can we do this also with a Global Variable?

    Please login or register to see this code.

    or is it

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • We could also do this to generate a on the minute and on the hour event

    Please login or register to see this code.

     

    5 minutes ago, Sjakie said:

    Jan, can we do this also with a Global Variable?

    Please login or register to see this code.

    or is it

    Please login or register to see this code.

     

    I don't think I understand.

    First line you post an event (in 11 minutes)

    Second line you trigger on that event and set a global to 'Yes'.

     

    So, what do you want to do 'also with a Global Variable' ?

    Edited by jgab
    Link to comment
    Share on other sites

    Jan I need 30 minutes after $Lichttoestaan == 'Yes' another GV $Lichttoestaan = 'Nee'

    I want to do it without post

    a kind off $Lichttoestaan == 'Yes',+/00:11

    Edited by Sjakie
    Link to comment
    Share on other sites

  • Topic Author
  • 9 minutes ago, Sjakie said:

    Jan I need 30 minutes after $Lichttoestaan == 'Yes' another GV $Lichttoestaan = 'Nee'

    I want to do it without post

    You could do

    Please login or register to see this code.

    That would always set it back to 'Nee' after 30min.

    But you need to be careful as it will always wait 30min and set the var to 'Nee', even if you toggle the var before (set it to 'Yes' and 'Nee')

    Link to comment
    Share on other sites

     

    Hi @jgab, @Sjakie

     

    Thanks both for your solutions!

    The last solution is the clearest read to for me and quite flexible to schedule at other exact times as well.

     

    Please login or register to see this code.

     

    I find the method with the post difficult to read and do not yet understand well enough how to apply it. Still have a lot to learn.

     

    Please login or register to see this code.

     

     

    Link to comment
    Share on other sites

    Hi @jgab

     

    I am still struggling to apply it so that it is executed for a particular section. I am trying this but this is not working. 

     

    Under the fibaro.EM.SECTION = nil:   

    Please login or register to see this code.

     

    In the section:

     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • The minute event you setup so that it's always posting events on the minute. 

    Then you enable/disable the other rules that trigger on that event

     

    Please login or register to see this code.

     

    Edited by jgab
    Link to comment
    Share on other sites

    Jan what's better to use in ER

     

    Rule.eval([[$Test='A' | $Test='B' | $Test='C' | $Test='D' =>

    or

    Rule.eval([[!$Test='E' =>

     

     
    Link to comment
    Share on other sites

  • Topic Author
  • It should be == if you want to test for equality. = is assignment.

    Rule.eval([[$Test=='A' | $Test=='B' | $Test=='C' | $Test=='D' =>

     

    You mean that the alternative would be

    Rule.eval([[!$Test=='A' => ..

    Rule.eval([[!$Test=='B' =>

    Rule.eval([[!$Test=='C' =>

    :

     

    ?

    The first is a bit faster as the it only needs to trigger one rule.

     

    Link to comment
    Share on other sites

    Jan, yep sorry was in a hurry.

    Getting error

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • ! has higher priority than == so you need parenthesis around it

    Please login or register to see this code.

    or you use ~=

     

    Please login or register to see this code.

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