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)

Ok it is not a big deal if group action is not developped in fibemu (I can test with only one device if needed).

To try to turnOff all lights in a floor, I have changed the lightsOff function for this one:

function QuickApp:lightsOff()
    local lum = {}
    for i,k in ipairs(lamp[indx]) do
        lum[i]=tonumber(k)
        if fibaro.getValue(lum[i],"value") then print("Id: ",lum[i]," status:",fibaro.getValue(lum[i],"value"), " will be turnOff")
        fibaro.call(lum[i],"turnOff")
        print("Id",lum[i]," status:",fibaro.getValue(lum[i],"value"))
        end
    end
    print(json.encode(lum)) -- give  [502,502,502,502,502,410,410,388,389,187,463,464,311,54,50,80]
   -- fibaro.call(lum,"turnOff") nott working as call group action not developped in fibemu
    print("---- all lights off ----")
end
after the initial run of the QA it is working without any SYSWRN message but if I try again when running then the SYSWRN is back and the turnOff is not working as shown below:


[10.03.2024] [20:08:21] [DEBUG ] [QUICKAPP5000]: UIEvent:  {"type":"UIEvent","values":{},"deviceId":5000,"eventType":"onReleased","elementName":"sensors"}
[10.03.2024] [20:08:21] [DEBUG ] [QUICKAPP5000]: Id:  201  status: true  will be turnOff
[10.03.2024] [20:08:21] [SYSWRN] [onAction]: No action, QA declared local, ID:201
[10.03.2024] [20:08:21] [DEBUG ] [QUICKAPP5000]: Id 201  status: true

.../...

[10.03.2024] [20:08:21] [DEBUG ] [QUICKAPP5000]: Id:  32  status: true  will be turnOff
[10.03.2024] [20:08:21] [SYSWRN] [onAction]: No action, QA declared local, ID:32
[10.03.2024] [20:08:21] [DEBUG ] [QUICKAPP5000]: Id 32  status: true
[10.03.2024] [20:08:21] [DEBUG ] [QUICKAPP5000]: [201,346,330,502,502,430,430,431,322,181,75,386,182,363,32]
[10.03.2024] [20:08:21] [DEBUG ] [QUICKAPP5000]: ---- end all lightsOff() ----
if I restart the QA then the lights are switched of first time...
3 hours ago, jgab said:
3 hours ago, jgab said:

Please login or register to see this link.

In vscode, do Edit->Search in Files

and look for "will be" and see if it is in some log statement...

I have found which fibemu function is making this SYSWRN message:

Please login or register to see this attachment.

I relay don't know why my QA is local? How to change that?

 

Edited by Christb
  • Topic Author
  • Posted
    On 3/9/2024 at 1:42 PM, Christb said:

    I fact I had to again desinstall all application as I explained in a previous post.

    If some one in the forum is a specialist of Microsoft Windows / Visual Studio code can help me, I will be happy to know what I can do for protecting my vscode fibemu settings...

    I guess could be that you somehow disable or enable a python virtual environment (env) - sometimes vscode will pop-up a dialogue asking if it should create one. Also, there are vscode commands to select python interpreter(when running python it's even a button on the bottom status-bar of vscode)

    On 3/8/2024 at 1:03 PM, PeterV959 said:

    @jgab, a while back you provided a QA called ChildsPlay. It's a simple QA which creates a QwikAppChild class to allow child devices to have their own UI. I am trying to take that and use it by building up the simple child device into something I will use. When I run it on FibEmu it works fine (of course). But when I port it to the Z-Box hub (which is an HC3 or HCL device) the UIHandler can't find the methods in the class. I used swagger to examine the child device structure and the UI callbacks have been mangled by adding "ui" to the front and the event type to the end (but, of course, the event type onReleased is changed to OnReleased to make it camel case). Thus, the table of UI Callbacks stored in the child's QA Variables is one thing:

    Please login or register to see this link.

     

    but the callback found in the uiCallbacks sub-table becomes:

    Please login or register to see this link.

     

    So my question is:

     

    Am I wrong for overriding the QuickApp:UIHandler() method to redirect the UI Event? Or is there an update to this code which modifies the names being searched for to be more compliant with the way the HC3 handles this? FibEmu doesn't have the mangled names and works as expected. I am running version 5.150 on my hub.

     

    On a different note, is it not possible to add a property entry on the child QA? My device not only must turn on and off, but there is a speed setting (a value from 1 to 6), a direction of rotation setting (forward or reverse), and a sleep timer setting (a value, in minutes, for one 24 hour period), for my ceiling fan device. In FibEmu I can add these properties to the properties table but they are discarded on the hub.

     

    Thanks @jgab.

     

    Peter

    UIHandler would be the way to patch it. 

    No, we can't add new properties to devices - the HC3 has a (strict) schema checker for each device type.

  • Topic Author
  • Posted
    12 hours ago, Christb said:

    Ok it is not a big deal if group action is not developped in fibemu (I can test with only one device if needed).

    To try to turnOff all lights in a floor, I have changed the lightsOff function for this one:

    function QuickApp:lightsOff()
        local lum = {}
        for i,k in ipairs(lamp[indx]) do
            lum[i]=tonumber(k)
            if fibaro.getValue(lum[i],"value") then print("Id: ",lum[i]," status:",fibaro.getValue(lum[i],"value"), " will be turnOff")
            fibaro.call(lum[i],"turnOff")
            print("Id",lum[i]," status:",fibaro.getValue(lum[i],"value"))
            end
        end
        print(json.encode(lum)) -- give  [502,502,502,502,502,410,410,388,389,187,463,464,311,54,50,80]
       -- fibaro.call(lum,"turnOff") nott working as call group action not developped in fibemu
        print("---- all lights off ----")
    end
    after the initial run of the QA it is working without any SYSWRN message but if I try again when running then the SYSWRN is back and the turnOff is not working as shown below:


    [10.03.2024] [20:08:21] [DEBUG ] [QUICKAPP5000]: UIEvent:  {"type":"UIEvent","values":{},"deviceId":5000,"eventType":"onReleased","elementName":"sensors"}
    [10.03.2024] [20:08:21] [DEBUG ] [QUICKAPP5000]: Id:  201  status: true  will be turnOff
    [10.03.2024] [20:08:21] [SYSWRN] [onAction]: No action, QA declared local, ID:201
    [10.03.2024] [20:08:21] [DEBUG ] [QUICKAPP5000]: Id 201  status: true

    .../...

    [10.03.2024] [20:08:21] [DEBUG ] [QUICKAPP5000]: Id:  32  status: true  will be turnOff
    [10.03.2024] [20:08:21] [SYSWRN] [onAction]: No action, QA declared local, ID:32
    [10.03.2024] [20:08:21] [DEBUG ] [QUICKAPP5000]: Id 32  status: true
    [10.03.2024] [20:08:21] [DEBUG ] [QUICKAPP5000]: [201,346,330,502,502,430,430,431,322,181,75,386,182,363,32]
    [10.03.2024] [20:08:21] [DEBUG ] [QUICKAPP5000]: ---- end all lightsOff() ----
    if I restart the QA then the lights are switched of first time...

    I have found which fibemu function is making this SYSWRN message:

    Please login or register to see this attachment.

    I relay don't know why my QA is local? How to change that?

     

    The syswarn message is a bit erroneous,

    but what it tries to tell us is that neither 201 nor 32 are devices it knows about.

    They are not declared locally in fibemu or have been detected on the HC3.

    Normally, fibemu will read in all devices on the HC3 at start, but if there is no connection to the HC3 (or fibemu is run local) it will have no knowledge of what devices exists on the HC3.

    However, because it's not warning about the other devices I suspect that 201 and 32 does not exist on the HC3...?

    Posted (edited)
    5 hours ago, jgab said:

    The syswarn message is a bit erroneous,

    but what it tries to tell us is that neither 201 nor 32 are devices it knows about.

    They are not declared locally in fibemu or have been detected on the HC3.

    Normally, fibemu will read in all devices on the HC3 at start, but if there is no connection to the HC3 (or fibemu is run local) it will have no knowledge of what devices exists on the HC3.

    However, because it's not warning about the other devices I suspect that 201 and 32 does not exist on the HC3...?

    All the devices exist in the HC3 (the same lum table is used in the HC3 QA without any issue). I have not given the full log and all devices in the lum table are making the SYSWRN message but only if the result of the request fibaro.getValue(lum[i],"value") is true which demonstrate that the device exists.

     Also after each restart of the emulated QA, the lightsOff function switches all lights of the lum table without any SYSWRN message: after this successfull run, the same table is gving the SYSWRN message for ever and devices are not turned off.

    Do I have to declare that all lum devices are remote in the header? if yes, how I can do that?

     

    For your information, below is how I declare the devices and there positions in the main lua file:

    local lamp={}
    local lampPos={}
    lamp[1]={201,346,330,502,502,430,430,431,322,181,75,386,182,363,32} --
      lampPos[1]={{x=22,y=55},{x=90,y=55},{x=180,y=55},{x=280,y=55},{x=353,y=55},{x=23,y=115},{x=80,y=115},{x=60,y=150},{x=22,y=220},{x=80,y=220},{x=120,y=135},{x=185,y=110},{x=80,y=250},{x=290,y=220},{x=270,y=135}}
    lamp[2]={502,502,502,502,502,410,410,388,389,187,463,464,311,54,50,80}
       lampPos[2]={{x=25,y=50},{x=110,y=50},{x=182,y=50},{x=275,y=50},{x=350,y=50},{x=40,y=125},{x=100,y=115},{x=175,y=150},{x=185,y=150},{x=310,y=125},{x=65,y=220},{x=75,y=220},{x=182,y=250},{x=275,y=220},{x=320,y=220},{x=370,y=250}}
    lamp[3]={416,416,416,416,416,416,416,416,416}
      lampPos[3]={{x=350,y=40},{x=250,y=80},{x=125,y=150},{x=182,y=140},{x=300,y=145},{x=70,y=220},{x=150,y=200},{x=182,y=220},{x=300,y=220}}
    lamp[4]={195,195,195,195,195,329,329,329,329}
      lampPos[4]={{x=23,y=72},{x=182,y=30},{x=330,y=110},{x=23,y=180},{x=105,y=175},{x=175,y=165},{x=290,y=150},{x=316,y=163},{x=322,y=250}}
     
    6 hours ago, jgab said:

    I guess could be that you somehow disable or enable a python virtual environment (env) - sometimes vscode will pop-up a dialogue asking if it should create one. Also, there are vscode commands to select python interpreter(when running python it's even a button on the bottom status-bar of vscode)

    Thanks for the advice, I will try to look if anything happened before next time I will go in the same trouble with Python.

     

    Edited by Christb
    Posted (edited)
    2 hours ago, Christb said:

     

    Do I have to declare that all lum devices are remote in the header? if yes, how I can do that?

    I think I have corrected the issue in adding in the header   --%%remote=devices:*  and first tests show that now all "On" lights are turned "Off" for all floors and whatever the number of times the function lightsOff() runs. Will make further tests but I am confident that the problem is fixed and I have learnt few things from that.

    Sorry for the inconveniance caused.

    Edited by Christb
  • Topic Author
  • Posted
    5 hours ago, Christb said:

    I think I have corrected the issue in adding in the header   --%%remote=devices:*  and first tests show that now all "On" lights are turned "Off" for all floors and whatever the number of times the function lightsOff() runs. Will make further tests but I am confident that the problem is fixed and I have learnt few things from that.

    Sorry for the inconveniance caused.

    That should have been my first question - "Did you declare the devices remote?" :-) 

    Posted
    On 3/11/2024 at 2:59 AM, jgab said:

    No, we can't add new properties to devices - the HC3 has a (strict) schema checker for each device type.

    So this brings up what are the device properties used for with a QuickApp? Specifically the value and state properties. I see they are used for the device predefined UI states but can I not store a persistent value (i.e. one of my UI properties) in the class table? I don't need them to persist in the device structure since I retrieve them every time I poll my ceiling fan & light  (via an API call) to find out their current state. These two devices (which are a single entity on the physical device) can be controlled externally via a dedicated remote control and/or my virtual assistant (Alexa). So as I initialize the QA, I would be getting the current states and I could store them locally to the child classes without need for them to be in the device structure. It would appear that's what self.properties.value is doing behind the scenes. I can read the value property but must use a system call to write to it. So for my custom properties, I could just read and write them and forego the call to update the device memory table.

  • Topic Author
  • Posted (edited)

    Well, 

    self:updateProperty('value', true) do update the local copy in

    self.properties.value to true but it also updates the device structure with a 

    call to /plugins/updateProperty

     

    That last call generates an event (refreshState) and causes UI icons to change and other scenes/QAs to trigger on it, etc etc.

    So, storing a value in self.properties.value without the call to /plugins/updateProperty serves no real purpose and you could as well store the value in a QuickApp variable. 

     

    If another QA does a fibaro.getValue(<ID>,"value") it will get the value from the device structure and not what's stored in self.properties.value

     

    Edited by jgab
    Posted (edited)

    Dear Jgab,

     

    I have, I hope, finished the development of my QA Home Summary to have displayed temperature values and lights status of each floor of may house.

    Everything are working as expected but I have a debug message in the QA Console which means that some thing is not correct even if working:

    [13.03.2024] [19:25:54] [DEBUG] [QUICKAPP526]: custom [luabind::detail::null_type] object: (nil)

    In fibemu, I have also a message which I am sure is friom the same cause:

    [11.03.2024] [20:08:22] [DEBUG ] [QUICKAPP5000]: createMap indx: 1, curr: 12
    [11.03.2024] [20:08:22] [DEBUG ] [QUICKAPP5000]: [obj:SVG:2]
    [11.03.2024] [20:08:22] [DEBUG ] [QUICKAPP5000]: No grid

     

    I think that it is comming from the lines of codes about the orange rectangles I have added (with your help):

      local  curr = #tempDevices[indx]
    print("createMap indx: "..indx..", curr: " ..curr)
        self.temps = {}
      for i=1,curr do -- Christb: linked to number of devices
        local tempPos = tempPos[indx]
         --print(json.encode(tempPos)) -- OK but for debug only
          im:add(Rectangle{x=(tempPos[i].x)-2,y=(tempPos[i].y)-20,width="50",height="30",style="fill:orange;fill-opacity:0.5"}) -- added by Christb and OK
          self.temps[#self.temps+1] =
          im:add(Text{x=tempPos[i].x,y=tempPos[i].y,text=fmt('0.%d°',i),style='font-size:20', filter='url(%23rounded-corners)'})
      end

    I have not found where is the bug... Changing anything in that code is almost always making the QA to crash.

    Any idea?

     

    Attached the fqa files with the 2 icons I am using for it

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Edited by Christb
    Posted
    On 3/9/2024 at 1:42 PM, Christb said:

    I fact I had to again desinstall all application as I explained in a previous post.

    If some one in the forum is a specialist of Microsoft Windows / Visual Studio code can help me, I will be happy to know what I can do for protecting my vscode fibemu settings...

    Just loose again the Pyton in vscode.

    I know what is making this issue with python in vscode: a new Windows10 update but I have not yet found why.

    As previouly, Enviroment variables have the right path

    I can launch python 3.11 by itself.

    I have no other issue than desinsltall all application and restart full installation.

    Posted
    3 hours ago, Christb said:

    I have no other issue than desinsltall all application and restart full installation.

    I have been unable to have fibemu working with the installed Python 3.11 version even if the correct path is shown in the path Environment Variable: it is still not recognized in vscode as installed.

    For getting back a working fibemu, I install the Python extension for vscode and miracle every thing is back;  I have not seen any differences of behavior except fo the DEBUG CONSOLE which is not activated but everything are shown now in the TERMINAL window  as below:

    Please login or register to see this attachment.

    I am still searching for someone to help me about this issue of loosing Python configuration after a Windows10 update.

    Posted
    On 2/22/2024 at 8:39 AM, jgab said:

    Have you tried to set a short timeout, like 2-3s ?

    Hi Jan, Sorry for no reply on this topic, was away for some time and lot of other activities...
    Setting short timeout doesn't help. Exact same behaviour, not message / not response.

    I did a small Python code try and it works. But my code is synchronous --> may be this is where to troubleshoot...
     

    Please login or register to see this code.

     

  • Topic Author
  • Posted

    In the python code you only send "\n" at the end, in the Lua you sent "\r\n". Can the server be picky about that?

    If you check how many bytes you write

    Please login or register to see this code.

    do you get the same as you send.

     

    So I tested QA_tcp_test.lua against a python server that just sends back the string "ABC" and then closes the socket and that worked

    It received "ABC" but then QA_tcp_test.lua will end with a "send error:Bad file descriptor" because it's a loop expecting to echo back, but the socket is of course closed.

    Posted
    On 3/15/2024 at 1:52 PM, Christb said:

    I have been unable to have fibemu working with the installed Python 3.11 version even if the correct path is shown in the path Environment Variable: it is still not recognized in vscode as installed

    I have found a way to have vscode fibemu working as with the previous working installation unsing standard instllation of Python 3111 and without installing the Python vscode extension:

    I have just changed in all occurences of "command=python3" by "command=python" in "launch.json" file .

    I still have not undersood why I am loosing Python command after a Window OS update...

    Posted
    On 2/7/2024 at 9:10 PM, jgab said:

    Good, I believe that multi-root is the future for project setups...

    Dear @jgab, I am trying using the muti-root vscode feature (I go issue with my last git pull in loosing some of my files):

     I have been able to have 2 directories in my WORKSPACE and I have moved 1 QA with its combined files in the new directory \myDev:

    I am on Windows10.

    Please login or register to see this attachment.

    I have not yet found a way to load the 2 additional files which are in the same directory than QA_SVGTest_3.lua.

     

    Posted
    19 hours ago, Christb said:

    I have not yet found a way to load the 2 additional files which are in the same directory than QA_SVGTest_3.lua.

    I have found a way to have the QA loading the additional files --%%=SVG.lua... in moving the file from :

    D:\Mes_documents_perso\St_Loup\St_Loup_Travaux_et_Fournisseurs\Electricité\Domotique\Domotique_ST_Loup\HC3\myDev

    to:

    C:\Users\ASUS\Documents\myDev

    in fact it is now in the same directory than fibemu.

    This is a real issue for me as C:\ is almost full and I have a lot of disk space in D:\

     

    Is there a way to declare D:\Mes_Doc... in Vvscode in order to use another disk?

     

  • Topic Author
  • Posted

    This I tested on Win11.

    I have fibemu in C:\Users\jangabrielsson\Desktop\fibemu

    I have my development folder in Z:/test

    I add workspace 'fibemu' (from C:\Users\jangabrielsson\Desktop\fibemu)  to my development folder in vscode

    using "Add Folder to Workspace..." under "File"->

     

    In development folder I have QA AppTest importing SVG.lua from the fibemu/examples directory

    Please login or register to see this code.

    ....and it works... for me.

    Posted
    3 hours ago, jgab said:

    I add workspace 'fibemu' (from C:\Users\jangabrielsson\Desktop\fibemu)  to my development folder in vscode

    using "Add Folder to Workspace..." under "File"->

     

    In development folder I have QA AppTest importing SVG.lua from the fibemu/examples directory

    Please login or register to see this code.

    ....and it works... for me.

    Dear @jgab , is the order of creating folders is important? If I remember weel, I add the myDev floder to opened fibemu.

    Do I have to supress myDev form the workspace, close all, open myDev in vscode and then add fibemu to it?

    • 2 weeks later...
    Posted

    Hello,

    I've a question about QA web interface in VSC emulator: can the button be defined as "switch" in VSC (terminology from interface constructor of HC3 webpage)? I mean that he button has permanent on and off state
    Or it only can act as a regular button?

  • Topic Author
  • Posted
    28 minutes ago, Łukasz997 said:

    Hello,

    I've a question about QA web interface in VSC emulator: can the button be defined as "switch" in VSC (terminology from interface constructor of HC3 webpage)? I mean that he button has permanent on and off state
    Or it only can act as a regular button?

     

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