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

Posted (edited)

@jgab

how to do it same function (UI, Variables, Proxy and Files) in Plua for this:

 

Please login or register to see this code.

 

Edited by petrkl12
Posted (edited)
1 hour ago, Christb said:

Worse because the Proxi QA now is crashing

I have reboot my HC3 (upgrade of HC3 version).

Now the Proxy 706 is no more crashing but still no reaction to button release.

HC3 console is now giving:

[13.09.2025] [20:25:05] [DEBUG] [QUICKAPP706]: Started Manual Heating Override_Proxy 706
[13.09.2025] [20:25:05] [DEBUG] [QUICKAPP706]: http://192.168.1.24:8080/api/devices/%s/action/%s
[13.09.2025] [20:25:05] [DEBUG] [QUICKAPP706]: http://192.168.1.24:8080/api/plugins/callUIEvent
[13.09.2025] [20:25:41] [TRACE] [QUICKAPP706]: onAction: {"deviceId":706,"actionName":"CONNECT","args":[{"ip":"192.168.1.24","port":8080}],"manual":true}
[13.09.2025] [20:25:41] [DEBUG] [QUICKAPP706]: CONNECT[13.09.2025] [20:25:41] [DEBUG] [QUICKAPP706]: http://192.168.1.24:8080/api/devices/%s/action/%s
[13.09.2025] [20:25:41] [DEBUG] [QUICKAPP706]: http://192.168.1.24:8080/api/plugins/callUIEvent
[13.09.2025] [20:25:41] [DEBUG] [QUICKAPP706]: Connected
[13.09.2025] [20:26:06] [TRACE] [QUICKAPP706]: UIEvent: {"elementName":"b2","values":[],"eventType":"onReleased","deviceId":706}
[13.09.2025] [20:26:12] [TRACE] [QUICKAPP706]: UIEvent: {"elementName":"b2","values":[],"eventType":"onReleased","deviceId":706}
[13.09.2025] [20:27:05] [TRACE] [QUICKAPP706]: onAction: {"deviceId":706,"actionName":"CONNECT","args":[{"ip":"192.168.1.24","port":8080}],"manual":true}
[13.09.2025] [20:27:05] [DEBUG] [QUICKAPP706]: CONNECT
[13.09.2025] [20:27:05] [DEBUG] [QUICKAPP706]: http://192.168.1.24:8080/api/devices/%s/action/%s
[13.09.2025] [20:27:05] [DEBUG] [QUICKAPP706]: http://192.168.1.24:8080/api/plugins/callUIEvent
[13.09.2025] [20:27:05] [DEBUG] [QUICKAPP706]: Connected
13.09.2025] [20:27:37] [TRACE] [QUICKAPP706]: UIEvent: {"elementName":"b2","values":[],"eventType":"onReleased","deviceId":706}
[13.09.2025] [20:28:16] [ERROR] [QUICKAPP706]: Connection timed out
[13.09.2025] [20:28:22] [ERROR] [QUICKAPP706]: Connection timed out
[13.09.2025] [20:28:35] [TRACE] [QUICKAPP706]: UIEvent: {"elementName":"b1","values":[],"eventType":"onReleased","deviceId":706}
[13.09.2025] [20:29:48] [ERROR] [QUICKAPP706]: Connection timed out
[13.09.2025] [20:30:45] [ERROR] [QUICKAPP706]: Connection timed out
 
Edited by Christb
  • Topic Author
  • Posted (edited)

    It seems to work. The proxy gets the ip and port from plua (CONNECT).
    When you press a button (UIEvent) the proxy calls back to plua

    and it times out after ~30s - meaning that plua's web server on port 8080 don't answer.

    One reason is that plua have stopped running.

    Another reason is that you have stopped in a breakpoint in the debugger so Plua don't run.

    A third reason could be that your windows machine is running some firewall? (but it worked with hc3emu?)

    For plua (and your QA) be able to process incoming button presses, your QA needs to be running.

    Edited by jgab
    Posted (edited)
    11 hours ago, jgab said:

    One reason is that plua have stopped running

    in vscode the top symbols show that it is running

    Please login or register to see this image.

    /monthly_2025_09/image.png.83f7e1a930ec3d27eab1cfb152fa5558.png" />

    Also the wed UI is working ok and I did test each buttons and select and all are working perfectly. 

    11 hours ago, jgab said:

    Another reason is that you have stopped in a breakpoint in the debugger so Plua don't run.

    As I know, I have not added any breakpoint as this QA was working perfectly in hc3emu2

    11 hours ago, jgab said:

    A third reason could be that your windows machine is running some firewall? (but it worked with hc3emu?)

    I was thinking of this possibility and have used kill-port.ps1 to kill the port without any improvement.

     

    Do you have more comprehensive debug mode that will help understanding what is happening with the port? 

     

    For your information going to

    Please login or register to see this link.

    and runing "GET /health" I have:

    status

              "healthy"

    uptime_seconds

    51686.4702231884

    requests_served

    4

    mode

    "multi-process"

    lua_engine

    "connected via IPC"

    fibaro_api   

              "available (hook-based)"
    Edited by Christb
  • Topic Author
  • Posted

    To check the firewall, from another pc or your mobile go to http://<ip of your plua pc>/health and see if you get response.
    localhost just test internal pc traffic....

  • Topic Author
  • Posted

    @Christb try v1.2.39 that I just uploaded.
    Debugging on Windows (which is not so easy for me, will get a better machine this week)
    I had the same issue. It seems that Windows is much more restrictive with external access.
    Anyway, with v1.2.39 I get the proxy to work running on Windows.

    Posted
    4 hours ago, jgab said:

    To check the firewall, from another pc or your mobile go to http://<ip of your plua pc>/health and see if you get response.

    I have no other PC so tried with my mobile using ConnectBot but hve not yet been able to connect any port of my PC using this tool.

    I have tried PowerShell and cannot connect also but:


    PS C:\WINDOWS\system32> Get-NetTCPConnection | Where-Object { $_.LocalPort -eq 8082 }

    LocalAddress                        LocalPort RemoteAddress                       RemotePort State       AppliedSetting
    ------------                        --------- -------------                ---------- -----                             --------------
    192.168.1.25                        8082      0.0.0.0                             0              Listen
    192.168.1.25                        8082      homecenter_IP                54654      Established Internet

    which shows that the  QA PluaHelper is connected

     

    Using:

    PS C:\WINDOWS\system32> Get-NetTCPConnection | Where-Object { $_.LocalPort -eq 8080 }

    LocalAddress                        LocalPort RemoteAddress                       RemotePort State       AppliedSetting
    ------------                        --------- -------------                        ---------- -----       --------------
    ::1                                     8080      ::                                      0             Listen
    127.0.0.1                           8080      127.0.0.1                           51026      TimeWait
    127.0.0.1                           8080      127.0.0.1                           51009      TimeWait
    127.0.0.1                           8080      127.0.0.1                           51206      TimeWait
    127.0.0.1                           8080      127.0.0.1                           50988      TimeWait
    127.0.0.1                           8080      127.0.0.1                           51189      TimeWait
    127.0.0.1                           8080      127.0.0.1                           51187      TimeWait
    127.0.0.1                           8080      127.0.0.1                           51148      TimeWait
    127.0.0.1                           8080      127.0.0.1                           51067      TimeWait
    127.0.0.1                           8080      127.0.0.1                           51046      TimeWait
    127.0.0.1                           8080      127.0.0.1                           51087      TimeWait
    127.0.0.1                           8080      0.0.0.0                             0             Listen
    127.0.0.1                           8080      127.0.0.1                           51169      TimeWait
    127.0.0.1                           8080      127.0.0.1                           51165      TimeWait
    127.0.0.1                           8080      127.0.0.1                           51006      TimeWait
    127.0.0.1                           8080      127.0.0.1                           51146      TimeWait
    127.0.0.1                           8080      127.0.0.1                           51129      TimeWait
    127.0.0.1                           8080      127.0.0.1                           51209      Established Internet
    127.0.0.1                           8080      127.0.0.1                           51106      TimeWait
    127.0.0.1                           8080      127.0.0.1                           51126      TimeWait
    127.0.0.1                           8080      127.0.0.1                           51049      TimeWait
    127.0.0.1                           8080      127.0.0.1                           50969      TimeWait
    127.0.0.1                           8080      127.0.0.1                           51089      TimeWait
    127.0.0.1                           8080      127.0.0.1                           51069      TimeWait
    127.0.0.1                           8080      127.0.0.1                           51028      TimeWait
    127.0.0.1                           8080      127.0.0.1                           50986      TimeWait

    I cannot see any connection to my homecenter_IP so I assume I have an issue with port 8080 but why your web emulator QuickApp 706 can sent command to this port? Is it because in fact not a remote acces?

     

    I have checked in my FireWall and port 8080 accpts incomming acces from all remote devices.

    Posted (edited)
    1 hour ago, jgab said:

    @Christb try v1.2.39 that I just uploaded.

    Upgrade done 🙂and now my proxy 706 in HC3 has all press buttons launching its function in vscode👍

     

    But I have now a new error using the select button:  Manual_Climate_zone_plua_v11.x.lua::1009: attempt to index a nil value (field 'values') that I never have before using hc3emu2.

    Also doing the same use of the select buttons using the web QuickAp 706, I do not have this error.

     

    Looking to the differences of received event message, I have

    with QuickApp 706:

    [14.09.2025][18:43:27][DEBUG  ][MANUAL HEATING OVERRIDE_PROXY706]: ev-> {"values":["auto"],"eventType":"onToggled","deviceID":706,"elementName":"selectChange"}

    then using the value "auto" the following lua code is processed OK (choice=ev.values[1] -> choice="auto")

     

    using the HC3 Proxy I have:

    [14.09.2025][18:34:09][DEBUG  ][MANUAL HEATING OVERRIDE_PROXY706]: ev-> {"deviceID":706,"elementName":"selectChange","eventType":"onToggled"}
    [14.09.2025][18:34:09][ERROR  ][MANUAL HEATING OVERRIDE_PROXY706]: Manual_Climate_zone_plua_v11.x.lua::1010: attempt to index a nil value (field 'values')

    which shows that the '"values":[auto]' element is missing so the error field 'ev.value[1]' is nil and the QA crashes  👎

     

    Attache my last version of the QA lua file

     

     

     

     

     

    Please login or register to see this attachment.

    Edited by Christb
  • Topic Author
  • Posted

    Ok, I fixed the values issue. v1.2.40
    You have to delete and create a new proxy. 
    Alt. go in and patch your proxy on the HC3 by hand:

    Please login or register to see this code.

     

    Posted (edited)
    8 hours ago, jgab said:

    Ok, I fixed the values issue. v1.2.40

    I have uploaded your last version =, renamed the old proxy and let Plua creating a new one id 744.

    Oups , the new Proxy is now crashing when any button is pressed, log console below:

    [15.09.2025] [15:19:59] [DEBUG] [QUICKAPP744]: Started Manual Heating Override_Proxy 744
    [15.09.2025] [15:19:59] [DEBUG] [QUICKAPP744]: [15.09.2025] [15:19:59] [DEBUG] [QUICKAPP744]:
    [15.09.2025] [15:19:59] [TRACE] [QUICKAPP744]: onAction: {"args":[{}],"deviceId":744,"actionName":"CONNECT","manual":true}
    [15.09.2025] [15:19:59] [DEBUG] [QUICKAPP744]: CONNECT
    [15.09.2025] [15:19:59] [DEBUG] [QUICKAPP744]:
    [15.09.2025] [15:19:59] [DEBUG] [QUICKAPP744]:
    [15.09.2025] [15:19:59] [DEBUG] [QUICKAPP744]: Connected
    [15.09.2025] [15:20:37] [TRACE] [QUICKAPP744]: UIEvent: {"elementName":"b2","values":[],"deviceId":744,"eventType":"onReleased"}
    [15.09.2025] [15:20:37] [ERROR] [QUICKAPP744]: QuickApp crashed
    [15.09.2025] [15:20:37] [ERROR] [QUICKAPP744]: std::runtime_error: 'Invalid argument'
    [15.09.2025] [15:20:57] [DEBUG] [QUICKAPP744]: Started Manual Heating Override_Proxy 744
    [15.09.2025] [15:20:57] [DEBUG] [QUICKAPP744]:
    [15.09.2025] [15:20:57] [DEBUG] [QUICKAPP744]:

     

     

    As I kept the 706 Proxy, I rename it as the normal proxy name (Manual Heating Override_Proxy) patch the additional line (with a comma at the end of the previews line) and relaunch vscode; 😄 this Proxy 706 is now working perfectly with v1.2.40

    Edited by Christb
    Posted
    9 minutes ago, Christb said:

    😄 this Proxy 706 is now working perfectly with v1.2.40

    But not yet the QA as I have discovered a problem which I didn't have with hc3emu2 using api.put; this error is only when I am trying to change Climate zone to 'Manual'or 'Vacation' mode( return error 400).

    The 2 other possible modes 'Return to Schedule' and 'Modified Schedule' modes changes are accepted by HC3 (return 200) 

     

    After some trials with different timing values for Vacation or Manual , , I got this error:

    [15.09.2025][16:16:16][DEBUG  ][PLUA]: PUT /panels/climate/16 {"id":16,"name":"Test Zone","properties":{"autoSetPointHysteresis":2.0,"calculationStrategy":"avg"..
    [15.09.2025][16:16:16][DEBUG  ][MANUAL HEATING OVERRIDE_PROXY706]: updateHC3() 10; Error while sending new data to HC3, error code:  400
    [15.09.2025][16:16:20][DEBUG  ][PLUA]: Connection failed, attempting to wake HC3 device...
    WARNING:plua.lua_bindings:Failed to wake network device: 192.168.1.107
    [15.09.2025][16:16:22][DEBUG  ][PLUA]: Wake attempt failed or device didn't respond
    [15.09.2025][16:16:22][ERROR  ][PLUA]: HC3 call failed: HTTPConnectionPool(host='192.168.1.107', port=80): Max retries exceeded with url: /api/plugins/updateView (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000215D3B4BBD0>: Failed to establish a new connection: [WinError 10053] Une connexion établie a été abandonnée par un logiciel de votre ordinateur hôte'))
    [15.09.2025][16:16:22][INFO   ][PLUA]: Please check your HC3 connection
    Process exit with code: 0 signal: null

    ->Is it Plua which stop the connection because too much bad access trial or the HC3 killing the session for the same reason?

    If it is the later reason, this is has been added in the latest Beta version has I never got this with previous HC3 version.

    Good for the HC3 security but not good when you are making development.

     

    What is strange, is that changing to Manual mode is OK using the QuickApp 706 (change of mode also seen in the HC3 Climate page) but not the Vacation mode (error 400).

    For all mode change, the code is using the same QuickApp:updateHC3(); main code is:

     if line==200 then -- value of this local variable, line, has to be set to 200 only when you know that HC3 is online
              local a,apiPutError = api.put("/panels/climate/"..zoneId,climZTable)
              if apiPutError==200 then self:debug("updateHC3() 9; New data of ZoneId: ",zoneId," have been sent to HC3")
              else self:debug("updateHC3() 10; Error while sending new data to HC3, error code: ",apiPutError)
              end
     else self:debug("updateHC3() 11; Off Line means no update of HC3")
     end

    I don't see why the format of the PUT requests are now incorrect in 2 modes and not the others but I will dig more in checking "climateZTable" file for all modes (comparison and Swagger); will let you know my fidings.

     

    I have seen is that even if in this 2 modes you can make a 'longPressedDown' to launch the function QuickApp:infiniteDuration() -- which exists in the QA lua -- is now giving a Warning message like: UI callback for b10 onLongPressDown not found., same for button b12.

    It seems that the longPressedDown feature is not active in the desktop QuickApp UI; ->true and then explaining why proxy long press is not recognized?

    Posted
    3 hours ago, Christb said:

    why proxy long press is not recognized?

    Sorry, Plua is managing onlongPressDown and OnlongPressedReleased, I have created a special QA to test all buttons and switch actions and all are working in Proxy and QuickApp Web UI; need to check my code but again, it was working in hc3emu2.

     

    The directive --%%logui=true is now ignored: by which directive can you retreive the Proxy UI?

     

  • Topic Author
  • Posted

    I've added --%%logui:true
    Note the lower case.

    Can you give me the full data structure for [15.09.2025][16:16:16][DEBUG  ][PLUA]: PUT /panels/climate/16 {"id":16,"name":"Test Zone","properties":{"autoSetPointHysteresis":2.0,"calculationStrategy":"avg"..
    so I can test something similar and try to see where it goes wrong?

    I think I  can improve on the cascading error messages...

  • Topic Author
  • Posted

    Yes, long presses are not handled by the desktop UI.

  • Topic Author
  • Posted

    So this sequence is strange.
     

    Please login or register to see this code.

    Your PUT is wrong somehow (do you have an empty array in the data? like {} ? - it needs to be marked as an array for json encoding to work correctly)
    and it generates a error 400 which is normal

    But then 16:16:20 (4s later) there seems to be another request that fail to connect to the HC3 (timeout or refused) so plua goes into wakeup attempts, tries a few times, gives up and exits.

    Ah, now I see, it's 16:16:22, /api/plugins/updateView that times out .- somehow your HC3 has decided not to answer and refuses connection.
    I will add some better debugging in next version to understand better why it couldn't connect (timeout, refuse, ...). 

    • Like 1
    Posted (edited)
    5 hours ago, jgab said:

    Your PUT is wrong somehow (do you have an empty array in the data? like {} ? - it needs to be marked as an array for json encoding to work correctly

    I experienced the issue few months ago and I have already added in my QA your function to replace {} by [] 👍which runs when pressing the "Validate" button just before sending the file to HC3.

     

    As I said, I need to have a look at the structure of 'climZTable' file for each of the 4 possible changes and also each weekDay period tables:

    'Climate Zone' data file are not easy to create as there are a lot of rules which prevent the file to be accepted by HC3 like:

    - like you said empty table with {},

    - 'properties.handTimestamp', 'properties.vacationStartTime', 'properties.vacationEndTime' which needs to be set to 0 in order to return to any Schedule mode,

    - 'Heat Temperature' new value cannot be more than set 'Cool_temperature-2°' with minimum and maximum values for 'T° Heat' and 'T° Cool' values, 

    - some other rules related to 4 'day period' start time that are not documented by Fibaro...

    I found these rules in testing in my QA copying the DEBUG CONSOLE json.encode print and using Swagger.

     

    But I have not a real efficient tool to compare json files:

    ->do you have something  I can use for that?

    ->is there a function to save the created json file on to my hard disk?

     

     

     

     

    Edited by Christb
    Posted

    New,

    How are you translating the hc3emu.lua.io in Plua?

    I need to use the following function that was OK in hc3emu2

     

    function QuickApp:readLocalData()
         local f = fibaro.hc3emu.lua.io.open("ClimateZone.json", "r")
        assert(f,"Couln't open the file")
        localData = f:read("*a")
        f:close()
        
        if localData == nil then
          self:debug("localData is nil")
        else
          self:debug("localData is not nil")
          localData = json.decode(localData)
          return localData
        end 
    end --en io.open r

    Posted
    18 minutes ago, Christb said:

    How are you translating the hc3emu.lua.io in Plua?

      Ok I have found that replacing "fibaro.hc3emu.lua.io.open" by just "io.open" it is working.😄

  • Topic Author
  • Posted

    Yes, in plua we get the whole Lua environment and all standard functions.

    Posted
    7 hours ago, Christb said:

    I have already added in my QA your function to replace {} by []

    Unfortunatly, the function I have added is no more making the change, {} are still {} after running the function.

    What I am using is:

         local function emptyArray(t)
              if type(t) == 'table' then
                if next(t)==nil then json.util.InitArray(t)
                else
                  for _,v in pairs(t) do emptyArray(v) end
                end
              end
         end --emptyArray()

     

        emptyArray(climZTable) -- needed for changing {} to []; lauched after all new values control in climZTable table
     
    I tried also 
    json.util.InitArray(climZTable.properties.incompatibleDevices)

    with no success

    This function was working with fibemu and hc3emu...

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