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


Run QA function at certain day,time which was set by a user


Recommended Posts

Hey all,

Probably this is a question for some really experts outthere..

I have made a QA, which allows for user to set irrigation schedules..like start time, duration, days..etc..as it is not possible from HC3 panels..

User doesnt have acces from Yubii app to garden panel..

How can I achieve that a time variable, what is set in the QA by user..will then trigger a function in the same QA..

For example..user have set a scheduled watering in my App for Monday 6:00..This info is stored in QAs variables..

The QA has the functions which will start the watering, but i don't know how to start it at the time what has been set by the user..

Ohh..sorry..really confusing i think..but I hope some expert in Fibaro will have some answer, or at least some suggestion how to achieve this..

 

Thanks

 

Link to comment
Share on other sites

15 hours ago, Neo Andersson said:

For example..user have set a scheduled watering in my App for Monday 6:00..This info is stored in QAs variables..

The QA has the functions which will start the watering, but i don't know how to start it at the time what has been set by the user..

 

you need in the loop function of your QA to check for "is the time set user between current and end of the day/schedule" or just "do we already reached start time", so in principle you have to compare each every minute if the stored value is equal to current time, and if so start the QA watering function. You need of course some interface for the user, to be able to change QA variables from BUI/App, and to save new values. If the user is you, or the user "know how to set time properly", yyou don't even need to check if the time set is properly formated 😉

 

Please login or register to see this image.

/monthly_2021_08/image.png.477f2ba41636c4ba06cf4345ec971416.png" />

  • Thanks 1
Link to comment
Share on other sites

  • Topic Author
  • Thanks, this approach i knew..I just wanted to avoid using settimeout..

    If it was possible to create a brnd new scene from inside the QA, and when the user sets the time, it creates a scene with the corresponding time parameter. anyway thanks for the suggestion

     

     

     

     

    Link to comment
    Share on other sites

    1 hour ago, Neo Andersson said:

    Thanks, this approach i knew..I just wanted to avoid using settimeout..

    If it was possible to create a brnd new scene from inside the QA, and when the user sets the time, it creates a scene with the corresponding time parameter. anyway thanks for the suggestion

     

    you don't need settimout, check this presence simulator, it does check time between, based on startTime and endTime values. So all you need is to hack some keypad together to allow user to enter values (as i did in the picure above), save these values in QA variable and to make use of it (with help of the between function from below Quick App) in your QuickApp.

     

     

    • Thanks 1
    Link to comment
    Share on other sites

  • Topic Author
  • 18 hours ago, tinman said:

     

    you don't need settimout, check this presence simulator, it does check time between, based on startTime and endTime values. So all you need is to hack some keypad together to allow user to enter values (as i did in the picure above), save these values in QA variable and to make use of it (with help of the between function from below Quick App) in your QuickApp.

     

     

     

    I think i expressed myself in a wrong way...i am sorry...You always need some kind of looping/polling/checking preocess, if you are checking when a certain time has come...theres no way to avoid it..I think even normal Fibaro block scenes are using it in the background when you select an exact time as a trigger..So my issue is coming from this: There are 3 watering relays, and I need to start one after the other..not together...First i need a function which will be constantly checking the time in a Loop. This is my first headache..Isn't this too high demand on the system, if we have forexample more settimeouts functions running all the day every second?

     

    Then we compare current and the scheduled time wether they matche, and if they do we need to start relays on by one..

     

    So the logic must be like this:

     

     

    function TimeCheckLoop()

     

          If current_time == schedule_time then

            

                  runIrrigation ()

           

           else

                 

                 TimeCheckLoop()

     

          end

     

    end

     

     

    So this is the time checking logic...

     

     

    Then comes the run 1by1 problem.

     

     

    function runIrrigation()

     

    startRelay1()

    fibaro.setTimeout(15000, function()

                      stopRelay1()

                      startRelay2()

                                    fibaro.setTimeout(15000, function()

                                           stopRelay2()

                                           startRelay3()

                                                       fibaro.setTimeout(15000, function()

                                                            stopRelay3()

                                                             

                                                       end)                                                                      

     

     

                                     end)

     

     

    end)

     

    end

     

     

    This embedded style of setTimeout seems to me very nasty, and it doesnt even work...

     

    Is there any fault in my logic, or my logic is okay, only the code is bad?

     

    Thanks

     

     

     

     

     

    Link to comment
    Share on other sites

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

     

     

    I think i expressed myself in a wrong way...i am sorry...You always need some kind of looping/polling/checking preocess, if you are checking when a certain time has come...theres no way to avoid it..I think even normal Fibaro block scenes are using it in the background when you select an exact time as a trigger..So my issue is coming from this: There are 3 watering relays, and I need to start one after the other..not together...First i need a function which will be constantly checking the time in a Loop. This is my first headache..Isn't this too high demand on the system, if we have forexample more settimeouts functions running all the day every second?

     

    Then we compare current and the scheduled time wether they matche, and if they do we need to start relays on by one..

     

    So the logic must be like this:

     

     

    function TimeCheckLoop()

     

          If current_time == schedule_time then

            

                  runIrrigation ()

           

           else

                 

                 TimeCheckLoop()

     

          end

     

    end

     

     

    So this is the time checking logic...

     

     

    Then comes the run 1by1 problem.

     

     

    function runIrrigation()

     

    startRelay1()

    fibaro.setTimeout(15000, function()

                      stopRelay1()

                      startRelay2()

                                    fibaro.setTimeout(15000, function()

                                           stopRelay2()

                                           startRelay3()

                                                       fibaro.setTimeout(15000, function()

                                                            stopRelay3()

                                                             

                                                       end)                                                                      

     

     

                                     end)

     

     

    end)

     

    end

     

     

    This embedded style of setTimeout seems to me very nasty, and it doesnt even work...

     

    Is there any fault in my logic, or my logic is okay, only the code is bad?

     

    Thanks

     

    35 minutes ago, Neo Andersson said:

     

    PI: Sorry...your example is too complex for my level..I don't uderstand how could you anyway continuosly compare two time values without being forced to run a Loop function which reads the current time then compares it...

     

     

     

     

    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.

     Share

    ×
    ×
    • Create New...