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
12 minutes ago, Christb said:

I have forgotten to update fibemu first, now all working 😐

I still have an issue which I think is not related to --%%passThrough=<api.string> but to the format used to do the action

 

I am willing to limit the number of historical event to a maximum of 30 000 elements(**) in the HC3 table; using the Swagger , the command is 

API DELETE

Please login or register to see this code.

I tried:

api.delete("events/history?shrink="..maxBase)

where maxBase=30000

I do not get any error message back but the api command is ignored as I can see that the number of events is still increasing above 32000...

Any idea to help me?

 

(**) for your info, in the past I never get attention to the registered number of events in the history and got a hc3 database full which had the consequence of strange behavior of the HC3: for example, all my scenes were no more triggered by device action or events (QA still workin but low). Fibaro support cleared my database and advised me to clear very old events in history using the swagger.

I want to do the same automatically in a QA which is checking number of events and optionnaly limits all events (manualy or  regularely). It is now working excepted the shrink function which I am mentionning above.   

  • 2 weeks later...
Posted
On 7/23/2023 at 9:40 PM, jgab said:

......

 

The file is available in the fibemu directory ./examples/backup.lua

 

Here is a problem I don't understand. Vanilla installation from today, so latest version of backup.lua

 

Please login or register to see this code.

 

That's strange because line 20 works fine, after I commented out line 19.

 

fibemu.pyhooks.io.open is nil, too.

 

Any suggestions? Thanks for the great work, as usual!

 

/jayrock

  • Topic Author
  • Posted
    43 minutes ago, jayrock said:

     

    Here is a problem I don't understand. Vanilla installation from today, so latest version of backup.lua

     

    Please login or register to see this code.

     

    That's strange because line 20 works fine, after I commented out line 19.

     

    fibemu.pyhooks.io.open is nil, too.

     

    Any suggestions? Thanks for the great work, as usual!

     

    /jayrock

    It was an old example that was not updated.

    To get access to all Lua functions (ex. io.*) you need to set the directive

    --%%fullLua=true

     

    There was also an issue with the statement

    QAs = {QAs) 

    that was removed.

     

    I have updated the example and pushed it to GitHub 

    • Thanks 1
    Posted
    On 6/27/2023 at 10:46 AM, jgab said:

    Please login or register to see this code.

    Any plans to implement mqtt?

     

    I'm a heavy user and volunteer to test.

     

    Thanks,

     

    /jayrock

  • Topic Author
  • Posted
    6 hours ago, jayrock said:

    Any plans to implement mqtt?

     

    I'm a heavy user and volunteer to test.

     

    Thanks,

     

    /jayrock

    Yes, it's kind of prepared for it... may have a look at it this weekend.

    Posted
    3 hours ago, jgab said:

    Yes, it's kind of prepared for it... may have a look at it this weekend.

    Awesome, thanks!

  • Topic Author
  • Posted
    16 hours ago, jayrock said:

    Awesome, thanks!

    Ok, I pushed a version with first support for mqtt.

    It can run this code

    Please login or register to see this code.

    However, I don't handle any connection options at the moment.

    Posted
    3 hours ago, jgab said:

    Ok, I pushed a version with first support for mqtt.

    It can run this code

    Please login or register to see this code.

    However, I don't handle any connection options at the moment.

     

    This is my connect code, which works on the real HC3 machine:

     

    Please login or register to see this code.

     

    Doesn't work for me yet, I get

    Please login or register to see this code.

    , which does not make sense because I'm using an IP address anyway. Same if I remove all the options, I'd expect the connection to be rejected but not getaddinfo failed. 

     

    FWIW, a Python client on the same machine works fine with paho-mqtt 2.1.0.

     

    I'll keep investigating.

     

     

  • Topic Author
  • Posted
    18 minutes ago, jayrock said:

     

    This is my connect code, which works on the real HC3 machine:

     

    Please login or register to see this code.

     

    Doesn't work for me yet, I get

    Please login or register to see this code.

    , which does not make sense because I'm using an IP address anyway. Same if I remove all the options, I'd expect the connection to be rejected but not getaddinfo failed. 

     

    FWIW, a Python client on the same machine works fine with paho-mqtt 2.1.0.

     

    I'll keep investigating.

     

     

    Remove the port from the url.

    Default is 1883 for mqtt. If you need another port set it in the options.  

    {clientId=tostring(self.id), username="user", port=1883, password = "pw", keepAlivePeriod=keepAlivePeriodSeconds})

    Posted
    29 minutes ago, jgab said:

    Remove the port from the url.

    Default is 1883 for mqtt. If you need another port set it in the options.  

    {clientId=tostring(self.id), username="user", port=1883, password = "pw", keepAlivePeriod=keepAlivePeriodSeconds})

    That did the trick, thank you!

    • 2 weeks later...
    Posted (edited)

    hi @jgab,

    I have developped using vscode a QA for verifying battery level with lot of visual effects (icon, image showing battery level; image of the QA UI attached)

    The emulated QA is now working very well and is stable since a while now. So I upload it into my HC3 and it started as expected EXCEPT that the QA is resetting regularly (between 5 to 190s) with NO error message as you can see in the copy of the HC3 Console:

    [11.06.2024] [09:07:43] [DEBUG] [QUICKAPP554]: ====================================================================================================

    [11.06.2024] [09:07:43] [DEBUG] [QUICKAPP554]: ================================= QA reading local variables ======================================

    [11.06.2024] [09:07:43] [DEBUG] [QUICKAPP554]: ------- QA - version v 5.6 , Check Battery Device 554 Id: 554 --------

    [11.06.2024] [09:07:43] [DEBUG] [QUICKAPP554]: ----- end updateUI() -----

    [11.06.2024] [09:07:44] [DEBUG] [QUICKAPP554]: ----- getSelectedBatteryDevices() end -----

    [11.06.2024] [09:07:44] [DEBUG] [QUICKAPP554]: ----- getSelectedBatteryDevices() end -----

    [11.06.2024] [09:07:44] [DEBUG] [QUICKAPP554]: ----- getSelectedBatteryDevices() end -----

    [11.06.2024] [09:07:46] [DEBUG] [QUICKAPP554]: ----- checkBatteryDevices() end -----

    [11.06.2024] [09:07:46] [DEBUG] [QUICKAPP554]: ----- takeFromBattTable() end -----

    [11.06.2024] [09:07:46] [DEBUG] [QUICKAPP554]: ----- updateData() end -----

    [11.06.2024] [09:07:46] [DEBUG] [QUICKAPP554]: line 398 - nbMaxDevice: 35 , indx 1

    [11.06.2024] [09:07:46] [DEBUG] [QUICKAPP554]: line 417 - current device data: 101 , Room Vestibule , Name 101 Porte Vestibule , bat_type AAA , bat_pcs 2 , battLevel 65 , dev_name 2,8,2,0,0,8,1,5 , dev_type com.fibaro.doorSensor , Price 1.0 Hank , soft: 3,4,34 , recharge: false

    [11.06.2024] [09:07:46] [DEBUG] [QUICKAPP554]: ----- iconLevel() -----

    [11.06.2024] [09:07:46] [DEBUG] [QUICKAPP554]: ----- updateIcon() -----

    [11.06.2024] [09:07:48] [DEBUG] [QUICKAPP554]: line 398 - nbMaxDevice: 35 , indx 1

    [11.06.2024] [09:07:48] [DEBUG] [QUICKAPP554]: line 417 - current device data: 101 , Room Vestibule , Name 101 Porte Vestibule , bat_type AAA , bat_pcs 2 , battLevel 65 , dev_name 2,8,2,0,0,8,1,5 , dev_type com.fibaro.doorSensor , Price 1.0 Hank , soft: 3,4,34 , recharge: false

    [11.06.2024] [09:07:48] [DEBUG] [QUICKAPP554]: ----- iconLevel() -----

    [11.06.2024] [09:07:48] [DEBUG] [QUICKAPP554]: ----- updateIcon() -----

    [11.06.2024] [09:07:48] [DEBUG] [QUICKAPP554]: Next refresh :86400.0s, i.e.: 1440mn, or 24h

    [11.06.2024] [09:07:48] [DEBUG] [QUICKAPP554]: line 1551 -> Start loop3

    [11.06.2024] [09:07:49] [DEBUG] [QUICKAPP554]: --------- line 1584 end checkChange() next loop3 in 120s -------

    [11.06.2024] [09:07:49] [DEBUG] [QUICKAPP554]: ------- end b31() Refresh --------

    [11.06.2024] [09:07:49] [DEBUG] [QUICKAPP554]: line 1551 -> Start loop3

    [11.06.2024] [09:07:49] [DEBUG] [QUICKAPP554]: --------- line 1584 end checkChange() next loop3 in 120s -------

    [11.06.2024] [09:07:49] [DEBUG] [QUICKAPP554]: ---- on Init end -----

    [11.06.2024] [09:09:23] [DEBUG] [QUICKAPP554]: ====================================================================================================

    [11.06.2024] [09:09:23] [DEBUG] [QUICKAPP554]: ================================= QA reading local variables ======================================

    [11.06.2024] [09:09:24] [DEBUG] [QUICKAPP554]: ------- QA - version v 5.6 , Check Battery Device 554 Id: 554 --------

    [11.06.2024] [09:09:24] [DEBUG] [QUICKAPP554]: ----- end updateUI() -----

    [11.06.2024] [09:09:25] [DEBUG] [QUICKAPP554]: ----- getSelectedBatteryDevices() end -----

    [11.06.2024] [09:09:25] [DEBUG] [QUICKAPP554]: ----- getSelectedBatteryDevices() end -----

    [11.06.2024] [09:09:25] [DEBUG] [QUICKAPP554]: ----- getSelectedBatteryDevices() end -----

    [11.06.2024] [09:09:26] [DEBUG] [QUICKAPP554]: ----- checkBatteryDevices() end -----

    [11.06.2024] [09:09:27] [DEBUG] [QUICKAPP554]: ----- takeFromBattTable() end -----

    [11.06.2024] [09:09:27] [DEBUG] [QUICKAPP554]: ----- updateData() end -----

    [11.06.2024] [09:09:27] [DEBUG] [QUICKAPP554]: line 398 - nbMaxDevice: 35 , indx 1

    [11.06.2024] [09:09:27] [DEBUG] [QUICKAPP554]: line 417 - current device data: 101 , Room Vestibule , Name 101 Porte Vestibule , bat_type AAA , bat_pcs 2 , battLevel 65 , dev_name 2,8,2,0,0,8,1,5 , dev_type com.fibaro.doorSensor , Price 1.0 Hank , soft: 3,4,34 , recharge: false

    [11.06.2024] [09:09:27] [DEBUG] [QUICKAPP554]: ----- iconLevel() -----

    [11.06.2024] [09:09:27] [DEBUG] [QUICKAPP554]: ----- updateIcon() -----

    [11.06.2024] [09:09:29] [DEBUG] [QUICKAPP554]: line 398 - nbMaxDevice: 35 , indx 1

    [11.06.2024] [09:09:29] [DEBUG] [QUICKAPP554]: line 417 - current device data: 101 , Room Vestibule , Name 101 Porte Vestibule , bat_type AAA , bat_pcs 2 , battLevel 65 , dev_name 2,8,2,0,0,8,1,5 , dev_type com.fibaro.doorSensor , Price 1.0 Hank , soft: 3,4,34 , recharge: false

    [11.06.2024] [09:09:29] [DEBUG] [QUICKAPP554]: ----- iconLevel() -----

    [11.06.2024] [09:09:29] [DEBUG] [QUICKAPP554]: ----- updateIcon() -----

    [11.06.2024] [09:09:29] [DEBUG] [QUICKAPP554]: Next refresh :86400.0s, i.e.: 1440mn, or 24h

    [11.06.2024] [09:09:29] [DEBUG] [QUICKAPP554]: line 1551 -> Start loop3

    [11.06.2024] [09:09:30] [DEBUG] [QUICKAPP554]: --------- line 1584 end checkChange() next loop3 in 120s -------

    [11.06.2024] [09:09:30] [DEBUG] [QUICKAPP554]: ------- end b31() Refresh --------

    [11.06.2024] [09:09:30] [DEBUG] [QUICKAPP554]: line 1551 -> Start loop3

    [11.06.2024] [09:09:30] [DEBUG] [QUICKAPP554]: --------- line 1584 end checkChange() next loop3 in 120s -------

    [11.06.2024] [09:09:30] [DEBUG] [QUICKAPP554]: ---- on Init end -----

     

    Is there a way to stop a QA without suppressing it of the HC3 list of device? Needed in order to prevent overloading HC3 with these QA restarts, until I found where is the problem.

     

    Is there a way to have more debug information in the HC3 console?

     

    Comment on 12/06/2024 : I have tested the QA without any function except the starting debug message and QuickApp:updateUI() function and the QA is still restarting by itself without any error message!

    function QuickApp:updateUI() --show at startup what will be displayed with data replaced by a red question mark
      self:updateView("slct01","text",Lang.confirmChange)
      self:updateView(
    "Label1","text",sy.battery.." "..sy.question.."["..sy.question.."] "..sy.question.." ("..sy.question..")" )
      self:updateView("Label2","text",sy.battery.." "..sy.question.." x 0 @ 0 "..currency)
      self:updateView("Label3","text",sy.new_sign..Lang.replacement..sy.month.." "..sy.question)
      self:updateView("Label4","text",sy.refresh..Lang.refresh..cHM.." "..sy.question)
      self:updateView("Label6","text",sy.in_envelope..sy.off.." - "..sy.package..sy.id_sign.." - "..sy.rewind..sy.ffwd.." x 1")
      self:updateView('Label7','text',sy.package..sy.question..Lang.first..sy.refresh)
      self:updateView("Label8","text",sy.package.." "..sy.question)
      self:updateView("Label10","text",sy.factory.." "..sy.question..sy.question.." - "..sy.cd.." "..sy.question)
      self:updateView("Label11","text",sy.battery.." "..sy.question..Lang.first..sy.refresh)
      self:updateView("Label12","text",sy.battery.. "Type "..sy.question..", "..Lang.price..sy.question..currency)
      self:updateView("slct01","options",{{text=Lang.Choice1,type='option',value=1},{text=Lang.Choice2,type='option',value=2},{text=Lang.Choice3,type='option',value=3}})  
            courriel=sy.in_envelope..sy.off
        print("----- end updateUI() -----")
     return courriel
    end

     

    Please login or register to see this attachment.

    Edited by Christb
    new tests done
  • Topic Author
  • Posted

    This is tricky - usually it means a code crash but it's not caught by the Lua environment and just becomes a silent restart.

    It used to happen to if a setTimeout function crashed, but that is fixed now.

    Are you doing some http calls?

    If you post me the QA I could have a look and see if I it has the same issue on my box and if I can find it.

     

    Posted (edited)
    On 6/13/2024 at 9:02 AM, jgab said:

    Are you doing some http calls?

    If you post me the QA I could have a look and see if I it has the same issue on my box and if I can find it.

     

    I do not use http calls.

    I have made some more testing and found the following:

    - the QA is still resetting by itself event when no function is activated, I can only see the UI defined in the --%%u= declarations.

    - I have created the same UI view using the HC3 editor and then paste the code in it and add the IMAGES file and it is perfectly working without any reset since one day.

     

    I have not finished to test all funtions of the new HC3 QA but I confident that this new created from scrtach is stable1.

     

    I have attached in a zip file: the QA_BatteryCheck.lua vscode (with the 11 images that are needed to create the _IMAGES file), the Check_Battery_from_vscode.fqa (which resets itself)  and the new one created with HC3 UI editor (Battery_Check_from_HC3.fqa, which seems to be OK).

    Note that during the creation of the QA using the HC3 editor, I have restructured the presentation of the code but not really change function roles.

    I have not been able to find any difference that may cause the problem.

    My feeling is that during the Run task process of QA,upload or QA,update there is something going wrong but as I am still a learner and this may not be right.

     

     

    Note 1: the only remaining issue I have is that, for the selector, self:updateView("slct01","options",{... ...}) is not working in the HC3 but is OK in web view of fibemu - needed for having translation of options names.

     

    Please login or register to see this attachment.

    Edited by Christb
    Posted
    53 minutes ago, Christb said:

    I have attached in a zip file:

    I have forgotten to add in the zip file the user manual I have prepared for this QA. It is not completly update with the latest code but explain the purpose of it and how to configure it

    Please login or register to see this attachment.

    Posted (edited)
    2 hours ago, Christb said:

    Note 1: the only remaining issue I have is that, for the selector, self:updateView("slct01","options",{... ...}) is not working in the HC3 but is OK in web view of fibemu - needed for having translation of options names.

     

    Ok I have found a way to have selector position translated in HC3 language  and I have discovered that in fibemu :

    self:updateView("slct01","options",{{text=Lang.Choice1,type='option',value=1},{text=Lang.Choice2,type='option',value=2},{text=Lang.Choice3,type='option',value=3}})  

    is working but not in HC3 ; the correct command has to be :

    self:updateView("slct01","options",{{text=Lang.Choice1,type='option',value="1"},{text=Lang.Choice2,type='option',value="2"},{text=Lang.Choice3,type='option',value="3"}})

    value field has to be a string.

    Edited by Christb
    Posted
    On 6/13/2024 at 9:02 AM, jgab said:

    This is tricky - usually it means a code crash but it's not caught by the Lua environment and just becomes a silent restart

     

    Dear @jgab, I have made other tests and now I think that, if you upload the QA_BatteryCheck.lua file from vscode to your HC3, it may not restart by itself 😁
    but the Check_Battery_from_vscode.fqa may still do it.

    I just made my vscode totally similar to the HC3 QA and upload it into my HC3 => gives a stable QA 🙂 but (only) the 2 "setInterval" for loop() and loop3() are not working 😟.

    They are both working in the fibemu emulated QA, in Check_Battery_from_vscode.fqa and in Battery_Check_from_HC3.fqa.

    Also, all my trials to "update" the 554 QA with the same code does not fix the reset issue.

    I remember that the resets started after I have changed the first "Button01" by a selector "slct01" and I think it is when the gluch was introduced:

    At that time for doing it I did change the --%% lines as below:

     

    Please login or register to see this attachment.

     

    I have the feeling that fibemu run the code without taking care of the --[[ %%u= ...  ]]-- line but the task QA,update process may send to the HC3 something strange which makes the reset.

    I did suppress later the --[[ %%u={button='Button01', text='Confirm Change', onReleased='b01'} --]]-- but always using QA,update process.

    Is restart may comme from the --[[%%u=..]]--  line?

    What can be the reason for the 2 "setInterval" not working when the vscode is uploaded in HC3 but OK in fibemu and OK when created directly in HC3?

     

    • 1 month later...
    Posted

    Dear @jgab,

    coming back to my QA development for getting the number of history events in my HC3: it is working now as expected but only using https calls (api.get is giving a 500 error when history period is over 10 days).
    The time to get a response from HC3 can be up to 5minutes and during this period, the localhost:5004/frontend is disconnected around every 30s  and in the example below, I am getting this DEBUG  CONSOLE:

    Please login or register to see this attachment.

     

    Is there a way to increase the timeout for the refreshStates loop?

    I will be happy to have a lua command line for changing this timeout temporarily for this special QA: is this possible?

     

    • 2 weeks later...
  • Topic Author
  • Posted
    On 7/17/2024 at 8:42 PM, Christb said:

    Dear @jgab,

    coming back to my QA development for getting the number of history events in my HC3: it is working now as expected but only using https calls (api.get is giving a 500 error when history period is over 10 days).
    The time to get a response from HC3 can be up to 5minutes and during this period, the localhost:5004/frontend is disconnected around every 30s  and in the example below, I am getting this DEBUG  CONSOLE:

    Please login or register to see this attachment.

     

    Is there a way to increase the timeout for the refreshStates loop?

    I will be happy to have a lua command line for changing this timeout temporarily for this special QA: is this possible?

     

    Could add it as a configurable option. Noted it I my todo list.. for next release

    • 2 months later...
    Posted

    There is a lot information in this topic and watched the video, but I miss something. :( If it is already discussed than sorry :)

     

    1. I must run the task: update QA from the file explorer menu, but where? If I run it from the command pallette I get:

    Traceback (most recent call last):
      File "/Users/joep/Documents/dev/fibemu-vscode/.vscode/emufiles/__init__.py", line 57, in <module>
        if path.exists(c):
           ^^^^^^^^^^^^^^
      File "<frozen genericpath>", line 19, in exists
    TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

     

    2. And in your video on YouTube I see you have the HC3 log in vscode, how do you do it? I don't see this option in the output panel.

     

    3. Is it possible to update only the code? not the vars or other stuff? only code from the file you work in, so if I have 2 files, it updates the name in the HC3 with the corresponding file name. For example main.lua updates main in hc3, and joeplib.lua updates joeplib in hc3. But only code. Now I copy and paste, but if I can update with a keypress that should be great.

  • Topic Author
  • Posted
    21 hours ago, Joep said:

    1. I must run the task: update QA from the file explorer menu, but where? If I run it from the command pallette I get:

    Traceback (most recent call last):
      File "/Users/joep/Documents/dev/fibemu-vscode/.vscode/emufiles/__init__.py", line 57, in <module>
        if path.exists(c):
           ^^^^^^^^^^^^^^
      File "<frozen genericpath>", line 19, in exists
    TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

    You run the tasks from the Command Palette (Shift-Cmd-P on a Mac). There you run Tasks: Run Tasks: ....and there is the QA tasks...

     

     

    21 hours ago, Joep said:

    2. And in your video on YouTube I see you have the HC3 log in vscode, how do you do it? I don't see this option in the output panel.

    It logs in the Debug Console (not the Terminal). That's nothing special that I have set up - should work like that when you do a Lua print... Are you using the launch.js and tasks.json files provided with fibemu?

     

    21 hours ago, Joep said:

     

    3. Is it possible to update only the code? not the vars or other stuff? only code from the file you work in, so if I have 2 files, it updates the name in the HC3 with the corresponding file name. For example main.lua updates main in hc3, and joeplib.lua updates joeplib in hc3. But only code. Now I copy and paste, but if I can update with a keypress that should be great.

    From the fibEmu.pdf

    Please login or register to see this code.

    so if you precede the ID with '-' it willl not update the quickAppVars.

    It will however update all the lua files every time.

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