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


  • 0

settimeout - cleartimeout


Neo Andersson

Question

Guys anyone can assist me, cause i am probably missing something evident..

 

I am using a simple formula , where this timer start when my Rain sensor detects rain, so it waits 3 sec and then prints the message

Please login or register to see this code.

later in the code i am testing the timer, and if exists i want to clear it

Please login or register to see this code.

However this always throws me this error

[19.01.2023] [03:23:22] [ERROR] [QUICKAPP51]: in Event({"type":"device","id":57,"property":"value"}) => ..: ./include/eventDefinitions.lua:113: Wrong parameter type, number required. Provided param '[Timer:31866 02:31:47 01/19/23]' is type of table

 

So this indicates that rainref is a table when i assign it to seTimeout, on the other hand Cleartimeout functions awaits number...

 

Then i open a completely new QA, just for testint this functionality..i am following the same procedure...and in the other QA the rainref is a number, so the Cleartimeout can work...

 

What the hell is going on???

 

Anyone any clue???

 

This is my simple testing QA, and in this the timer references are always numbers and not tables..

 

Please login or register to see this code.

 

 

 

 

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0

Sorry, you seems to be using fibaroExtra in your code and there was a some code that fell out the last rewrite.

Either download the latest fibaroExtra (0.955) or add this line to your code

Please login or register to see this code.

I never use the fibaro.clearTimeout version, only clearTimeout (why type 7 extra characters?), so I didn't notice that the function was dropped.
 
Edited by jgab
Link to comment
Share on other sites

  • 0

The reason fibaroExtra is rewriting the setTimeout function is that it is more helpful then the standard version:

1. It will give a decent error message if the function provided to setTimeout crashes.

2. It can (optionally) warn if the timer runs late

3. It can specify times longer than 24.8 days....  <

Please login or register to see this link.

>

4. ....and the ref's printed representation contains the timer ID and the time it will expire. That was what you were seeing because the fibaroExtra's ref contains that extra information, but it requires that we use the fibaroExtra's clearTimeout to handle the ref. I had forgot to patch fibaroExtra.clearTimeout so it used the standard version that expects the standard ref.

Edited by jgab
Link to comment
Share on other sites

  • 0
  • Inquirer
  • 4 hours ago, jgab said:

    The reason fibaroExtra is rewriting the setTimeout function is that it is more helpful then the standard version:

    1. It will give a decent error message if the function provided to setTimeout crashes.

    2. It can (optionally) warn if the timer runs late

    3. It can specify times longer than 24.8 days....  <

    Please login or register to see this link.

    >

    4. ....and the ref's printed representation contains the timer ID and the time it will expire. That was what you were seeing because the fibaroExtra's ref contains that extra information, but it requires that we use the fibaroExtra's clearTimeout to handle the ref. I had forgot to patch fibaroExtra.clearTimeout so it used the standard version that expects the standard ref.

    Thanks Jan, so when I use fibaroextra, it is better to use simpy clearTimeout(ref) formula instead of fibaro.clerTimeout(ref) right?...and the same goes to setTimeout()...?

    Link to comment
    Share on other sites

    • 0
    57 minutes ago, Neo Andersson said:

    Thanks Jan, so when I use fibaroextra, it is better to use simpy clearTimeout(ref) formula instead of fibaro.clerTimeout(ref) right?...and the same goes to setTimeout()...?

    With the patch or the latest fibaroExtra it doesn't matter. Use what you remember ;-) 

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • On 1/20/2023 at 11:31 AM, jgab said:

    With the patch or the latest fibaroExtra it doesn't matter. Use what you remember ;-) 

    Jan, did you mean (0.945) for the lates update? Becuase you wrote 0.955 as for the lates version, and i cant find that file..

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 8 minutes ago, Neo Andersson said:

    Jan, did you mean (0.945) for the lates update? Becuase you wrote 0.955 as for the lates version, and i cant find that file..

    Jan, I have found the latest 0.955 version, and i changed every fibaro.clearTimeout and fibaro.setTimetout to simple clearTimeout and setTimeout, however now i am getting this error

     fibaroExtra.lua:139: attempt to perform arithmetic on a function value (local 'ms')

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 4 minutes ago, Neo Andersson said:

    Jan, I have found the latest 0.955 version, and i changed every fibaro.clearTimeout and fibaro.setTimetout to simple clearTimeout and setTimeout, however now i am getting this error

     fibaroExtra.lua:139: attempt to perform arithmetic on a function value (local 'ms')

    Okay, now i see, it is not compatible with Fibaro regular settimeout function i think...the argument order is different...

    Link to comment
    Share on other sites

    • 0
    33 minutes ago, Neo Andersson said:

    Okay, now i see, it is not compatible with Fibaro regular settimeout function i think...the argument order is different...

    Well, for 10 years fibaro had only setTimeout(fun, ms) and then they added fibaro.setTimeout(ms, fun) and changed the order and the reason is unknown....

    Both are there in QA's and fibaroExtra supports both.  Choose one. I prefer just setTimeout...

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 3 minutes ago, jgab said:

    Well, for 10 years fibaro had only setTimeout(fun, ms) and then they added fibaro.setTimeout(ms, fun) and changed the order and the reason is unknown....

    Both are there in QA's and fibaroExtra supports both.  Choose one. I prefer just setTimeout...

    Actually the old order is not supported, as I wrote you above

    Just now, Neo Andersson said:

    Actually the old order is not supported, as I wrote you above

    I mean setTimeout(ms,fun) doesnt work as you can see

    Link to comment
    Share on other sites

    • 0
    15 hours ago, Neo Andersson said:

    Actually the old order is not supported, as I wrote you above

    I mean setTimeout(ms,fun) doesnt work as you can see

    I tried to explain it in my post...

    Fibaro have both

    Please login or register to see this code.

    defined. They chose to switch the order of the arguments in the later fibaro.setTimeout introduced - we don't know why.

    fibaroExtra modifies setTimeout(fun, ms) but the modification of the original fibaro.setTimeout(ms, fun) had dropped.

    Now they are both in fibaroExtra and you can chose whichever version you want. but of course you need to provide the arguments in the correct orders...

    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
    Answer this question...

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