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


Recommended Posts

  • Topic Author
  • Posted
    1 minute ago, Joep said:

    I programmed past 2 evenings with this VScode setup and uploading code to my HC3 and it works like a charm. Two things I found out:

     

    1. If I use a multi-root workspace then the lsp / intellisense is not working correctly. Like fibaro.getValue doesn't pop up the inline code example. Also the Quick App functions (crawled from the fibemu files, I think) are not always suggested. If I work from the fibemu folder (say fibemu/dev/main.lua) everything works. I think this is a VScode thing, but I can't find a setting to fix this.

     

    2. If I start debugging (F5) from a secondary file (not main.lua) the emulator starts but the QA does nothing. Very strange. I stays at running main:

     

    Please login or register to see this attachment.

     

    Nothing to worry about, I now symlink my second repository to fibemu/dev, but I wanted to notice this.

    Yes, the first "bug" I think is vscode or the lua language server.

     

    The second issue is that the emulator/fibemu starts to run your secondary file thinking it is the main, and usually there are just definitions and no actions... no QuickApp:onInit() to run etc. So it kind of looks like nothing happens in many cases...

    The emulator can be used to run non QuickApp code too (with all the QuickApp functions) and I use that a lot so I don't want to print some warning message either...

    What would be nice if there was some vscode setting that to point at the active file when running debug (like in ZeroBrane) so it always started to debug that file and not the one currently opened.

    Posted
    On 10/21/2024 at 10:18 AM, jgab said:

    The emulator can be used to run non QuickApp code too (with all the QuickApp functions) and I use that a lot so I don't want to print some warning message either...

    What would be nice if there was some vscode setting that to point at the active file when running debug (like in ZeroBrane) so it always started to debug that file and not the one currently opened.

     

    I tested by changing the launch.json task parameter from ${relativeFile} to ${relativeFileDirname}/main.lua. This works for me. :) Now it always launches the main.lua file when also edditing other files with a more complex QA.

     

  • Topic Author
  • Posted
    On 10/22/2024 at 11:06 AM, Joep said:

     

    I tested by changing the launch.json task parameter from ${relativeFile} to ${relativeFileDirname}/main.lua. This works for me. :) Now it always launches the main.lua file when also edditing other files with a more complex QA.

     

    Yes, but it would be nice to mark the current file in the UI and not need to change launch.json file.

    I usually run several "main"s, not named "main", while developing and having to edit a file to point to different places is too much work... However, if you have one focused project it can be worth it.

    • 3 weeks later...
  • Topic Author
  • Posted

    Ok, I updated a number of python libraries in requirements.txt - recommend that all users (MacOS or Windows) to redo pip install...

    • Thanks 1
    • 5 weeks later...
  • Topic Author
  • Posted

    I have updated fibemu now so it generates .fqa (upload or download to HC3) using the new apiVersion 1.3 that includes the new uiView structure for the new mobile (web) ui look. Default is that useUiView is set to false but can be changed in the QA web editor.

  • Topic Author
  • Posted (edited)

    A new directive for emulated QAs:

    Please login or register to see this code.

    If this is set at startup, the emulator will lookup if there is a QA named "MyProxy" on the HC3 and if not create one.

    If the a QA with the name exists nothings is done.

     

    The QA created is a proxy that sends all UI events and fibaro.calls directed to the QA back to the emulated QA in vscode.

    This way the emulated QA has a proxy on the HC3 with the representative UI and a QA that other QAs on the HC3 can interact with (fibaro.calls)

     

    In the emulated QA in vscode, if we do self:updateView or self:updateProperty it will be reflected back to the proxy on the QA so it has the same state and look.

     

    If we edit the UI on the proxy with the QA web editor and restart the emulated QA back in vscode, it will log the new --%%u=... directives to build the UI same as on the proxy. Ex. here we add a slider to the proxy, and the vscode emulator at startup logs:
     

    Please login or register to see this code.

    When we run with a proxy the emulated QA will always use the UI elements of the proxy and ignore the --%%u directives in the QA file.

    However, it can be good to have them synchronized when packaging and uploading the finalized QA to the HC3...

     

    This will also work with child devices. They will be created on the HC3 as Childs to the proxy and send their events back to the emulated QA in vscode.

    If we want to delete the proxy we can go to the HC3 and delete it, which also deletes all children.

    We can also do

    Please login or register to see this code.

    that will delete the proxy named "MyProxy" if it exists.

     

    In the repo there is a test QA in

    /examples/QA_proxy.lua

    that tests this new feature...
     

    There may be bugs - I'm a bit unsure how to handle quickAppVariables. Now the emulated QA sets and dictates them, but it should probably be an option to import them from the proxy...

     

     

    Edited by jgab
    • Like 1
  • Topic Author
  • Posted

    Ex, of a QA using proxy
     

    Please login or register to see this code.

     

    It includes my QwikChild library to ease the creation of child devices.

    The proxy will get two UI elements, a slider and a button when created, but if we create additional UI elements on the proxy QA on the HC3 it will be reflected back to the vscode emulated QA.

     

    It creates 2 child devices that will be created as children to the proxy QA on the HC3.

     

    All events will be directed back to the emulated QA so we can set breakpoints and see what's going on.

     

    • Like 1
  • Topic Author
  • Posted

    Video for how to use the proxy feature....

     

    • Like 2
  • Topic Author
  • Posted (edited)

    Important, to make proxy work you need to set 

    "fibemuvar": true,

    in config.json

    It' set in config.json.example, so it's a good chance you already have it, but if it's removed it has to be set again....

     

    When that parameter is set, the emulator will update a global variable in the HC3 named FIBEMU with the ip address of the emulator so the proxy knows where to send the events....

     

    Edited by jgab
    • 4 weeks later...
    Posted

    Good morning,

    after update to the last version of VSC for QA I'm confronted with the following error. It occurs during

     

    self:updateView(HTMLtable[tabl].field, "text", HTMLtable[tabl].table)

     

    Content of the view is simple html table with named colours of background and font - in this example just white and black.

    It seems like the colour name is wrong in html2color or so?

     

    Other QA, using this technique and previously working ok, also fails.

     

    Please login or register to see this attachment.

  • Topic Author
  • Posted

    Yes, you are using a color name that is not in defined in my emulator (it needs to translate html colors to ansi colors)

    Look in .vscode/emufiles/lua/utils.lua and the COLOR table. 

    Add your color and choose the closest match, then it should work.

    Let me know the mapping and I will add it.

    I will also fix so it doesn't crash, but it may choose a strange color as substitute...

    • Thanks 1
    Posted

    Thank you for answer. White and Black (starting with small letter) is present in the COLORTABLE, and still not working.

    My names (ordinary HTML color names) is supported by HC3 and it was working good before. Maybe it will be good to go back with this COLORTABLE...

    I will wait until changed not to crash, because otherwise I have to change my library used to manage the tables in HTML. And it's used in many of my apps.

    Posted

    That's the list of my colours translated to ansi, not present in your library. Still it seems the lowercase/uppercase is a problem.

     

    floralwhite = "\033[38;5;230m", darkseagreen = "\033[38;5;108m", darkslateblue = "\033[38;5;60m", gainsboro = "\033[38;5;188m", slategray = "\033[38;5;102m", darkslategray = "\033[38;5;58m", lemonchiffon = "\033[38;5;187m", khaki = "\033[38;5;143m", lightgoldenrodyellow = "\033[38;5;186m", lavenderblush = "\033[38;5;225m", lavender = "\033[38;5;189m", slateblue = "\033[38;5;62m", deepskyblue = "\033[38;5;39m",

    • Thanks 1
  • Topic Author
  • Posted (edited)

    Added your colors to utils.lua.

     

    Actually, I don't think the problem was missing colors, I think it was an issue with config.colors.

    Did you have an colors entry in config.json?

    There were also other strange things in the html2color that I think I fixed too. Incl. lowercase.

     

    Anyway, the COLORMAP is accessible from your code so you can add your own colors if needed

    Ex.

    Please login or register to see this code.

     

    Btw, colors need to start with \027 to work in vscode debug console

    Edited by jgab
    Posted
    3 godziny temu, jgab napisał:

    Added your colors to utils.lua.

     

    Actually, I don't think the problem was missing colors, I think it was an issue with config.colors.

    Did you have an colors entry in config.json?

    There were also other strange things in the html2color that I think I fixed too. Incl. lowercase.

     

    Anyway, the COLORMAP is accessible from your code so you can add your own colors if needed

    Ex.

    Please login or register to see this code.

     

    Btw, colors need to start with \027 to work in vscode debug console

     

    Good morning Jan,

    I pulled new files from git and the problem persist, but with other info (see below). It's not a problem of small/capital letter, it's something other. Crash occurs despite colors I used are in the library (blueviolet). They are used not in the console, but in the controls area - as a HTML table for presenting some information (in the emu it's simulated on the webpage). On the HC it's working OK.

    Please login or register to see this attachment.

     

    Posted (edited)

    .

    Edited by Łukasz997
    Posted

    Well, I would like to apologise for misinformation: there's no more problem with colours.

     

    Error occurs because of other:

     

    I do in emulator:

     

    local heatZoneData, a1 = api.get("/panels/climate?detailed=true")

    and then, refer to the

    heatZoneData.properties.currentTemperature

     

    what can return current temperature of zone received from associated measuring device. Unfortunately, the field currentTemperature is missing (refers to nil). Other fields in this structure is present and holds various data.

    I copy the code to HC3 and it works. In HC3 this field is present and, as expected, holds the current temp. reading.

    Can you tell me what I'm doing wrong?

     

  • Topic Author
  • Posted
    4 hours ago, Łukasz997 said:

    Well, I would like to apologise for misinformation: there's no more problem with colours.

     

    Error occurs because of other:

     

    I do in emulator:

     

    local heatZoneData, a1 = api.get("/panels/climate?detailed=true")

    and then, refer to the

    heatZoneData.properties.currentTemperature

     

    what can return current temperature of zone received from associated measuring device. Unfortunately, the field currentTemperature is missing (refers to nil). Other fields in this structure is present and holds various data.

    I copy the code to HC3 and it works. In HC3 this field is present and, as expected, holds the current temp. reading.

    Can you tell me what I'm doing wrong?

     

    Well, the call is not implemented in the emulator. I don't have any thermostats so this area has not been in focus...

    You can fetch the value from HC3 by doing

    Please login or register to see this code.

    and condition the "hc3" depending on if you are running in the emulator or not (i.e. if fibaro.fbemu is defined).

    All api.get, api.post, api.put, api.delete takes a last argument "hc3" that bypasses the emulators own data and makes the call directly to the HC3.

    • Thanks 1
    Posted

    Thank you very much - I can use Fibemu again!

    • Like 1
    Posted

    Good Morning Jan,

    I have to test an application which perform complex action at the year change.

    I've tried to use

    fibaro.fibemu.setTime(str)

    to simulate nearly and of the year, but it's not working. It seems as setTime is not present in fibaro.fibemu
    What am I doing wrong?

     

     

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