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


SDK for remote and offline HC3 development


jgab

Recommended Posts

  • Topic Author
  • 15 hours ago, mike79 said:

    not sure but when i setVaribles in function onInit()

    all other functions are not reponsive.

    Dont we set Varibles on onInit() ?

     

    Also i get from console

    04.07.2021] [15:02:04] [WARNING] [QUICKAPP64]: Variable PROXYIP not found

     

    Your code looks ok, and it works very well when I test it. The problem must be something else.

    First the missing PROXYIP warning you get in the console. It indicates that the proxy QA installed on the HC3 is broken somehow. Could you remove the QA (it is created again of you have hc3_emulator.proxy=true) and try?

    Secondly, you say that it is unresponsive - what does that mean? Is the emulator unresponsive (the ZBS IDE) or is it the proxy QA on the HC3? Is it when you press buttons on the QA proxy in the HC3?

     

    You can also post me the log in ZBS so I can see how far it runs. When I run your code in ZBS it looks like this

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    The missing PROXYIP only appear in console when setting varibles in onInit function, if i remove them it disapeers again.

    And the none reponsive is that , when you click the buttons and callt he other functions i do not get the print out from those when setvaribles are in onInit either, once removed they are working again.

     

    Please login or register to see this code.

    Please login or register to see this code.

    I working late today, so i wont have time to reinstall QA but tommmow i can reinstall and test again.

    Link to comment
    Share on other sites

  • Topic Author
  • 16 hours ago, mike79 said:

    The missing PROXYIP only appear in console when setting varibles in onInit function, if i remove them it disapeers again.

    And the none reponsive is that , when you click the buttons and callt he other functions i do not get the print out from those when setvaribles are in onInit either, once removed they are working again.

     

    Please login or register to see this code.

    Please login or register to see this code.

    I working late today, so i wont have time to reinstall QA but tommmow i can reinstall and test again.

    I'm wondering if you use the proxy in the right way.

    When you set hc3_emulator.procy=true the emulator will install a "proxy" QA on the HC3 when it starts (it will try to reuse the  the proxy if it already exists).

    The proxy on the HC3 is named "Proxy <Your QA  name>".

    That proxy QA is an "empty shell" that sends all interactions, button pushes, slide bar setting, other QAs call fibaro.call on the QA, it sends all these actions back to the emulator. It knows where the emulator is (Mac or PC) because the PROXYIP quickAppVariable contains the IP address of the emulator.

    You should never ever edit the proxy QA on the HC3.

     

    So when you press a button on the proxy QA on the HC3 and the PROXYIP doesn't exists, nothing happens. That is because the code that logs "Saying hello..." runs in the emulator and is never called.

     

    So, somehow the proxy QA seems to be broken. Try to remove it on the HC3 and re-run your code.

    Do you run the latest version of the emulator?

    Link to comment
    Share on other sites

    • 1 month later...

    Using latest  FIBAROAPIHC3_VERSION = "0.315" on VS code after few hours (2~3) I receive error/notification. Not tested yet on ZB.

      

    Please login or register to see this spoiler.

      

    In some case the code crashes...

     

     

    Edited by cag014
    Link to comment
    Share on other sites

  • Topic Author
  • 22 hours ago, cag014 said:

    Using latest  FIBAROAPIHC3_VERSION = "0.315" on VS code after few hours (2~3) I receive error/notification. Not tested yet on ZB.

      

    Please login or register to see this spoiler.

    It seems to be a socket operation that fails in a non-trappable way inside the socket lib.

    Do you run TCP,UDP,WebSockets? Anything besides standard HTTPClient?

    Link to comment
    Share on other sites

    5 minutes ago, jgab said:

    It seems to be a socket operation that fails in a non-trappable way inside the socket lib.

    Do you run TCP,UDP,WebSockets? Anything besides standard HTTPClient?

    No, httpclient only...

    BTW it looks like the code doesn't crash, but in timeout... after while it continues to run...

    Could you please add a timestamp to the line to see how long it stuck?

    Edited by cag014
    Link to comment
    Share on other sites

    Have tried to run it (0.309 and 0.315) on ZB and it fails on follow error

    Please login or register to see this code.

    Here is the 5934 line

    Please login or register to see this spoiler.

     

     

    while 0.158 works fine...

     

    Edited by cag014
    Link to comment
    Share on other sites

  • Topic Author
  • 4 minutes ago, cag014 said:

    Have tried to run it (0.309 and 0.315) on ZB and it fails on follow error

    Please login or register to see this code.

    Here is the 5934 line

    Please login or register to see this spoiler.

    You need to set Lua compiler to 5.3 (since v300)

    QAs on HC3 run Lua 5.3

    Link to comment
    Share on other sites

    2 minutes ago, jgab said:

    You need to set Lua compiler to 5.3 (since v300)

    QAs on HC3 run Lua 5.3

    Thanks, works fine now.

    Link to comment
    Share on other sites

    15 hours ago, jgab said:

    It seems to be a socket operation that fails in a non-trappable way inside the socket lib.

    Do you run TCP,UDP,WebSockets? Anything besides standard HTTPClient?

    @jgab, sorry it was my bad.

    Recently I have replaced my laptop and forgot to change the sleep mode, so after few hours my PC goes into sleep mode and WiFi disconnects... that the reason for the error and why after while it works again (when I open the PC and WiFi connects)

    Sorry...

     

    Link to comment
    Share on other sites

    @jgab

    My idea is to monitor several HCs using HHTPClient with timeout (600 mSec)

    But when I add to monitor another HC, following info appears on the console

    Please login or register to see this spoiler.

    It happens on HC where no a lot of activity (no answer on refreshstate)  and the HTTP breaks by timeout then that info displayed.

    When refreshstate returns answer no info shown..

    By the way the program does run correctly.

     

    Any option to stop these endless messages?

    I think the TIMEOUT on HTTPClient causes the problem...

     

    Working fine with few HCs using fibaroapiHC3_0158.lua  and HTTPAsyncClient({timeout=600})

     

     

    Edited by cag014
    Link to comment
    Share on other sites

    after while an additional warning displayed

    Number of outstanding http requests 32

     

    Meanwhile have set as a comment follow line

    Please login or register to see this spoiler.

     

    works fine for last several hours....

     

    Edited by cag014
    Link to comment
    Share on other sites

  • Topic Author
  • "Number of outstanding http requests ..." tells you that you are making requests quicker than they complete.

    If it builds up and exceed 30 it's a good chance that it's a trend and it will eventually break 100.

     

    Link to comment
    Share on other sites

    3 hours ago, jgab said:

    "Number of outstanding http requests ..." tells you that you are making requests quicker than they complete.

    If it builds up and exceed 30 it's a good chance that it's a trend and it will eventually break 100.

    I understand that, but I'm curious how same code  works on 0.158 without problems?

    Link to comment
    Share on other sites

  • Topic Author
  • .158 is synchronous http (faked asynchronous callbacks) so I guess the program just slows down.

    >.300 the calls are asynchronous and seems to stack up...

    Link to comment
    Share on other sites

    1 hour ago, jgab said:

    .158 is synchronous http (faked asynchronous callbacks) so I guess the program just slows down.

    >.300 the calls are asynchronous and seems to stack up...

    Same code and HTTP requests run on HC3 (monitoring 3 controllers)  no issues at all.

    Could be that when HTTP request ends by timeout it doesn't closed fast enough?

    Link to comment
    Share on other sites

  • Topic Author
  • Yes, then I don't know - the errors you get are deep inside the copas code and it's really hard to debug.

    I'm moving over my logic (and efforts) to my new TQAE emulator and I will eventually add async calls there to - as an option - but it may take a while.

     

    On the other hand why do you poll every 600ms? 

    The advantage with a http request is that you hang (non-blocking) for the request to return and the /refreshState call will return immediatly when there are events available (or ~30s timeout). 

    Have separate setTimeout loops for your controllers that waits for events and and puts them in a common queue. Then you can have have a separate setTimeout loop that runs often (every 100ms) and checks the queue for new events and render your GUI or whatever...

    That way you don't load the controllers unnecessary and the load on the emulator/PC is low too.

    Link to comment
    Share on other sites

  • Topic Author
  • Something like this

    Please login or register to see this code.

     

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

    Thanks, will try it...

    In any case did some debugging and looks like HTTP ended by timeout still in buffer. All requests in buffer are cleared when HTTP success.

    Means even by polling one controller ever 600 ms the number of HTTP requests in buffer goes up. When controller finally responds, all HTTP requests are cleared and no HTTP requests in buffer.

     

    Link to comment
    Share on other sites

    Have implement your idea using setTimeout and works just great.

    Since now I don't need async HTTP hope to try your new TQAE .

    Thanks

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