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

    The command

    >plua --init
    will create a project setup in a new workspace for vscode.

    Besides choosing a QA template it will also install

    /.vscode/launch.json
    /.vscode/tasks.json

     

    The launch.json contains 2 different launch configs:

    -plua: Run Current Lua File with Debugger
    -plua: Run Current Fibaro File with Debugger

    The first config just runs a lua file without loading the fibaro APIs. The second expects the file to be a QA and will load the fibaro APIs and try to start QuickApp:onInit if it exists.

    Note that when pressing F5 or choosing "Start Debugging" in vscode, it will run the current chosen launch configuration. If that happens to be the first config, in this case, it will complain that there is no fibaro.* or api.* functions available.
    In vscode we select the launch config in the run and debug side panel.

    Please login or register to see this attachment.

    Posted

    Good morning,

    I've noticed that:

    fibaro.getValue(1, "sunsetHour")

    stopped working on plua emulator (up to date version) - returns nil.

    With sunriseHour - the same.

     

    Sooner it's working on the emulator. On real box - it's working as well.

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

    Good morning,

    I've noticed that:

    fibaro.getValue(1, "sunsetHour")

    stopped working on plua emulator (up to date version) - returns nil.

    With sunriseHour - the same.

     

    Sooner it's working on the emulator. On real box - it's working as well.

    That was a strange bug... the problem seems to have been there for a long time...
    Try v1.3.14

    • Thanks 1
    Posted

    Now it's working again. Thank you!

    Posted (edited)

    hi @jgab,

    I just started a new QA for controlling a new High Loal module from Nice, id 818 and I am getting the following error when using fibaro.getValue(818;"name") or api.get("/devices/818"):

     


    Process started
    Detected host IP: 192.168.1.34
    ╭──────────────────────────────────────────────────────────────────────────────╮
    │ Python:3.14.2, Lua:5.4                                                       │
    │ API:8080                                                                     │
    ╰──────────────────────────────────────────────────────────────────────────────╯
    Fibaro SDK, online, (0.7574s)
        [C]: in upvalue 'original_error'
        [C]: in function 'xpcall'
        [string "<python>"]:1: in main chunk

     

    This is the first time I get this...

    F5 was with "Plua Run Current Fibaro File with Debugger" 

     

    As the line print("sunSet at",fibaro.getValue(1, "sunsetHour")) is working now, I need to check if my request has the correct format...  

     

    I have corrected the format of my requests and it is working now but I wonder why I did not get previous error message with line number where the error occurs.

    Edited by Christb
    Posted

    In fact, I think that something went wrong during the last update as when launching a old QA code which was perfectly working before, I am getting the following message:


    Process started
    Detected host IP: 192.168.1.34
    ╭──────────────────────────────────────────────────────────────────────────────╮
    Python:3.14.2, Lua:5.4                                                       │
    API:8080                                                                     │
    ╰──────────────────────────────────────────────────────────────────────────────╯
    Fibaro SDK, offline, (0.3965s)
        no field package.preload['dkjson']
        no file 'C:/Users/bruvi/scoop/apps/python/current/Lib/site-packages/lua/dkjson.lua'
        no file 'C:\Users\bruvi\scoop\apps\python\current\dkjson\init.lua'
        no file 'C:\Users\bruvi\scoop\apps\python\current\..\share\lua\5.4\dkjson.lua'
        no file 'C:\Users\bruvi\scoop\apps\python\current\..\share\lua\5.4\dkjson\init.lua'
        no file '.\dkjson.lua'
        no file '.\dkjson\init.lua'
        no file 'C:\Users\bruvi\scoop\apps\lua\current\bin'
        [C]: in function 'require'
        [C]: in function 'xpcall'
        [string "<python>"]:1: in main chunk

     

     

    I tried to reinstall plua and I am getting at then end of the TERMINAL log:

     

    ...

    Requirement already satisfied: colorama in C:\Users\bruvi\scoop\apps\python\current\Lib\site-packages (from click>=7.0->uvicorn>=0.30.0->uvicorn[standard]>=0.30.0->plua) (0.4.6)
    Requirement already satisfied: colorama in C:\Users\bruvi\scoop\apps\python\current\Lib\site-packages (from click>=7.0->uvicorn>=0.30.0->uvicorn[standard]>=0.30.0->plua) (0.4.6)
    Requirement already satisfied: colorama in C:\Users\bruvi\scoop\apps\python\current\Lib\site-packages (from click>=7.0->uvicorn>=0.30.0->uvicorn[standard]>=0.30.0->plua) (0.4.6)
    Requirement already satisfied: httptools>=0.6.3 in C:\Users\bruvi\scoop\apps\python\current\Lib\site-packages (from uvicorn[standard]>=0.30.0->plua) (0.7.1)
    Requirement already satisfied: python-dotenv>=0.13 in C:\Users\bruvi\scoop\apps\python\current\Lib\site-packages (from uvicorn[standard]>=0.30.0->plua) (1.2.1)
    Requirement already satisfied: pyyaml>=5.1 in C:\Users\bruvi\scoop\apps\python\current\Lib\site-packages (from uvicorn[standard]>=0.30.0->plua) (6.0.3)
    Requirement already satisfied: watchfiles>=0.13 in C:\Users\bruvi\scoop\apps\python\current\Lib\site-packages (from uvicorn[standard]>=0.30.0->plua) (1.1.1)
    WARNING: Ignoring invalid distribution ~lua (C:\Users\bruvi\scoop\apps\python\current\Lib\site-packages)
    WARNING: Ignoring invalid distribution ~lua (C:\Users\bruvi\scoop\apps\python\current\Lib\site-packages) 

     

    Do I have to reinstall everything using scoop?

    Posted

    Good morning,
    I’ve encountered some unexpected behavior in PLUA. Is this a bug? In my opinion, it would be worth fixing.

    When selecting Run Task/upload current file as QA, if the file contains --%%file=... directives, the files are not loaded into the QA in the same order as the --%%file directives. This can matter. In my case, it did.

    However, if a project file is created first, which, to my knowledge, essentially means starting a debugger session, and then Run Task/update QA is selected, the files are loaded in the same order as the file directives.

  • Topic Author
  • Posted

    You can’t rely on the load order of QA files on the HC3. The only given is that :onInit() is called after all files are loaded.

     

    Posted

    I think we can assume that the files are launched in the same order in which they appear in the box interface. And what I described above seems to happen repeatedly.


    Please login or register to see this image.

    /monthly_2026_07/image.png.da49c0e7e58427ada2a6c544caf9fff2.png" />

    Posted

    If I'm wrong with my opinion, I think the load manager should be very easy to write.

     

    File ONE (file order - no matters):

    Please login or register to see this code.

     

    File TWO (file order - no matters):

    Please login or register to see this code.

    ...and all other files of the project.

     

    Finally, load manager:

    Please login or register to see this code.

     

    This ensures controlled order of loading. Name scooping behaves practically the same as not function-enclosed.
    *
    One trap: in each module do not forget final 
    end

  • Topic Author
  • Posted (edited)

    It used to be a bit random.

     

    It may be that after they fixed the QA file load bug some time ago that the order has become more predictable.
    However, if that was the case I would assume that they had a way to allow us to reorder the files in the edit UI ?  :-) 

    ER7 uses a module system where each module sets a priority. < 0 loads before main code runs and > 0 loads after.
    There are many ways to solve it. As I proposed in the post 6 years ago we could agree about a model to make it easier to use each others modules, but there were no believers at that time.

    Edited by jgab
  • Topic Author
  • Posted
    On 7/25/2026 at 11:27 PM, Christb said:

    In fact, I think that something went wrong during the last update as when launching a old QA code which was perfectly working before, I am getting the following message:


    Process started
    Detected host IP: 192.168.1.34
    ╭──────────────────────────────────────────────────────────────────────────────╮
    Python:3.14.2, Lua:5.4                                                       │
    API:8080                                                                     │
    ╰──────────────────────────────────────────────────────────────────────────────╯
    Fibaro SDK, offline, (0.3965s)
        no field package.preload['dkjson']
        no file 'C:/Users/bruvi/scoop/apps/python/current/Lib/site-packages/lua/dkjson.lua'
        no file 'C:\Users\bruvi\scoop\apps\python\current\dkjson\init.lua'
        no file 'C:\Users\bruvi\scoop\apps\python\current\..\share\lua\5.4\dkjson.lua'
        no file 'C:\Users\bruvi\scoop\apps\python\current\..\share\lua\5.4\dkjson\init.lua'
        no file '.\dkjson.lua'
        no file '.\dkjson\init.lua'
        no file 'C:\Users\bruvi\scoop\apps\lua\current\bin'
        [C]: in function 'require'
        [C]: in function 'xpcall'
        [string "<python>"]:1: in main chunk

     

     

    I tried to reinstall plua and I am getting at then end of the TERMINAL log:

     

    ...

    Requirement already satisfied: colorama in C:\Users\bruvi\scoop\apps\python\current\Lib\site-packages (from click>=7.0->uvicorn>=0.30.0->uvicorn[standard]>=0.30.0->plua) (0.4.6)
    Requirement already satisfied: colorama in C:\Users\bruvi\scoop\apps\python\current\Lib\site-packages (from click>=7.0->uvicorn>=0.30.0->uvicorn[standard]>=0.30.0->plua) (0.4.6)
    Requirement already satisfied: colorama in C:\Users\bruvi\scoop\apps\python\current\Lib\site-packages (from click>=7.0->uvicorn>=0.30.0->uvicorn[standard]>=0.30.0->plua) (0.4.6)
    Requirement already satisfied: httptools>=0.6.3 in C:\Users\bruvi\scoop\apps\python\current\Lib\site-packages (from uvicorn[standard]>=0.30.0->plua) (0.7.1)
    Requirement already satisfied: python-dotenv>=0.13 in C:\Users\bruvi\scoop\apps\python\current\Lib\site-packages (from uvicorn[standard]>=0.30.0->plua) (1.2.1)
    Requirement already satisfied: pyyaml>=5.1 in C:\Users\bruvi\scoop\apps\python\current\Lib\site-packages (from uvicorn[standard]>=0.30.0->plua) (6.0.3)
    Requirement already satisfied: watchfiles>=0.13 in C:\Users\bruvi\scoop\apps\python\current\Lib\site-packages (from uvicorn[standard]>=0.30.0->plua) (1.1.1)
    WARNING: Ignoring invalid distribution ~lua (C:\Users\bruvi\scoop\apps\python\current\Lib\site-packages)
    WARNING: Ignoring invalid distribution ~lua (C:\Users\bruvi\scoop\apps\python\current\Lib\site-packages) 

     

    Do I have to reinstall everything using scoop?


    Yes, it looks like the installation is broken. It trying to load dkjson.lua instead of plus's own builtin json lib is a bad sign.

    Google "force an install with scoop ?" and follow the guidance from the AI answer...

    Posted
    8 godzin temu, jgab napisał:

    It may be that after they fixed the QA file load bug some time ago that the order has become more predictable.
    However, if that was the case I would assume that they had a way to allow us to reorder the files in the edit UI ?  :-) 

    Well, we know nothing certain about the module loading order, and even less about the order in which QuickApps start. My impression is that whichever one manages to push its way through first is the one that starts first.

    Is that why you didn’t implement ER a client–server application? It’s a different topic, but I couldn’t resist asking after my recent "server-side experiences".

    Your request from six years ago didn’t attract any interest. My SVG proposal – which significantly improves the quality of communication with the user in a simple way – attracted four interested people...

    Posted (edited)

    Try this and you will see the start order - it's always the same - as listed in UI. Whatever you do.
    If one need order of --%%file appearance in plua you need:

    1) upload application (no start order guaranteed)

    2) set --%%project to uploaded ID

    3) run in plua and stop

    4) update application (now, you can expect the same order as file directives).
    There's no fix of plua necessary - there is a solution only little longer.
     

    Please login or register to see this attachment.

    Edited by Łukasz997

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