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


Visual Studio Code (vscode) for QuickApp development


jgab

Recommended Posts

9 minutes ago, jgab said:

So there is an error in the file so the QA restarts when you start it up. That can explain why your buttons don't work...

I'm a bit disappointed that there is no error message though...

Can you PM me the HouseCheck QA (the .fqa) so I can have a look at it?

The error could be that there is no QA variables as you expect.... but could also be something else.

I will send teh QA in PM, meanwhilte check on this pls..

This is coming with Fibemu i think

The lspaddon folder, fibaro.lua file

 

This is incorrect definition of fibaro.getName...so my QA debigging show it as error..It says fibaro.getName should return integer..I think there is a bug, because in the picture you can see,that it defines fibaro.getName as it should return device's room ID

Please login or register to see this image.

/monthly_2024_01/image.png.6f537dc4e37bfff472f6dbde84de5750.png" />

 

Link to comment
Share on other sites

  • Topic Author
  • Posted (edited)
    12 minutes ago, Neo Andersson said:

    I will send teh QA in PM, meanwhilte check on this pls..

    This is coming with Fibemu i think

    The lspaddon folder, fibaro.lua file

     

    This is incorrect definition of fibaro.getName...so my QA debigging show it as error..It says fibaro.getName should return integer..I think there is a bug, because in the picture you can see,that it defines fibaro.getName as it should return device's room ID

    Please login or register to see this link.

     

    Yep, thats a bug - will fix. (should return string - the name)

    Edited by jgab
    Link to comment
    Share on other sites

  • Topic Author
  • So I got 2 errors.

     

    [04.01.2024] [23:25:05] [ERROR ] [QUICKAPP1469]: :onInit() :attempt to index a nil value (global 'self'), dev/HouseCheck_helpers.lua:checkGlobals:147

     

    There is no self available here. Change to

    quickApp:setSilentmode(true, "Missing speaker IPs. Switching to silent mode.")

     

    Secondly, you call fibaro.cancel often with a nil reference. If you want/need to do that, redefine fibaro.cancel to

    function fibaro.cancel(ref) if ref then clearTimeout(ref) end end

     

    Having done that I get the following log output

    Please login or register to see this code.

    Which I guess is kind of reasonable as I haven't setup the QuickApp variables or access to the other devices on the HC3...

    and when I press Time-

    I get

    Please login or register to see this code.

     

    an error because local h1 is nil in the subsTimefunction, line 32

     

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    6 minutes ago, jgab said:

    So I got 2 errors.

     

    [04.01.2024] [23:25:05] [ERROR ] [QUICKAPP1469]: :onInit() :attempt to index a nil value (global 'self'), dev/HouseCheck_helpers.lua:checkGlobals:147

     

    There is no self available here. Change to

    quickApp:setSilentmode(true, "Missing speaker IPs. Switching to silent mode.")

     

    Secondly, you call fibaro.cancel often with a nil reference. If you want/need to do that, redefine fibaro.cancel to

    function fibaro.cancel(ref) if ref then clearTimeout(ref) end end

     

    Having done that I get the following log output

    Please login or register to see this code.

    Which I guess is kind of reasonable as I haven't setup the QuickApp variables or access to the other devices on the HC3...

    and when I press Time-

    I get

    Please login or register to see this code.

     

    an error because local h1 is nil in the subsTimefunction, line 32

     

    Please login or register to see this attachment.

    Okay, will clear the bugs, and retry tomorrow..many thanks

    Link to comment
    Share on other sites

  • Topic Author
  • 8 hours ago, Neo Andersson said:

    Okay, will clear the bugs, and retry tomorrow..many thanks

     

    In general, the Task that downloads and unpacks a QA residing on the HC3 is there just for already existing QAs that I want to continue to develop in fibemu (or when I receive a fqa from someone in the forum and wants to inspect/test the QA in fibemu)

    After the download and unpack, that becomes the master code for the QA. It is developed and tested in fibemu. It could also be pushed to github for revision control.

    When happy with the QA's behaviour in fibemu then it can be uploaded back to the HC3 with the update Task... but it's just the very last verification step. If it works in fibemu it usually works on the HC3 too...

     

    In 99.999% of the cases I start to develop QAs in fibemu from scratch. 

    Link to comment
    Share on other sites

  • Topic Author
  • Posted (edited)
    9 hours ago, jgab said:

    Having done that I get the following log output

    Which I guess is kind of reasonable as I haven't setup the QuickApp variables or access to the other devices on the HC3...

    In the emulator it's easy to create "fake devices" to test against.

    Adding this in HouseCheck.lua around line 40

    Please login or register to see this code.

    creates the simulated devices of all the devices in alldeviceIdsInUse so that doesn' generate an error anymore...

     

    I also see that the task download and unpack seems to have a bug as the HouseCheck.lua file created has 2 versions of 

    function QuickApp:onInit() in the code - removing the last seems to work...

    ...which is now fixed in the latest version of fibemu.

    Edited by jgab
    Link to comment
    Share on other sites

  • Topic Author
  • Posted (edited)

    Now running it (with fake devices and the fixes)

    by adding these quickApp vars to HouseCheck.lua 

    Please login or register to see this code.

     

    and this setup code in HouseCheck.lua :onInit (after alldeviceIdsInUse been defined)
     

    Please login or register to see this code.

     

    We then get the log

    All the Installs and "Running main" is the fake devices starting up (they are implemented as QuickApps)
     

    Please login or register to see this code.

     

    Because it was in demo mode it didn't turn off device 111 so we get the message.

     

    Please login or register to see this code.

    Maybe demo mode should not do that...?

     

    Now it only gives an error when pressing the Time- button in the UI. I believe it assumes that the TTS is setup...

    With the QA variables setup the emulator should be able to call out to nest etc...

    Edited by jgab
    Link to comment
    Share on other sites

    @jgab Jan, i am trying to create a QA from scratch, to get more familiar with deriectoves and other stuff.

     

    I set up 3 buttons a label and QA variables,

    Everything seems to be okay, but the label doesnt update in webbrowser on buttonclick. SHould there be any other directive? I did not find any in the documnetation.

     

    Please login or register to see this attachment.

     

     

    Link to comment
    Share on other sites

    4 hours ago, jgab said:

    Maybe demo mode should not do that...?

    Yes, demo mode does not act on device, just mimcs it, and debugs.

    Link to comment
    Share on other sites

  • Topic Author
  • The old UI at :5004/ needs a reload of the page to see the changes (there is also a hack that reloads the page every x seconds). The old UI will soon be removed.

     

    Instead, use the new (alt.) UI at 

    Please login or register to see this code.

    It updates automatically when you do a self:updateView(....)

     

    I'm currently hacking on the new UI to support the new select element and switch.

    2 minutes ago, jgab said:

    The old UI at :5004/ needs a reload of the page to see the changes (there is also a hack that reloads the page every x seconds). The old UI will soon be removed.

     

    Instead, use the new (alt.) UI at 

    Please login or register to see this code.

    It updates automatically when you do a self:updateView(....)

     

    I'm currently hacking on the new UI to support the new select element and switch.

    If you set autoui=true in config.json it will auto reload the old UI every 2s.

    ...but the new (alt.) UI is the preferred approach these days.

    Link to comment
    Share on other sites

    18 minutes ago, jgab said:

    The old UI at :5004/ needs a reload of the page to see the changes (there is also a hack that reloads the page every x seconds). The old UI will soon be removed.

     

    Instead, use the new (alt.) UI at 

    Please login or register to see this code.

    It updates automatically when you do a self:updateView(....)

     

    I'm currently hacking on the new UI to support the new select element and switch.

    If you set autoui=true in config.json it will auto reload the old UI every 2s.

    ...but the new (alt.) UI is the preferred approach these days.

    Okay, i will use the new UI..I didn't know about it. Now the update works..Thanks

    Link to comment
    Share on other sites

    @jgab Jan, is there any option to trigger a function at a certain time, or at some custom event trigger wihout using fibaroextra, ER5 or using loops? 

    I think the new subscription method doesnt work for times.. So i dont need to use fibaroextra in my VScode developoment just for one sinlge time event

    Link to comment
    Share on other sites

  • Topic Author
  • Posted (edited)

    Should it also run on the HC3 or is it just for testing in VSCode?

     

    The HC3 only have the setTimeout/setInterval functions and you need to buid something ontop of that to time at specific times and not drift.

     

    The sourcerTiggerSubscriber can post events at specific times just like fibaroExtra, but is a bit smaller.

    Besides that there has been a multitude of timer-helper functions in the forum over the last years.

    If you just want something that runs at a specific time each day you can use

    Ex.

    Please login or register to see this code.

     

    Edited by jgab
    Link to comment
    Share on other sites

    5 minutes ago, jgab said:

    Should it also run on the HC3 or is it just for testing in VSCode?

     

    The HC3 only have the setTimeout/setInterval functions and you need to buid something ontop of that to time at specific times and not drift.

     

    The sourcerTiggerSubscriber can post events at specific times just like fibaroExtra, but is a bit smaller.

    Besides that there has been a multitude of timer-helper functions in the forum over the last years.

    If you just want something that runs at a specific time each day you can use

    Ex.

    Please login or register to see this code.

     

    It should run on HC3 too

    Link to comment
    Share on other sites

    @jgab  Jan, when uploading or updating a QA from VS code, how can we upload/uppdate a QA that consist of multiple files. I know if there is one file, we can set . inside the task parameter textbox, but what to do when there is more files in QA. Will the directives handle the upload? So the task will know what files to update/upload when there are linked in directives with %%file = ... ?

    Edited by Neo Andersson
    Link to comment
    Share on other sites

  • Topic Author
  • 1 hour ago, Neo Andersson said:

    @jgab  Jan, when uploading or updating a QA from VS code, how can we upload/uppdate a QA that consist of multiple files. I know if there is one file, we can set . inside the task parameter textbox, but what to do when there is more files in QA. Will the directives handle the upload? So the task will know what files to update/upload when there are linked in directives with %%file = ... ?

    Yes, it will copy the QA and all it's "linked" QA files --%%file= 

    to the QA on the HC3 with the same --%%id=x as set in the main QA file.

    It will delete files on the HC3 QA that is not valid anymore, so make sure that all files are specified with --%%file=....

    It will then update the UI structure of the HC3 QA from the headers definition in the main QA.

     

    The '.' in the task parameter textbox is just to say that you want the current file in focus in the editor (I have many times made the mistake and had some other editor buffer in focus.... 😕 )

    You could also give the filename for the QA file (+ it's "linked" files) but it's usually more convenient to have the relevant QA's buffer in focus.

    Link to comment
    Share on other sites

  • Topic Author
  • v0.40 of fibemu pushed.

    -Lot's of minor bugfixes

    -Now support the select UI element

    see examples/QA_UIselect.lua for an example of use.

    Header definition looks like

    Please login or register to see this code.

    support self:updateView(<id>,"options",<options table>)

    support self:updateView(<id>,"selectedItem",<item value>)

    creates UI events with event.values[1] == selected item value

     

    New header directive --%%merge

    Please login or register to see this code.

    --%%merge=file<1>,...file<n-1>,file<n>

    will take a comma separated list of files and create a file with the name of the last file <n> that consists of the other files <1>...<n-1> merged together.

    In the example above it will create dev/OST.lua that consists of lib/OS.lua and lib/Table.lua (in that order).

    This means that we can automatically assemble a library file with pieces consisting of other files dynamically and the include that file with the --%%file directive.

    The advantage is that we create a new file that allow us to debug the file in VScode too.

    With this I'm rethinking my use of library files. I used to have one big file, fibaroExtra.lua, that consisted of everything. Now I'm building up a library of smaller files that I include with the merge command into a tailor-made library for the QA I'm developing. 

    Link to comment
    Share on other sites

    • 3 weeks later...

    I noticed the following "Unknown Event Type"s this morning. I looked at the fibemu code and saw there's a lengthy definition of the event types you've uncovered. Not sure if you are trying to add to this list as you discover more, but here's the screenshot of what I saw. If you need more info, just let me know.

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

  • Topic Author
  • 13 minutes ago, PeterV959 said:

    I noticed the following "Unknown Event Type"s this morning. I looked at the fibemu code and saw there's a lengthy definition of the event types you've uncovered. Not sure if you are trying to add to this list as you discover more, but here's the screenshot of what I saw. If you need more info, just let me know.

    Please login or register to see this attachment.

    Thanks, I will add them so the log isn't spammed. Unsure if it's worth creating sourceTriggers out of them though.

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