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
  • 1 hour ago, jgab said:

    This is cool.

    In ZBS user or system preferences, set:

    Please login or register to see this code.

    Then run something like

    Please login or register to see this code.

    It will download QuickApp with deviceId 47, unpack it in directory /fqas and stop the debugger when it enter the QA's :onInit and open the file in a new ZBS buffer....  and then it's just to step through and debug...

    ...and breakOnLoad=true makes the debugger stop on the first line of files loaded and open them in a ZBS buffer. 

    Link to comment
    Share on other sites

    @jgab

    After testing of new fibaroapiHC3C it's still better to use and simple for debug older fibaroapiHC3.

    I usually use this syntax - it works for me :) 

     

    if dofile then
      if not hc3_emulator then
        hc3_emulator={id=xxx,quickApp=true,poll=1500}
        dofile("fibaroapiHC3.lua")
      end
    end

     

     

    Edited by petrkl12
    Link to comment
    Share on other sites

  • Topic Author
  • 3 minutes ago, petrkl12 said:

    @jgab

    After testing of new fibaroapiHC3C it's still better to use and simple for debug older fibaroapiHC3.

    I usually use this syntax - it works for me :) 

     

    if dofile then
      if not hc3_emulator then
        hc3_emulator={id=xxx,quickApp=true,poll=1500}
        dofile("fibaroapiHC3.lua")
      end
    end

    Ok, unfortunately it will not be updated to keep up with fw releases.

    Link to comment
    Share on other sites

    Understand.

    For example now I can't change/install any QAs in my HC3 (thanks to Fibaro that all QAs are twice in memory).

    With old setup I can do some development - in new one it doesn't work  ...

     

    Edited by petrkl12
    Link to comment
    Share on other sites

  • Topic Author
  • 1 minute ago, petrkl12 said:

    Understand.

    For example now I can't change/install any QAs in my HC3 (thanks to Fiabro that all QAs are twice in memory).

    With old setup I can do some development - in new one it doesn't work  ...

    Yes, that is unfortunate - but connecting to existing QA was always a bit strange and your use-case seems to be easiest to solve by just copying over the properties from the real QA when you start up the emulated QA?

    I'm spending a lot of effort to make the emulator more compliant, both for QAs and Scenes, and it's impossible to keep up with two diverging sources. However, I do value feedback from users and I'm willing to spend time implementing features requested. I know the new emulator with 50% rewritten code will have issues and it will take a couple of rounds before it is on par with the old. The potential for the future is much bigger though.

    However, for your problem with viewLayout I suggested copying the properties from the real QA at startup instead of spending a lot of code for something that is an exception to how people normally use the emulator.

    What else doesn't work that we can fix?

     

    Link to comment
    Share on other sites

  • Topic Author
  • 2 minutes ago, jgab said:

    Yes, that is unfortunate - but connecting to existing QA was always a bit strange and your use-case seems to be easiest to solve by just copying over the properties from the real QA when you start up the emulated QA?

    I'm spending a lot of effort to make the emulator more compliant, both for QAs and Scenes, and it's impossible to keep up with two diverging sources. However, I do value feedback from users and I'm willing to spend time implementing features requested. I know the new emulator with 50% rewritten code will have issues and it will take a couple of rounds before it is on par with the old. The potential for the future is much bigger though.

    However, for your problem with viewLayout I suggested copying the properties from the real QA at startup instead of spending a lot of code for something that is an exception to how people normally use the emulator.

    What else doesn't work that we can fix?

     

     

    So I tried to run your Hue QA (fqa version) and it throws an error "[string "HueTools"]:25: attempt to perform arithmetic on a nil value "

    If you PM me an unobfuscated version of you fqa I will debug it and make sure the emulator can run it. (now it's really difficult and ZBS even freeze when I try to open some file ?)

    Link to comment
    Share on other sites

    I can't create new QA for you because my HC3 is dead for any QA changes :(

    I will send you all source codes and you will have to replace them in QA

    Link to comment
    Share on other sites

  • Topic Author
  • 1 minute ago, petrkl12 said:

    I can't create new QA for you because my HC3 is dead for any QA changes :(

    I will send you all source codes and you will have to replace them in QA

    Thanks!

    Link to comment
    Share on other sites

  • Topic Author
  • So, 5 days of intensive debugging after @petrkl12 sent me his QA :-)

    However, fibaroapiHC3C.lua is in better shape. Thanks.

    @petrkl12 I can get the Hue QA to run now. All the wrinkles is not ironed out but it runs.

    If you set 

    Please login or register to see this code.

    It will load the viewLayout and quickVars from QuickApp ID 523 at startup.

    If you provide your own quickVars 

    Please login or register to see this code.

    it (foo in this case) will override or be added to the variables from the resource declaration

    If you provide 

    Please login or register to see this code.

    it will override the viewLayout from the resource.

     

    I can run the Hue QA with hc3_emulator.proxy = true

    If not it is possible to open http://127.0.0.1:6872/web/ to get a simulated web GUI of the QA (only when the emulator runs)

     

    • Like 1
    • Thanks 1
    Link to comment
    Share on other sites

    @jgab

    QA Hue works - basic run OK

     

    What is not working:

    - Buttons: Restart and Start

    - web gui - I'm not sure what should be visible here ...

     

    Please login or register to see this attachment.

     

     

    My setup:

     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    Hi @jgab

     

    I got a new device (

    Please login or register to see this link.

     

    Adding this rule

    Please login or register to see this code.

     

    fails with 

    any idea ?

     

    Please login or register to see this code.

    Please login or register to see this image.

    /monthly_2021_03/image.png.cc411816c56697126fe82790a3fdc95b.png" />

     

    Link to comment
    Share on other sites

  • Topic Author
  • 15 hours ago, petrkl12 said:

    @jgab

    QA Hue works - basic run OK

     

    What is not working:

    - Buttons: Restart and Start

    - web gui - I'm not sure what should be visible here ...

     

    Please login or register to see this attachment.

     

     

    My setup:

     

    Please login or register to see this code.

     

    Ooops, a bug I introduced before pushing the file. Fixed in .172

    I wonder if you have a bug in Menu.lua.

    You do

    Please login or register to see this code.

    but the file content (fc) is not json.encoded, so my emulator throws an json.exception.

    Another tip.

    make your setTimeout and json patches conditionally in Tools.lua because the setTimeout and json part of the emulator gives better error messages (easier to pinpoint problem)

    Something like

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • 16 minutes ago, ChristianSogaard said:

    Hi @jgab

     

    I got a new device (

    Please login or register to see this link.

     

    Adding this rule

    Please login or register to see this code.

     

    fails with 

    any idea ?

     

    Please login or register to see this code.

     

     

    I think this is an EventRunner issue and should be in that thread instead of the SDK forum.

    However, your rule has no visible problem. The rule parsers (tokeniser) complains because it can't identify the "words" in the rule. Because there seems to be no problem the best guess is that some "invisible" characters have managed to get into the text which trips up the parser.

    Rewrite the rule from scratch (don't copy&paste the old).

    • Like 1
    Link to comment
    Share on other sites

  • Topic Author
  • 16 hours ago, petrkl12 said:

    @jgab

    QA Hue works - basic run OK

     

    What is not working:

    - Buttons: Restart and Start

     

    plugin.restart() is not implemented yet but I'm working on it.

    Link to comment
    Share on other sites

    1 hour ago, jgab said:

    Ooops, a bug I introduced before pushing the file. Fixed in .172

    I wonder if you have a bug in Menu.lua.

    You do

    Please login or register to see this code.

    but the file content (fc) is not json.encoded, so my emulator throws an json.exception.

     

    It should be OK :) - content is of course not encoded but I have inside of HueMain all sources for other .fqa's and these are json encoded (technically there is one big comment and inside this comment there is encoded source code of fqa). You can see in my HueMain.fqa

    Please login or register to see this attachment.

     

     

    16 minutes ago, jgab said:

     

    plugin.restart() is not implemented yet but I'm working on it.

    Thanks

    Edited by petrkl12
    Link to comment
    Share on other sites

    1 hour ago, jgab said:

     

    I think this is an EventRunner issue and should be in that thread instead of the SDK forum.

    However, your rule has no visible problem. The rule parsers (tokeniser) complains because it can't identify the "words" in the rule. Because there seems to be no problem the best guess is that some "invisible" characters have managed to get into the text which trips up the parser.

    Rewrite the rule from scratch (don't copy&paste the old).

    confirmed that worked - thank you

    Link to comment
    Share on other sites

  • Topic Author
  • v 0.174 has a couple of interesting features.

    hc3.timersWarn=true will log a message if a setTimeout timer is scheduled and fire late (and how late it is fired).
    Because we have a cooperative scheduler (also on the HC3), timers may be fired late due to other stuff going on.
    If it happens now and then it's usually not a problem, but if it is recurring it can be good to understand why and redesign the code not to block for too long intervals.

     

    hc3.timersExtra=true will annotate the timer with the source code line from where it was scheduled (setTimeout)
    This way we now not only if the timer was late but where in the code the late timer was scheduled.
    Also when your function crashes due some error in your code you 

     

    This code

    Please login or register to see this code.

    It starts a timer in 2s, but then do a sleep for 4s that will delay the timer.

    The last timer crashes because it calls an undefined function A()

    Debug output.

     

    Please login or register to see this code.

     

    First we can print out timers. We will get identity, when it should expire, and the file and line it was scheduled from.

    We get a warning that the first timer is ~2s late when it finally runs.

    We get an error message when our last timer crashes. We get the line the timer was defined on and the line of the offending code.

    If we run in ZBS, late timers will be logged in red color, and ok timers in green

    11 minutes ago, ChristianSogaard said:

    confirmed that worked - thank you

    I will add a check for strange characters in the code...

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

  • Topic Author
  • 4 minutes ago, jgab said:

    v 0.174 has a couple of interesting features.

    hc3.timersWarn=true will log a message if a setTimeout timer is scheduled and fire late (and how late it is fired).
    Because we have a cooperative scheduler (also on the HC3), timers may be fired late due to other stuff going on.
    If it happens now and then it's usually not a problem, but if it is recurring it can be good to understand why and redesign the code not to block for too long intervals.

     

    hc3.timersExtra=true will annotate the timer with the source code line from where it was scheduled (setTimeout)
    This way we now not only if the timer was late but where in the code the late timer was scheduled.
    Also when your function crashes due some error in your code you 

     

    This code

    Please login or register to see this code.

    It starts a timer in 2s, but then do a sleep for 4s that will delay the timer.

    The last timer crashes because it calls an undefined function A()

    Debug output.

     

    Please login or register to see this code.

     

    First we can print out timers. The printed representation of the timer contains useful information.

    We will get address of the function, when it should expire, and the file and line it was scheduled from (where setTimeout was called from).

    We get a warning that the first timer is ~2s late when it finally runs.

    We get an error message when our last timer crashes. We get the line the timer was defined on and the line of the offending code.

    If we run in ZBS, late timers will be logged in red color, and ok timers in green

    I will add a check for strange characters in the 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...