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

    Ok, so the updateFile command uses the file .project that is created in your workspace.

    It has the id of your --%%project=<id> directive inside that file, together with the files and the names making up the QA.

    However, that .project file is generated when you run the QA in the emulator.

    So if you change the --%%project id you need to re-run the QA once so the new .project file is generated with the new id.

    Posted (edited)

    That's it, thank you. If I may suggest, it will be good to change it in emu2. This is the situation, when testing were possible only on the HC3 and that's why I do not run this qa in emu, while still making changes in it.

    Edited by Łukasz997
  • Topic Author
  • Posted (edited)

    Ok, I have pushed a new version of hc3emu2 that run your QA and can upload and update files.

     

    So, I'm not sure what to fix.... somehow I need to have a .project file that has the current deviceId of the QA on the HC3 the files relate to.

    The way was to create the .project every time you run the emulator, but of course the --%%project directive need to be manually updated

    as I have no clue what deviceId it has on the HC3. Suggestions?

     

    Btw, what can't you test in the emulator that you need to test on the HC3? - just curious...

     

    Btw2, the new hc3emu2 headers for VirtualConsole is then

    Please login or register to see this code.

    Note now that --%%proxy is just a boolean. It will automatically create a proxy with the QA name .. "Proxy".

    Edited by jgab
    Posted (edited)

    I have no further suggestions - forget it. I probably don't fully understand what --%%project is.

    Testing on the HC3 instead of the emulator leads to a longer discussion - why do it that way? - which, in my opinion, brings no real benefit. The tests were not strictly “only possible” on the HC3. I should said: it’s just better for me at the moment to run them directly on the HC.

    Edited by Łukasz997
    • Like 1
  • Topic Author
  • Posted

    Ok, there are always a need to test on the HC3. For speed, throughput, and the HC3 bugs ;-) 

     

    The idea with project was that @Joep wanted to use VSCode as the editor for QAs on the HC3. So while editing a file in VSCode, hit a short-cut to upload that file to the HC3.

    The problem for the emulator (me) was to understand what QA on the HC3 this file belonged to. Thus we created the 

    .project file with a format like

    Please login or register to see this code.

    So when you do uploadFile, the emulator looks through the .project file to find the file  path of the current VSCode buffer,

    then it has the QA id on the HC3 and the name of the file on the HC3, and can update the correct file.

     

    The alternative would have been to have directives in the files, but the problem with that is that some files (library files) are shared between different QAs when developing - and we don't want to update HC3 deviceID in many QA files either.

     

    So, instead the .project file is auto generated when the emulator runs the QA, as it knows what files make up the QA. The only thing missing is the deviceID of the real QA on the HC3. Which we set with --%%project=<HC3 QA id>

     

    We can't really use the name of the QA as QAs on the HC3 can have the same name, the only unique difference is the deviceId.

    • Like 2
    • Thanks 1
    Posted
    On 5/27/2025 at 6:28 AM, jgab said:

    There is no need for "if require and not QuickApp then require('hc3emu') end" at the top of the file

    If you keep this line when running on hc3emu2 a QA file created using hc3emu, will it be ignored?

  • Topic Author
  • Posted

    Yes, it should be ignored because 'required' is not defined when we enter the QA code.

    • Like 1
  • Topic Author
  • Posted

    Pushed v2.0.6

    Please login or register to see this code.

    • Bugfixes
    • More robust startup. Will switch to offline mode if HC3 can not be contacted

     

    Posted (edited)

    Good morning,

    I would like to ask: should I remove version hc3emu 1.1.11 before installing emu2, or will it replace the old version automatically?

     

    I’ve been having trouble with the proxy and uploading qa in version 1.1.11 (all related to the QA interface, it makes my work little "harder"). I can describe the issue in detail if you need, but maybe it's best to simply upgrade. The problem might disappear, or if it persists, at least any effort to fix would be based on the current version. It's also possible me to blame, doing something wrong.

    Edited by Łukasz997
  • Topic Author
  • Posted

    You can keep both installed, one is installed under ‘hc3emu’ and the new under ‘hc3emu2’.

    just make sure to use the new launch.json definitions and tasks definitions (you can merge them as long as they have different names)

    Posted

    I completed the installation, but I can't switch to the new emulator - I don't know what steps to take to start it.
    Where can I find the new launch.json and task files, and what should I do once I find them?
    How should the HC credentials be entered?

    It would be great if you could provide a complete manual for the installation and setup process.

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

    I completed the installation, but I can't switch to the new emulator - I don't know what steps to take to start it.
    Where can I find the new launch.json and task files, and what should I do once I find them?
    How should the HC credentials be entered?

    It would be great if you could provide a complete manual for the installation and setup process.

     

     

  • Topic Author
  • Posted

    So I'm trying to keep the first post and the links fro that page up-to-date, from now reflecting hc3emu2

    Posted

    I did it according to the instruction as I understand it.

    launch.json, settings, taksk - all copied as is from github, located in workspace/.vscode

    .hc3emu.lua in my home directory, plugin installed.

    But can't go further:

    Please login or register to see this code.

    Could you help, please?

  • Topic Author
  • Posted

    Create a file named .hc3emu2.lua. (note the preceding '.')

    either in your workspace or in your home directory 

    and set the content to

    Please login or register to see this code.

    I also store other credentials there for other services that I use. In my Hue QA I can then do

    Please login or register to see this code.

    to have a QuickAppVariable with the Hue IP without having to show it in the source code...

  • Topic Author
  • Posted
    11 minutes ago, jgab said:

    Create a file named .hc3emu2.lua. (note the preceding '.')

    either in your workspace or in your home directory 

    and set the content to

    Please login or register to see this code.

    I also store other credentials there for other services that I use. In my Hue QA I can then do

    Please login or register to see this code.

    to have a QuickAppVariable with the Hue IP without having to show it in the source code...

     

    I have added a paragraph in the first post about credentials. I saw that it was missing...

    I think there was an earlier post saying the credentials should be in 

    Please login or register to see this code.

    but that was wrong. It should be on the top-level of the structure 

    Please login or register to see this code.

     

    Posted (edited)

    Now it's working, with proper return structure. Require('hc3emu2') is... not required.

    When this started working, I wanted to get back to work on the virtual console. 

    And I was confronted with the following issues:

    plugin variable structure was changed: field plugin.mainDeviceId still exists, but - recently present - field plugin._quickApp.name dissapeared.

    As I checked now - it is also not present on HC3. It learn me to check the code on the console, not only trust emulator, because vprint from my thread about OCVC worked only on the fib2emu.

     

    Second, after running file with with RefreshRateSubscriber() in it, it's not working and I have an error:
     

    Please login or register to see this code.

     

    Next issue is with the upload and interface. Here's the definition of interface:

    Please login or register to see this code.

     

    After upload it looks like this (also when using proxy):

    Please login or register to see this image.

    /monthly_2025_06/image.png.e1664ef17ada7972b89acf3c1b51061c.png" />

    It's ok. But when I go into edit on HC3, same interface look like this:
    image.png.f6c087b006d1cace5f049589cc39ccd8.png

    As you see third line is missing.

     

    And if I try to change whatever (even single letter) in interface (in HC3) after save interface is empty.

    If I do it again (edit->any change->save), save is impossible and leads to error.

    Problem is generated by this evaporated line. It's replaced by a label with all fields empty. When I enter something in mandatory field, it saves, but third line still was lost.

    Also, I don't know if it's correct - update file task does not update changed interface. Interface is created only once, by upload.

     

    Edited by Łukasz997
  • Topic Author
  • Posted

    Yes, plugin._quickApp was a hack in the previous emulator. 

    Use the global 'quickApp' that also exist on the HC3.

    Note though that Fibaro sets it after you return from QuickApp:onInit().
    I commonly set it myself in the beginning of :onInit
     

    Please login or register to see this code.

     

    In theory there is no good way to get the name of the QuickApp before :onInit. 

    Sometimes in a library file you would like to get the name before, and then you can do

    Please login or register to see this code.

    __fibaro_get_device is a function available on the HC3 too.

     

    That the refreshStates fails is just that it times out, it will continue to poll. I will look into the error message there.

     

    The interface thing I don't see why - can you post me the source so I can try it out?

     

    The idea is that the interface is created once when the proxy is uploaded/created, and after that you edit the UI on the HC3 and in the emulator you set 

    --%%logui=true

    and it will log the new --%%u directives to recreate the UI on the proxy.

    Then one can choose to cut and paste that into the QA source to keep the in sync.

     

    I may come up with a directive the forces the update of the proxy UI from the QA when running, but it's not there yet.

    One can now delete the proxy so it's regenerated with the new UI if one needs to...

     

     

  • Topic Author
  • Posted

    Ok, I tested your --%%u declarations and I saw that your last line is a line with 6 buttons. 

    That is not really allowed on the HC3. It works as long as you don't try to open and edit the QA - then the Fibaro editor barks... and anything can happen...

    These kind of out-of-spec UIs I would reserve for QuickApp children as they are not opened and edited by users.

  • Topic Author
  • Posted (edited)

    Pushed 2.0.14 with a fix for refreshState timeout.

    Edited by jgab

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