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

@jgab

here is error in fibaroapiHC3C:

Please login or register to see this code.

 

My setup:

 

Please login or register to see this code.

 

Link to comment
Share on other sites

  • Topic Author
  • 14 minutes ago, petrkl12 said:

    @jgab

    here is error in fibaroapiHC3C:

    Please login or register to see this code.

     

    My setup:

     

    Please login or register to see this code.

     

    You need to move the hc3_emulator.FILE("QA_Hue_F_Tools.lua","HueTools") outside the header.

    Please login or register to see this code.

    The reason is that I load the code with hc3_emulator not defined (once) - and then hc3_emulator.FILE is of course not defined.

    I will come up with a better syntax to list files to be included and that can be used in the header.

    Link to comment
    Share on other sites

  • Topic Author
  • 29 minutes ago, jgab said:

    I will come up with a better syntax to list files to be included and that can be used in the header.

    Ok, now you can write

    Please login or register to see this code.

    --FILE:<file name>,<module name>;

     

    The old model, hc3_emulator.FILE(<file name>,<module name>) is still supported but will be phased out...

    Edited by jgab
    Link to comment
    Share on other sites

    40 minutes ago, jgab said:

    Ok, now you can write

    Please login or register to see this code.

    --FILE:<file name>,<module name>;

     

    The old model, hc3_emulator.FILE(<file name>,<module name>) is still supported but will be phased out...

    @jgabsame error for your syntax above

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • 3 hours ago, petrkl12 said:

    @jgabsame error for your syntax above

    Ok, new version uploaded.

    I'm a bit picky when it comes to how the header should be formatted because I need to grab it with a pattern.

    It should look like

    if dofile ....

    :

    end

    So the 'if dofile' should start the line and end at the first 'end' that starts a line.

    I give a better error message now if I can't match the header....

     

    (I loaded in 100 copies of the ER4 QA and they run really smooth - in parallell :-) )

    for i=1,100 do

      hc3_emulator.loadQA('EventRunner4.lua"):install()

    end

    Link to comment
    Share on other sites

    @jgab a bit progress :)

    but some errors:

    1. it looks there is not item viewLayout after calling local data=api.get('/devices/'..tostring(thisDeviceID))

    Please login or register to see this code.

    2. this also doesn't work

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • 1 minute ago, petrkl12 said:

    @jgab a bit progress :)

    but some errors:

    1. it looks there is not item viewLayout after calling local data=api.get('/devices/'..tostring(thisDeviceID))

    2. this also doesn't work

    Please login or register to see this code.

     

    It's a bit of a hack but it's still possible to do it.

    The match is different. To make it compatible between the emulator and HC3 the patterns needs to look like ':(%d+)' and ":(%d+):(.*)"

    Please login or register to see this code.

    However, I believe that the HC3 have become a bit better so if you throw an error within the patched setTimeout you get a reasonable line number...

    Link to comment
    Share on other sites

    19 minutes ago, jgab said:

    It's a bit of a hack but it's still possible to do it.

    The match is different. To make it compatible between the emulator and HC3 the patterns needs to look like ':(%d+)' and ":(%d+):(.*)"

    Please login or register to see this code.

    However, I believe that the HC3 have become a bit better so if you throw an error within the patched setTimeout you get a reasonable line number...

    thanks, line is not correct but it's not a problem

    [ERROR] Error in fibaro.setTimeout (line:-32): attempt to index a nil value (field 'viewLayout')

     

    in res there is "[string \"QA_Hue_F_Menu.lua\"]:86: attempt to index a nil value (field 'viewLayout')"

     

    but bigger problem is this:

    1. it looks there is not item viewLayout after calling local data=api.get('/devices/'..tostring(thisDeviceID))

     

    Edited by petrkl12
    Link to comment
    Share on other sites

  • Topic Author
  • 5 minutes ago, petrkl12 said:

    thanks, line is not correct but it's not a problem

    [ERROR] Error in fibaro.setTimeout (line:-32): attempt to index a nil value (field 'viewLayout')

     

    in res there is "[string \"QA_Hue_F_Menu.lua\"]:86: attempt to index a nil value (field 'viewLayout')"

     

    but bigger problem is this:

    1. it looks there is not item viewLayout after calling local data=api.get('/devices/'..tostring(thisDeviceID))

     

    Uploaded  a new version that creates a .viewLayout from the provided UI. It should work now.

    Link to comment
    Share on other sites

  • Topic Author
  • 12 minutes ago, petrkl12 said:

    thanks, line is not correct but it's not a problem

    [ERROR] Error in fibaro.setTimeout (line:-32): attempt to index a nil value (field 'viewLayout')

    Yes, but the patch of setTimeout to report the line number is not needed anymore as both the emulator and the HC3 report the right line number these days.

    Please login or register to see this code.

    The above code works both in the emulator and the HC3 but the cline fetched is always the right so line is always 0

    Link to comment
    Share on other sites

    39 minutes ago, jgab said:

    Yes, but the patch of setTimeout to report the line number is not needed anymore as both the emulator and the HC3 report the right line number these days.

    Please login or register to see this code.

    The above code works both in the emulator and the HC3 but the cline fetched is always the right so line is always 0

    thanks, corrected

    54 minutes ago, jgab said:

    Uploaded  a new version that creates a .viewLayout from the provided UI. It should work now.

    it's created but this is empty:

    data.properties.viewLayout["$jason"].body.sections.items

    and it shoudn't

     

     

    Link to comment
    Share on other sites

  • Topic Author
  • 11 hours ago, petrkl12 said:

    thanks, corrected

    it's created but this is empty:

    data.properties.viewLayout["$jason"].body.sections.items

    and it shoudn't

     

    If you have a QA emulator file (with a header), you need to define the UI in the header too.

    It will not fetch the viewLayout from a QA running in the HC3.

    If it's an existing QA, like your Hue QA I would recommend to convert the viewLayout to an UI struct and include it in the file.

    I uploaded a new version where you can do

    Please login or register to see this code.

    ...and paste it into the header as the UI element.

    (the format is not as compact as it could be...)

     

    An  alternative:

    What you can do is to save the QA on the HC3 as a "unpacked file"

    If you QA on the HC3 has the deviceID 77 and name "MyQA"  run this

    hc3_emulator.loadQA(77):save("unpacked","faqs/")

    It will create a couple of files

    faqs/QA_77_MyQA.json

    faqs/QA_77_MyQA_main.lua

    : -- other module as files

     

    Then make a file and run

    Please login or register to see this code.

    It will load and install the "unpacked" files.

    You can then open faqs/QA_77_MyQA_main.lua etc and set breakpoints and step through them

     

    I will come back with more information on what file formats are supported.

    Link to comment
    Share on other sites

    18 minutes ago, jgab said:

     

    If you have a QA emulator file (with a header), you need to define the UI in the header too.

     

    OK

    but if I want to use device from HC3 without define header how to do it?

    That a reson why I have in definition QA id (523) -  hc3_emulator={id=523,quickApp=true,poll=1500}

    Link to comment
    Share on other sites

  • Topic Author
  • 50 minutes ago, petrkl12 said:

    OK

    but if I want to use device from HC3 without define header how to do it?

    That a reson why I have in definition QA id (523) -  hc3_emulator={id=523,quickApp=true,poll=1500}

    So 523 is a proxy on the HC3 where you edit the UI? and as long as you connect to an existing proxy (523) you want the viewLayout from the proxy instead of the UI in the emulator file?

    If the proxy is deleted you loose the GUI?

    If so, let me think about how to do that...

     

     

    Edited by jgab
    Link to comment
    Share on other sites

    My case is about that I want to use everything from HC3 - it means everything from QA id 523 (existing QA in HC3) and also other APIs like list of all other devices, reading variables etc.

    Same function as you have in "old" fibaroapiHC3 :)

    Thanks

    Link to comment
    Share on other sites

  • Topic Author
  • 9 minutes ago, petrkl12 said:

    My case is about that I want to use everything from HC3 - it means everything from QA id 523 (existing QA in HC3) and also other APIs like list of all other devices, reading variables etc.

    Same function as you have in "old" fibaroapiHC3 :)

    Thanks

    You can always save the QA as a "unpacked" QA as shown in a previous post and debug this files.

    Link to comment
    Share on other sites

  • Topic Author
  • 19 minutes ago, petrkl12 said:

    My case is about that I want to use everything from HC3 - it means everything from QA id 523 (existing QA in HC3) and also other APIs like list of all other devices, reading variables etc.

    Same function as you have in "old" fibaroapiHC3 :)

    Thanks

    Is 523 the a proxy or the real QA?

    If its the real QA you don't get any callbacks? buttons , fibaro.calls from other QAs etc?

    Link to comment
    Share on other sites

    523 is the real QA.

    Currently it's enough for me just redirect all read/write operations to HC3 from SDK

     

    Prefect feature could be detect events (ie.press buttons) from that real QA to your SDK.

     

     

     

    Link to comment
    Share on other sites

  • Topic Author
  • 9 hours ago, petrkl12 said:

    523 is the real QA.

    Currently it's enough for me just redirect all read/write operations to HC3 from SDK

     

    Prefect feature could be detect events (ie.press buttons) from that real QA to your SDK.

    That's the point with the proxy.

    The emulator can automatically install a proxy on the HC3 that looks like your real QA.

    However it will send all events back to the emulator version of the QA.

    That means that if you click on buttons/sliders in the proxy UI on the HC3 the button handlers in your emulated version of the QA is called.

    If some other QA/Scene calls your QA on the HC3 with fibaro.call(523,"turnOn") that is sent back to the emulator and calls the QuickApp:turnOn function there. This is the real advantage of the emulated model. Then when it works you choose the "deploy QA" menu option and the real QA is deployed to the HC3 with all the files.

     

    You don't need to specify the deviceID 523 in the header to achieve what you need.

    Please login or register to see this code.

     

    9 hours ago, jgab said:

    That's the point with the proxy.

    The emulator can automatically install a proxy on the HC3 that looks like your real QA.

    However it will send all events back to the emulator version of the QA.

    That means that if you click on buttons/sliders in the proxy UI on the HC3 the button handlers in your emulated version of the QA is called.

    If some other QA/Scene calls your QA on the HC3 with fibaro.call(523,"turnOn") that is sent back to the emulator and calls the QuickApp:turnOn function there. This is the real advantage of the emulated model. Then when it works you choose the "deploy QA" menu option and the real QA is deployed to the HC3 with all the files.

     

    You don't need to specify the deviceID 523 in the header to achieve what you need.

    Please login or register to see this code.

     

    What I will do though is that if you have a proxy, you can edit the UI on the proxy and force that definition to be used by the emulated QA.

    Edited by jgab
    Link to comment
    Share on other sites

  • Topic Author
  • 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...

    Edited by jgab
    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...