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
On 1/11/2026 at 10:20 AM, jgab said:

You say that "homeTable json was registered in my global variable as a string."

-That means that you managed to encode the string?

Before this error, the home table was registered in a global variable (HomeTable) as a string so I can analyse what is inside and I had also saved it on my computer.

 

Now I am getting the error when I ry to recreate the aR table before saving it in the global variable.

 

I will try function and let you know 

Posted
On 1/12/2026 at 7:28 PM, Christb said:

I will try function and let you know 

Thanks to your function, I have discovered which character is causing the issue.

When creating the HomeTablejjson, I have functions that suppress or change some charaters and mainly:

  • Front digits are suppressed
  • spaces are changed by underscore except if it is the first character
  • all lettters like "é", "è", "à", "ù", "ô... are changed by e, e, a, u, o...

Which makes for room "Salle à manger", device name "731 💧Salle à manger Humidité" , Id 732 and  second device name "733 🌡 Salle à manger Température" with id 733:

a table like:

{"Salle_a_manger":{{"💧_Salle_a_manger_Humidite":732},{"🌡_Salle_manger_Temperature":733}}

the decoding error is comming from the replacement "à"->"a" and I don't yet undestand why: the same function with "é"->"e" is not giving this error.

I am using this to make the changes:

local aG="[\192-\255][\128-\191]*"
local aH={["Á"]="A",["Ä"]="A",["Ą"]="A",["À"]="A",["Â"]="A",["Č"]="C",["Ć"]="C",["Ç"]="C",["Ď"]="D",["É"]="E",["Ě"]="E",["Ë"]="E",["Ę"]="E",["È"]="E",["Ê"]="E",["Í"]="I",["Ï"]="I",["Î"]="I",["Ĺ"]="L",["Ľ"]="L",["Ł"]="L",["Ň"]="N",["Ń"]="N",["Ó"]="O",["Ô"]="O",["Ö"]="O",["Ő"]="O",["Œ"]="O",["Ŕ"]="R",["Ř"]="R",["Š"]="S",["Ś"]="S",["Ť"]="T",["Ú"]="U",["Ů"]="U",["Ü"]="U",["Ű"]="U",["Ù"]="U",["Û"]="U",["Ý"]="Y",["Ÿ"]="Y",["Ž"]="Z",["Ż"]="Z",["Ź"]="Z",["á"]="a",["ä"]="a",["ą"]="a",["à"]="a",["â"]="a",["č"]="c",["ć"]="c",["ç"]="c",["ď"]="d",["é"]="e",["ě"]="e",["ë"]="e",["ę"]="e",["è"]="e",["ê"]="e",["í"]="i",["ï"]="i",["î"]="i",["ĺ"]="l",["ľ"]="l",["ł"]="l",["ň"]="n",["ń"]="n",["ó"]="o",["ö"]="o",["ô"]="o",["ő"]="o",["œ"]="o",["ř"]="r",["ŕ"]="r",["š"]="s",["ś"]="s",["ť"]="t",["ú"]="u",["ů"]="u",["ü"]="u",["ű"]="u",["ù"]="u",["û"]="u",["ý"]="y",["ÿ"]="y",["ž"]="z",["ż"]="z",["ź"]="z"}

 

local function aI(aD) -- replace special character by standard one following table 'aH' in range 'aG'
    if aD then return aD:gsub(aG,aH)
    else return""
    end
end
The error is not there if room name is "Salle a manger" and shown again when using "Salle à manger" which gives:

14.01.2026][10:14:18][DEBUG  ][HOMETABLE5555]: ===== starting sanitization =====
[14.01.2026][10:14:18][DEBUG  ][HOMETABLE5555]: obj: 731
[14.01.2026][10:14:18][DEBUG  ][HOMETABLE5555]: result[ 💧_Salle_a_manger_Humidite ]: 731
[14.01.2026][10:14:18][DEBUG  ][HOMETABLE5555]: result: {"Lum_Salle_a_manger_A":656,"Lum_Salle_a_manger_B":657,"Thrmst_Salle_a_manger":135,"T°_Salle_a_Manger":690,"T°_Salle_a_manger":136,"🌡_Salle_a_manger_Temperature":733,"💧_Salle_a_manger_Humidite":731,"💭_Salle_a_manger_CO2":732}
[14.01.2026][10:14:18][ERROR  ][HOMETABLE5555]: ...scoop\apps\python\current\Lib\site-packages\lua\init.lua:'utf-8' codec can't decode byte 0xc3 in position 82: invalid continuation byte

 

What I do not understand is why "result" is showing correct changes but error is still there!

Note that vscode is giving this information:
[Error - 10:09:08 AM] Request textDocument/documentSymbol failed.
Error: selectionRange must be contained in fullRange
but as I know, "à" is Alt 133 well in the range
  • Topic Author
  • Posted

    So, looking a bit deeper into this it seemed to be an issue with how the Lua debugger communicated with vscode - nothing with the Lua code itself...
    Can you try plua v1.2.54 and see if it fixes your problem?

    Posted (edited)

     

    On 1/14/2026 at 12:33 PM, jgab said:

    Can you try plua v1.2.54 and see if it fixes your problem?

    Unfortunatly it does not fix it.

    For your information, attached HomeTable.lua 

    The issue is only related to "à" changed to "a": if room name is "Salle é manger" or "Salle ä manger", no error

     

     

    Please login or register to see this attachment.

    Edited by Christb
    Replace lua code by new version
    Posted

    I have dicovered another isue with the function aI(aD) in my HomeTable QA:

    if the name includes a "è" it is not changed by "e" and stays as "è" with no decode error - note  that "é" is well changed to "e".

    It seems that the character is not recognized in the string.

     

    What is strange is that I have started to check this 'aI(aD)' function in a separated QA doing only that (from the same source: api.get("/devices")) and it is working perfectly so it is not a Plua issue and as you said not also 'aI(aD)' code issue.

     

    I will review my code in HomeTablel.lua to understand why it is causing this error and let you know.

     

     

    Posted (edited)

    I have made more test and discovered that in plua with following code:

     

    local testSTRING=  "123_&éèç_à$ù£€#öäëü_testString"
    local meteoName="Météo"

     

    function QuickApp:onInit()
        print("--- onInit() starts ---")
        print("test_1",testSTRING) --ok
        newString1=aI(testSTRING) --ok
        --print("test_2",newString)
        newString3=testSTRING:gsub(aG,aH) --ok
        print("test_3",newString3)
        newString4=string.gsub("Météo","é","e") --ok
        print("test_4",newString4)
        newString5=string.gsub(meteoName,"é","e") --ok
        print("test_5",newString5)
        newString6=aI(meteoName--KO
        print("test_6",newString6)

     

    print("---- onInit() end ----")

     

    gives:
    [18.01.2026][22:33:39][DEBUG  ][TESTSTRINGREPLACEMENT5555]: --- onInit() starts ---
    [18.01.2026][22:33:39][DEBUG  ][TESTSTRINGREPLACEMENT5555]: test_1 123_&éèç_à$ù£€#öäëü_testString
    [18.01.2026][22:33:39][DEBUG  ][TESTSTRINGREPLACEMENT5555]: aD 123_&éèç_à$ù£€#öäëü_testString
    [18.01.2026][22:33:39][DEBUG  ][TESTSTRINGREPLACEMENT5555]: test_2 123_&eec_a$u£€#oaeu_testString
    [18.01.2026][22:33:39][DEBUG  ][TESTSTRINGREPLACEMENT5555]: test_3 123_&eec_a$u£€#oaeu_testString
    [18.01.2026][22:33:39][DEBUG  ][TESTSTRINGREPLACEMENT5555]: test_4 Meteo
    [18.01.2026][22:33:39][DEBUG  ][TESTSTRINGREPLACEMENT5555]: test_5 Meteo
    [18.01.2026][22:33:39][DEBUG  ][TESTSTRINGREPLACEMENT5555]: aD Météo
    [18.01.2026][22:33:39][DEBUG  ][TESTSTRINGREPLACEMENT5555]: test_2 Météo
    [18.01.2026][22:33:39][DEBUG  ][TESTSTRINGREPLACEMENT5555]: test_6 Météo
    [18.01.2026][22:33:39][DEBUG  ][TESTSTRINGREPLACEMENT5555]: ---- onInit() end ----
     
    Why function aI(string) does not work with string "Météo"?
    Edited by Christb
    Posted (edited)
    On 1/18/2026 at 9:46 PM, Christb said:

    Why function aI(string) does not work with string "Météo"?

    I have found a trick to have "è" & "è" or "ê" changed to "e" in adding in my function 'aI(aD)' the following lines :

     aD=string.gsub(aD,"é","e")
     aD=string.gsub(aD,"è","e")
     aD=string.gsub(aD,"ê","e")

    But I still don't understand why the above characters are not detected only in some strings.

    With that I have a correct HomeTable.json file as "à" is now correctly changed to "a"😄.

     

    In my new test QA, I do not have anymore the decode error for the character "à".

    I did not copy the code from QA 'HomeTable.lua' but rewrite it from scratch.

    As the code is similar, I am still not understanding the reason of this decode error.  

    Edited by Christb
    • 2 weeks later...
    Posted

    Hello,

    I would like to ask about utf8 library in plua. This lib is available on HC3, but in older emulator (hc3emu2) it is absent.

    This code on HC3 is succesful, when in hc3emu2 lead to an error (nil value utf8):
     

    Please login or register to see this code.

    My question is: how about plua - is the utf8 library present there?

    I’m a bit afraid to install plua (old computer, I didn’t manage well with installing the previous version), but I really miss this library.

    Posted

    I dare to install PLUA, with success. And I have the answer.
    I've tried utf8 with result: attempt to index a nil value (global 'utf8')

    It comes out:

    utf8 == nil
    but:

    print(package.loaded.utf8) 

    gives: table: 0x7fec62f2fe20

     

    So, I've done:
    _G.utf8 = require("utf8")

    and above example start to work. 


    It looks like utf8 is present but not automatically mapped to _G

    In older emulator this is not working at all.

    Posted (edited)
    W dniu 14.01.2026 o 12:33, jgab napisał:

    So, looking a bit deeper into this it seemed to be an issue with how the Lua debugger communicated with vscode - nothing with the Lua code itself...
    Can you try plua v1.2.54 and see if it fixes your problem?


    I have a similar problem that I didn’t have with the older emulator. Is there anything that can be done about it? It doesn’t seem to be related to Polish characters, which are present everywhere, but rather to some other characters…
    Debug info is not precise enough to isolate the place of "bad" character.

    Please login or register to see this attachment.

    Edited by Łukasz997
    Posted (edited)

    Update. Problem with 0xc5 decode disapear when UTF letter removed from QA name:

    Please login or register to see this code.

    However, I can't recreate error in other file with 'ż' in directive.

    One more thing I've done is to 'Save with encoding: UTF-8' in VSC (right lower corner click UTF-8), then Save... then UTF-8 (without BOM).
    Maybe directive parsing is done different way than rest of the script body.
    And maybe this helps...

    Edited by Łukasz997
    Posted

    Dear @jgab

    In a QA code using plua, I am able to add, modify or or delete an additional file

    When I am using the api.get formula I can read the content of the File of the remote QA😃

     😃

    local deviceId=450
    local file_name="getQADeviceIDs"
    print(json.encode(api.get("/quickApp/"..deviceId.."/files/"..file_name)))

    but it seems not posssible to do it using a http request; the code below is not giving any error message but I didnt get anything in the DEBUG CONSOLE:

    local url = "http://"..hc3_ip.."/quickApp/"..deviceId.."/files/"..file_name
    print("url",url)
     http:request(url,{
                              options={
                                      method="GET",
                                      checkCertificate=false,
                                       headers={
                                        ["Authorization"] = "Basic"..bearer_token,
                                        ["Content-Type"]  = "application/json",
                                        ["Accept"]        = "*/*",
                                                },
                                        success = function(r) print(r.status,r.data) end,
                                        error = function(err) print("ERR:",err) end
                                      },
                      }
          Is this type of request impossible or with a wrong format then why no error?

     

     

    Posted
    43 minutes ago, Christb said:

    request impossible or with a wrong format then why no error?

    Sorry @jgab,

    the above http code was not correct, fixed and I have a response but I am getting the following  message:

    Status 200 Data-> <!doctype html>

     

    Normaly it has to be is a json file

    So no more error but a fake response -> impossible to get a QA file content  using http?

    Posted
    2 godziny temu, Christb napisał:

    Normaly it has to be is a json file

    So no more error but a fake response -> impossible to get a QA file content  using http?

    The same. In PLUA this is not working, in hc3emu2 this is working. We will be glad for a patch...

    Posted
    On 1/31/2026 at 5:57 PM, Łukasz997 said:

    I would like to ask about utf8 library in plua.

    It seems that I have a new issue with UTF-8 when loading an icon created with GIMP (no matter which is the png file) , I got the following warning message:

    Please login or register to see this image.

    /monthly_2026_02/image.png.4cde192b1b9666139827e387b66e53a1.png" />

     

    As it is not said which characters have been replaced, using the base64encode(test_Icon.png) may give trouble when uploading it to HC3?

    Posted
    1 godzinę temu, Christb napisał:

    As it is not said which characters have been replaced, using the base64encode(test_Icon.png) may give trouble when uploading it to HC3?

    If you are asking me? - Some systems does not accept base64 (on example Fibaro emitCustomEvent!). There's "purer" version called base64 URL, which sometimes helps. 

    But safest way is to encode a stream to ascii hex - very simple and always working. This increase the size of course - base 64 by ~⅓ and asci hex x2.

    Find functions below:
     

    Please login or register to see this code.

     

    But please, could you execute the procedure I described above and say if it helps (remove utf from qa name and save it again with pure utf encoding)? This will not help with current case, but maybe in previous. Regarding me - it helps.

    Please shere the result.

    Posted

    Thanks

    Please login or register to see this link.

    4 hours ago, Łukasz997 said:

    If you are asking me?

    Not realy as it seems to be a Plua issue.

    But I have tested your proposal and will keep this for any futur needs.

     

    My issue is that due to the fact that some characters are not accepted and replaced just when loading in Plua an icon file type .png using:

    local function readFile(image)

    local rf =  assert(io.open(image, "r"))

    local data = rf:read("*all")
        rf:close()
        return data

    end

    The result is that the loaded file when transcoded in base64 is giving a totaly different string than using the site 

    Please login or register to see this link.

     causing the failure of uploading the image in my HC3

     

    Waiting for a possible fix from @jgab, I will first base64 encode the .png file using the above site and load this file in my QA but it is little more complex.

     

    3 hours ago, Łukasz997 said:

    (remove utf from qa name and save it again with pure utf encoding)

    I do not have any special utf character in my QA name (HomeTable), the issue was in  room and  device names like "Salle à manger": when triyng to recognize 'à' to replace it by 'a' I was getting the UTF-8 encode errror;  it seems that @jgab have fixed it in his last release.

    Posted

    I've done the experiment with resave on latest version, so I think it's not resolved.

    Prior to fix on the PLUA you may alse try url-ready version, I've done it sometimes just to work with custom events who hates +/=:

    Please login or register to see this code.

     

    • Like 1
    • 3 weeks later...
    Posted

    I'm starting to work on a battery integration via MQTT.
    I have been able to set-up a running test on my HC3, but it is not working in PLUA dev environment.

    Did anyone succeed with mqtt client already ?


    Here is my starting code:

     

    Please login or register to see this code.

     

    and here is the Debug Console...

     

    Please login or register to see this code.

     

    Seems the mqtt object is not available.

     

    Any hints to solve this or it is not supported yet ?
     

  • Topic Author
  • Posted
    4 hours ago, ClaudeH said:

    Seems the mqtt object is not available.

     

    Any hints to solve this or it is not supported yet ?
     

     

    the mqtt code had gone sour... I just pushed 1.2.56, let me know if it works better.

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