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

With your new version of fibaroapiHC3C it's a completly new level of debugging :) Thanks!

Link to comment
Share on other sites

  • Topic Author
  • Just now, petrkl12 said:

    With your new version of fibaroapiHC3C it's a completly new level of debugging :) Thanks!

    I think the timers info is quite helpful to nail those hard bugs.

    Link to comment
    Share on other sites

    I know but my HueMain is working without bugs ???

     

    btw.

    I have this

        hc3_emulator.debug = {http=false, api=false, timersSched=false, trigger=false, timersExtra=false, timersWarn=false}
    but still info about timers ...

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • 10 minutes ago, petrkl12 said:

    I know but my HueMain is working without bugs ???

     

    btw.

    I have this

        hc3_emulator.debug = {http=false, api=false, timersSched=false, trigger=false, timersExtra=false, timersWarn=false}
    but still info about timers ...

    Please login or register to see this code.

     

    Sorry, hadn't added it in the. check in version. Pushed v.183 where it should work.

    timersWarn is either false or the time that should be considered late in second. 0.9 is 900ms. 1.1 is 1100ms.

    • Thanks 1
    Link to comment
    Share on other sites

    @jgab

    how to debug QA with childs?

     

    I'd like to have the option for connecting real device with childs with proxy for reading information, events from childs and also for creating new ones (new child dev will be under 850)

    hc3_emulator.resources = {UI = 850, quickVars = 850, parent = 850}

     

    Please login or register to see this code.

     

    Edited by petrkl12
    Link to comment
    Share on other sites

  • Topic Author
  • 13 hours ago, petrkl12 said:

    @jgab

    how to debug QA with childs?

     

    I'd like to have the option for connecting real device with childs with proxy for reading information, events from childs and also for creating new ones (new child dev will be under 850)

    hc3_emulator.resources = {UI = 850, quickVars = 850, parent = 850}

     

    Please login or register to see this code.

     

    v.185 just pushed. Try 

    Please login or register to see this code.

     

    E.g. the proxy field is a number of a QA instead of true

     

    It will add a file to your QA 850 the defines

    Please login or register to see this code.

    That the emulator when it starts up will call fibaro.call(520,"PROXY",true,<IP>) to intercept all onAction and UIEvent events.

    The QA will ping back to the emulator and if it doesn't respond it will restore the onAction handlers.

    Also if you restart the QA the handlers are restored.

    • Thanks 1
    Link to comment
    Share on other sites

    @jgab

    here is error in function QuickApp:loadChildren()

    Please login or register to see this code.

    [14.03.2021] [18:15:11] |[31;1mERROR[0m|: QuickApp 'QA_VirtualDevAIO', deviceId:850, crashed ([string "QA_VirtualDevAIO.lua"]:436: attempt to index a nil value (global '_G')) at 03/14/21 18:15:11
    [string "QA_VirtualDevAIO.lua"]:436: attempt to index a nil value (global '_G')

     

    Link to comment
    Share on other sites

  • Topic Author
  • 5 minutes ago, petrkl12 said:

    @jgab

    here is error in function QuickApp:loadChildren()

    Please login or register to see this code.

    [14.03.2021] [18:15:11] |[31;1mERROR[0m|: QuickApp 'QA_VirtualDevAIO', deviceId:850, crashed ([string "QA_VirtualDevAIO.lua"]:436: attempt to index a nil value (global '_G')) at 03/14/21 18:15:11
    [string "QA_VirtualDevAIO.lua"]:436: attempt to index a nil value (global '_G')

     

    Yes, there is a bug in handling of children - I’m chasing it...

    Link to comment
    Share on other sites

    3 minutes ago, jgab said:

    Yes, there is a bug in handling of children - I’m chasing it...

    OK, Thanks

    Link to comment
    Share on other sites

  • Topic Author
  • 48 minutes ago, petrkl12 said:

    OK, Thanks

    Does it work for you if you add _G around line 8270 ?

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    22 minutes ago, jgab said:

    Does it work for you if you add _G around line 8270 ?

    Please login or register to see this code.

     

    No

    [14.03.2021] [19:40:05] |[31;1mERROR[0m|: QuickApp 'QA_VirtualDevAIO', deviceId:850, crashed (fibaroapiHC3C.lua:3620: attempt to index a nil value (field 'quickApp')) at 03/14/21 19:40:05
    fibaroapiHC3C.lua:3620: attempt to index a nil value (field 'quickApp')
    stack traceback:
        fibaroapiHC3C.lua:4466: in metamethod '__index'
        fibaroapiHC3C.lua:3620: in field '__init'
        [string "QA_VirtualDevAIO.lua"]:569: in field '__init'
        fibaroapiHC3C.lua:5314: in field '?'
        [string "QA_VirtualDevAIO.lua"]:472: in method 'loadChildren'
        [string "QA_VirtualDevAIO.lua"]:811: in method 'onInit'
        fibaroapiHC3C.lua:3570: in field '__init'
        fibaroapiHC3C.lua:5381: in field 'QuickApp'
        fibaroapiHC3C.lua:4463: in function <fibaroapiHC3C.lua:4463>
        [C]: in function 'xpcall'
        fibaroapiHC3C.lua:4462: in local 'runQA'
        fibaroapiHC3C.lua:4477: in method 'callback'
        fibaroapiHC3C.lua:2569: in function <fibaroapiHC3C.lua:2565>
        (...tail calls...)
    [14.03.2021] [19:40:05] |[34mLOG  [0m|: Intercepting events from QA:850
     

    Link to comment
    Share on other sites

  • Topic Author
  • 55 minutes ago, petrkl12 said:

    No

    [14.03.2021] [19:40:05] |[31;1mERROR[0m|: QuickApp 'QA_VirtualDevAIO', deviceId:850, crashed (fibaroapiHC3C.lua:3620: attempt to index a nil value (field 'quickApp')) at 03/14/21 19:40:05
    fibaroapiHC3C.lua:3620: attempt to index a nil value (field 'quickApp')
    stack traceback:
        fibaroapiHC3C.lua:4466: in metamethod '__index'
        fibaroapiHC3C.lua:3620: in field '__init'
        [string "QA_VirtualDevAIO.lua"]:569: in field '__init'
        fibaroapiHC3C.lua:5314: in field '?'
        [string "QA_VirtualDevAIO.lua"]:472: in method 'loadChildren'
        [string "QA_VirtualDevAIO.lua"]:811: in method 'onInit'
        fibaroapiHC3C.lua:3570: in field '__init'
        fibaroapiHC3C.lua:5381: in field 'QuickApp'
        fibaroapiHC3C.lua:4463: in function <fibaroapiHC3C.lua:4463>
        [C]: in function 'xpcall'
        fibaroapiHC3C.lua:4462: in local 'runQA'
        fibaroapiHC3C.lua:4477: in method 'callback'
        fibaroapiHC3C.lua:2569: in function <fibaroapiHC3C.lua:2565>
        (...tail calls...)
    [14.03.2021] [19:40:05] |[34mLOG  [0m|: Intercepting events from QA:850
     

    Yes, I've seen it too. Will come with a fix tomorrow.

    • Thanks 1
    Link to comment
    Share on other sites

  • Topic Author
  • 9 hours ago, jgab said:

    Yes, I've seen it too. Will come with a fix tomorrow.

    v .186 with fix for child devices.

    Link to comment
    Share on other sites

    @jgab

    now it works

    but press of buttons in HC3 are not transfered to ZBS (parent and also in child)

    I will send you my QA via pm

    Link to comment
    Share on other sites

  • Topic Author
  • debug flags for fibaroapiHC3.lua

    Please login or register to see this code.

    The values listed above is the defaults.

    To turn on flags add the fields in hc3_emulator.debug table in header.

     

    Please login or register to see this code.

    The above enables logging of fibaro functions and timers that are 1.1s or more late.

    Edited by jgab
    Link to comment
    Share on other sites

  • Topic Author
  • Dynamic load functions for fibaroapiHC3.lua


    To dynamically load QuickApps into the emulator at runtime. The :save() functions is a utility function to save a QA in various formats.

    Please login or register to see this code.

     

    The functions return the loaded object so the function calls can be chained.

    Ex.

    Please login or register to see this code.

     

    Similar for Scenes

    Please login or register to see this code.

     

    This means that we can code a QA and load another to test against.

    Please login or register to see this code.

     

    If we have the OtherQA.lua file open in ZBS we can set breakpoints and debug that code like our main QA. We can then easily "jump" between the QAs when we debug to understand the interaction.

    If in ZBS you set user prefs:  editor.autoactivate = true

    it will automatically open unopened files if you step into them.

     

    If we load a QA from the HC3 and run it

    Please login or register to see this code.

    it will save the code files in your temp directory and open them when you debug.

     

    The dynamic load functions also work well as a basis for roll-your-own backup/restore script.

     

    Please login or register to see this code.

     

     

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

  • Topic Author
  • Connecting to the emulator at runtime ( fibaroapiHC3.lua )

     

    The emulator, when running, opens two ports.

    hc3_emulator.webPort=6872 for a web server. This server both receives events pushed from the HC3 and also serves up a Web GUI on 

    Please login or register to see this link.

     that can be used to interact with QAs and devices

    hc3_emulator.webPort=6972 is a socket listener that can be connected to (with ex. telnet) and interact with the emulator when it's running. ZeroBrane Studio is a bit limited when it comes to running commands when the application is running. This listener allows lua commands to be typed into the emulator. when it's running.

    Please login or register to see this code.

    Two commands are treated special.

    'quit' - closes the port.

    'log <pattern>' - register a log listener for log output with the tag <pattern>

    log 120

    will output all log commands with tag 'QUICKAPP120' on this port. This allows many terminals to be setup to capture the logs from different QAs and/or Scenes.

    The port can also be used to pipe commands into to turn on/off devices in specific patterns to test a QA ex.

    Link to comment
    Share on other sites

  • Topic Author
  • Multi-file support in fibaroapiHC3.lua

     

    The emulator supports creating, running and debugging multi-file QuickApps.

    It is also easy to upload the QA with all the files to the HC3.

     

    Please login or register to see this code.

     

    The comment 

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

    will load <file name> and treat it as the file in the QA with name <module name>

    In the emulator the files are loaded and can be opened in in ZBS and debugged like any Lua program with included require/dofile files.

    If the "project" is uploaded to the HC3 the files are assembled in the .fqa structure.

     

    Link to comment
    Share on other sites

    • 2 weeks later...

    @jgab

    I have problem with reading "dead" property in child devices (in HC3 it works OK). deviceID is not nil ...

     

    Please login or register to see this code.

     

    [03.04.2021] [12:38:55] |[31;1mERROR[0m|: QuickApp timer <Timer:0001 fun:017d10d8 exp:12:38:35:261> for 'QA_VirtualDevAIO', deviceId:850, crashed - fibaroapiHC3.lua:7685: attempt to call a nil value (method 'getProperty')

     

    Link to comment
    Share on other sites

  • Topic Author
  • 3 hours ago, petrkl12 said:

    @jgab

    I have problem with reading "dead" property in child devices (in HC3 it works OK). deviceID is not nil ...

     

    Please login or register to see this code.

     

    [03.04.2021] [12:38:55] |[31;1mERROR[0m|: QuickApp timer <Timer:0001 fun:017d10d8 exp:12:38:35:261> for 'QA_VirtualDevAIO', deviceId:850, crashed - fibaroapiHC3.lua:7685: attempt to call a nil value (method 'getProperty')

     

    Thanks, fixed in v0.200.2

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