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


fibaroExtra


jgab

Recommended Posts

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

    This will check of the activeProfile==1 every morning at 07:00 and if so turnOn the device 576

     

    In a simple case like this it turns out that one can post a lua function instead of an event - this means that we don't need the event handler

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • So, fibaroExtra have had code for a cron function. Just added it to v0.943

    The example can then be written as

    Please login or register to see this code.

     

    The cron string has syntax

    Please login or register to see this code.

    There is a small bug currently that if you want to match all years leave that last parameter out - don't use '*' fixed

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

  • Topic Author
  • I updated fibaroExtr to 0.945 to fix a bug with cron. I also improved cron so all scheduled cron jobs share the same timer loop.

    This makes it very efficient to schedule several jobs in the same QA.

    Ex.

    Please login or register to see this code.

    Link to comment
    Share on other sites

    Hi  jgab

     Thank you for everything, the implementation of the cron2 function and much more. So far I can't do much with the quick app I'm better at writing scripts.
    Thanks for the help and patience. ["01:36 * * * *"even that fits it works.

     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • 01:36 is the same as 01-36, dvs all minutes between 00:01 and 00:36.

     

    I would not use fibaro._postSourceTrigger that is for internal use only. Use fibaro.post(ev[,time])

     

    A tip, have you tried the

    Please login or register to see this link.

    to develop the QA?

    It saves me a ton of time when developing and is the way I test peoples code when I help out in the forum.

     

    It's compatible with fibaroExtra and everything else you need to do when developing a QA.

    I test your code like this

    Please login or register to see this code.

     

    I set offline and speed and get an output like this
     

    Please login or register to see this spoiler.

     

    Oh, btw. use fibaro.cron. fibaro.cron2 will be deprecated soon.

    Edited by jgab
    Link to comment
    Share on other sites

    Hi

    I did not manage TQAE emulator. 

     

    Where can I look up this time format example "sunrise -10" and other. I would like that this time format like this "20:15" is supported, it is easier to read.

    01:36 is the same as 01-36, dvs all minutes between 00:01 and 00:36. probably that's why my mistake???

    Please login or register to see this code.

     

      ["01:03 * * * * "] =             "ActiveProfile",    
      ["01:04 * * * * "] =             "Home",       
     
    Debug:
    [03.07.2022] [01:03:00] [DEBUG] [QUICKAPP592]: Test {"type":"cron","datum":"01:03","timer":"ActiveProfile"}
    [03.07.2022] [01:03:00] [DEBUG] [QUICKAPP592]: Test {"type":"cron","datum":"01:03","timer":"Home"}
    [03.07.2022] [01:04:00] [DEBUG] [QUICKAPP592]: [Timer:13 01:04:00 07/03/22]
    [03.07.2022] [01:04:00] [DEBUG] [QUICKAPP592]: Test {"type":"cron","datum":"01:04","timer":"Home"}
     

    If I enter these two timers in my schedule like this, I get both triggered in the debug when the first one is triggered and then only the last one when the timer is triggered.

     

     

     

     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • In cron format (

    Please login or register to see this link.


    20:15 (15 min past 20) is expressed as

    "15 20 * * *"

     

    sunrise -10

    is my own extension. The idea is that we use the first field, the minute field) for sunrise or sunrise (that includes the hour) and then we use the hour field for an offset to the sun time.

    Link to comment
    Share on other sites

    OK. I solved this for myself. Just swapped the h with m. 

    I have one more question 

    What happens internally with the set cron can you delete them or is deleted with the init or restart the new set when changing in the shy the old ones? 

    Thank you 

     

    Quote

    schedules = {
      ["sunrise -10 * * * *"] =       "sunrise",        -- 10min before sunrise every sunday in the last week of the month ["sunrise -10 lastw-last * 1 *"]
      ["sunset +10 * * * *"] =        "sunset",         -- 10min before sunset every sunday in the last week of the month ["sunset -10 lastw-last * 1 *"]
      ["45 20 * * * *"] =             "ActiveProfile",     -- every 10min starting at 0 on Mondays and Wednesdays ["0/10 * * * 2,4 *"]
      ["01:15 * * * *"] =             "Home",              -- every 10min starting at 5min on Mondays and Wednesdays ["5/10 * * * 2,4 *"]
    }

    for scheduleTime,scheduleTimerName in pairs(schedules) do
     
        if scheduleTime:match("[:]") == ":" then
          local h,m = scheduleTime:match("([0-9][0-9]):([0-9][0-9])");
          x = scheduleTime:gsub( "(:[0-9][0-9])", ":".. h);
          scheduleTime = x:gsub( "([0-9][0-9]:)", m.. " ")
        end
       
        print(scheduleTime)

    end

     

    Edited by parip69
    Link to comment
    Share on other sites

  • Topic Author
  • Everything is cleared when the QA starts/restarts, but your init or other code will just register the cron "jobs" again...

    While the QA is running, you can delete an existing cron job with fibaro.removeCronJob(str) where the str is the same used for registering the job.

    Please login or register to see this code.

     

     

    Link to comment
    Share on other sites

    • 3 weeks later...

    Hi. Unfortunately, it doesn't work with multiple variables??? With device, yes. 

     

    Quote

    fibaro.event({type='device',id={509,44,146,143,139}}, function(env) 
        print(env.id) 
      end)
    fibaro.event({type='global-variable'},name={"var_1","var_2"}, function(env)
        print(env.event.name)
      end)

    Thank you

    Link to comment
    Share on other sites

  • Topic Author
  • 5 hours ago, parip69 said:

    Hi. Unfortunately, it doesn't work with multiple variables??? With device, yes. 

     

    Thank you

     

    It should have been

    Please login or register to see this code.

     

    But no, it doesn't. I could add it but it requires special code, and there are so many types of events that one could add support for... Allowing multiple device IDs was a special hack to be backwards compatible with some code I wrote years ago (EventRunner).

     

    However, fibaro.event always allow for a list of event patterns.

    Please login or register to see this code.

    or you could trigger on all globals and then check the name

    Please login or register to see this code.

    or if the variables have a commonality in naming (like starting with "var_")

    Please login or register to see this code.

    '<>' is the match operator that will take the name, and do name:match("_name") and if it returns true it's a match. 

    The most efficient rule is the first as it will find the right handler with a single hash lookup of the globals variables name. The two after needs a second test after the right handler is found.

    However, in practice the time difference is of little importance (milliseconds) so the taste should decide.

    Edited by jgab
    Link to comment
    Share on other sites

    • 2 weeks later...

    Hallo 

    Bei jedem Drücken einer der Tasten erscheint diese Meldung, "[object Object],[object Object]" siehe Foto.

    Danke im Voraus.

    Please login or register to see this attachment.

    Edited by parip69
    Link to comment
    Share on other sites

  • Topic Author
  • Eh, you need to post in English - my German is really bad....
    I'm not sure what your problem is but it seems like you try to set the label to something that is not a string.
    If you use QuickApp:setView(<element>,<field>,<value>) it will automatically make a string out of <value>. If that is a class object it may look like in your example....
    Do you have some code to share where you update the labels?

    Link to comment
    Share on other sites

    Hi

    Each time you press one of the buttons, this message appears, "[object Object],[object Object]" see photo.

    Thanks in advance.

     

    "updateView" quick app fibaro does not update?????????

     

    Please login or register to see this code.

     

    Please login or register to see this code.

     

    Edited by parip69
    Link to comment
    Share on other sites

    • 2 weeks later...
  • Topic Author
  • On 7/29/2022 at 5:13 PM, parip69 said:

    Hi

    Each time you press one of the buttons, this message appears, "[object Object],[object Object]" see photo.

    Thanks in advance.

     

    "updateView" quick app fibaro does not update?????????

     

    Please login or register to see this code.

     

    There is a bug in the Web UI for HC3 that doesn't always update the labels etc when they change - we have to wait for an update.

     

    Your problem I can't see what it depends on - never seen it before.

    If you change your self:setView to the "standard" self:updateView, does it work then?

     

    Link to comment
    Share on other sites

    • 3 months later...

    @jgab

    Trying to rid of onAction and UIEvent printing by using 

    Please login or register to see this spoiler.

     

    Indeed, onAction does not printed anymore, but UIEvent continue to be shown on debug console!?

    Might be it doesn't go through print function?

    Link to comment
    Share on other sites

  • Topic Author
  • 5 hours ago, cag014 said:

    @jgab

    Trying to rid of onAction and UIEvent printing by using 

    Please login or register to see this spoiler.

    Yep, they seem to have been doing it "right" and moved it to trace. Will update soon with fix. (would be nice if they did their "system" logging consequently...)

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

  • Topic Author
  • On 12/19/2022 at 7:17 AM, jgab said:

    Yep, they seem to have been doing it "right" and moved it to trace. Will update soon with fix. (would be nice if they did their "system" logging consequently...)

    Ok, fixed onUIEvent in latest fibaroExtra (v0.954)

    • Like 1
    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...