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

Yes it is working very well 😀

I have been able to create my first QA (ID700) 3 buttons switch and getting right information of its state in the UI. Able also to change some of its properties (value, manufacturer, log, userDesciption...).

I have created also another QA binary switch (ID 701) I want to be controled via my first QA (ID 700) : 701 permanently On or Off or scheduled On/Off.

Until now I have not be able find how having the 2 QA working simultaneously in ZeroBrane : what is the trick?

  • Topic Author
  • Posted (edited)

    Yes, you can do that.

    In your first QA (700) add this line in the beginning

     

    Please login or register to see this code.

     

    If you have the other QA's files open in ZeroBrane editor you can set break points there too and the debugger will stop in that QA's code.

    The other QA should not have the _=loadfile header...

    Of course you can load any number of QAs...

    1 minute ago, jgab said:

    Yes, you can do that.

    In your first QA (700) add this line in the beginning

     

    Please login or register to see this code.

     

    If you have the other QA's files open in ZeroBrane editor you can set break points there too and the debugger will stop in that QA's code.

    The other QA should not have the _=loadfile header...

    Of course you can load any number of QAs...

     

    Edited by jgab
    Posted (edited)

    I have been able to have the 2 QA visible on the web/main :

    Please login or register to see this image.

    /monthly_2023_10/image.png.fba15edd256a93d27ae1cbb536d40e67.png" />

    but I have a new error message in the output window:

    [02.10.2023] [21:26:43] |[33;1mSYS  |[0m [30mRunning offline[0m
    [30m[02.10.2023] [21:26:43] |[33;1mSYS  |[0m [30mUsing config file TQAEconfigs.lua[0m
    [30m[02.10.2023] [21:26:43] |[33;1mSYS  |[0m [30mCreated WebAPI at http://192.168.1.39:8976/web[0m
    [30m[02.10.2023] [21:26:43] |[33;1mSYS  |[0m [30msunrise 07:08, sunset 18:42[0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP701]: Start[0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP701]: [0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP700]: Start[0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP700]: [0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP701]: Inter Chauffeau 701[0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP701]: Ce QA repésente le switch contrôlant le chauffeau[0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP701]: Etat initial : Off[0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP700]: Test QA inter 700[0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP700]: Ce QA a pour objet de simuler un interupteur permettant de contrôler un automate comme un chauffeau[0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP700]: Etat initial : Off[0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP701]: onAction:  {"deviceId":701,"actionName":"turnOff","args":[]}[0m
    [30m[02.10.2023] [21:26:44] [[31;1mERROR[0m[30m] [QUICKAPP701]: modules\QuickApp.lua:38: callAction: No such method turnOff[0m
    [
    30m[02.10.2023] [21:26:49] [[31;1mDEBUG[0m[30m] [QUICKAPP701]: Etat actuel de l'interrupteur 701 : Off[0m
    [30m[02.10.2023] [21:26:49] [[31;1mDEBUG[0m[30m] [QUICKAPP700]: Etat actuel de l'interrupteur 700: Off[0m
    [30m[02.10.2023] [21:26:50] [[31;1mDEBUG[0m[30m] [QUICKAPP701]: Bouton On appuyé[0m
    [30m[02.10.2023] [21:26:50] [[31;1mDEBUG[0m[30m] [QUICKAPP701]: On[0m
    [30m[02.10.2023] [21:26:54] [[31;1mDEBUG[0m[30m] [QUICKAPP701]: Etat actuel de l'interrupteur 701 : On[0m
    [30m[02.10.2023] [21:26:54] [[31;1mDEBUG[0m[30m] [QUICKAPP700]: Etat actuel de l'interrupteur 700: Off[0m

     

    This error makes the id701 state not updated

    I have attache my 2 QA lua files just in cas you find an obvious error

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Edited by Christb
    hit send too fast
  • Topic Author
  • Posted
    10 hours ago, Christb said:

    I have been able to have the 2 QA visible on the web/main :

    Please login or register to see this link.

    but I have a new error message in the output window:

    [02.10.2023] [21:26:43] |[33;1mSYS  |[0m [30mRunning offline[0m
    [30m[02.10.2023] [21:26:43] |[33;1mSYS  |[0m [30mUsing config file TQAEconfigs.lua[0m
    [30m[02.10.2023] [21:26:43] |[33;1mSYS  |[0m [30mCreated WebAPI at http://192.168.1.39:8976/web[0m
    [30m[02.10.2023] [21:26:43] |[33;1mSYS  |[0m [30msunrise 07:08, sunset 18:42[0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP701]: Start[0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP701]: [0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP700]: Start[0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP700]: [0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP701]: Inter Chauffeau 701[0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP701]: Ce QA repésente le switch contrôlant le chauffeau[0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP701]: Etat initial : Off[0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP700]: Test QA inter 700[0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP700]: Ce QA a pour objet de simuler un interupteur permettant de contrôler un automate comme un chauffeau[0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP700]: Etat initial : Off[0m
    [30m[02.10.2023] [21:26:44] [[31;1mDEBUG[0m[30m] [QUICKAPP701]: onAction:  {"deviceId":701,"actionName":"turnOff","args":[]}[0m
    [30m[02.10.2023] [21:26:44] [[31;1mERROR[0m[30m] [QUICKAPP701]: modules\QuickApp.lua:38: callAction: No such method turnOff[0m
    [
    30m[02.10.2023] [21:26:49] [[31;1mDEBUG[0m[30m] [QUICKAPP701]: Etat actuel de l'interrupteur 701 : Off[0m
    [30m[02.10.2023] [21:26:49] [[31;1mDEBUG[0m[30m] [QUICKAPP700]: Etat actuel de l'interrupteur 700: Off[0m
    [30m[02.10.2023] [21:26:50] [[31;1mDEBUG[0m[30m] [QUICKAPP701]: Bouton On appuyé[0m
    [30m[02.10.2023] [21:26:50] [[31;1mDEBUG[0m[30m] [QUICKAPP701]: On[0m
    [30m[02.10.2023] [21:26:54] [[31;1mDEBUG[0m[30m] [QUICKAPP701]: Etat actuel de l'interrupteur 701 : On[0m
    [30m[02.10.2023] [21:26:54] [[31;1mDEBUG[0m[30m] [QUICKAPP700]: Etat actuel de l'interrupteur 700: Off[0m

     

    This error makes the id701 state not updated

    I have attache my 2 QA lua files just in cas you find an obvious error

    Please login or register to see this attachment.

    Please login or register to see this attachment.

     

    Your 701 functions are called QuickApp:MyTurnOn() and QuickApp:MyTurnOff()

    rename them to QuickApp:turnOn() and QuickApp:turnOff() that is the function you call, and the default for a binary switch

    onAction:  {"deviceId":701,"actionName":"turnOff","args":[]}

    • 2 weeks later...
    Posted

    I have been long to get back to you for feedback because I have worked hard to get to the right QA satisfying my objective.

    Even if the code may not be the most efficient, it is doing what I wanted, I may try to improve it later…

    To reach that I had to read first your posts from:

    Please login or register to see this link.

    Very comprehensive even I cannot understand all at the first reading but trying with the emulator help me to make progress. I even be able to get a proxy QA on my HC3 working well see below:

    Please login or register to see this image.

    /monthly_2023_10/image.png.d533ab89823cb2d99ea5bf01563b2b0a.png" />

    Question 1:  why on the emulator web UI  the labels of the QA 701 are not updated online following an action on QA 700? I need to refresh the page to have its status : TQAE limitation of bad coding from myself?

    Question 2: Why on the HC3 proxi QA the 2 buttons On/Off are shown on the top ?
     I don’t need them and they are conflicting with the buttons “Marche forcée” (turnOn) and “Arrêt” (turnoff).

    TQAE is a marvellous tool which prevent me to kill my Water Heater

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Posted (edited)

    For you information, This QA is intended to give following features for controlling my water heater:

    -Permanently OFF (Arrêt) - working OK

    -Permanently ON (Marche forcés) -Working OK

    -ON duringn night beetwen "Start Hour" (Commence à:) and "End Hour" (Se termine à:) but only when profile selected is "Home" or "Night", else permanently OFF   - Working OK

    - Possibility to change Start and End Hours via +h and -h buttons - Working OK

    I want know to have the profileClicked function to update the active profile so I modified the function as below:

     

    ---

    97    function QuickApp:profileClicked()
    98    curr = curr+1
    99    if curr > #data then curr=1 end
    100  Profil(self)
    101   update(self)
    102  --Ajout pour la MàJ de la HC3
    103             ID = tonumber(curr)
    104              fibaro.profile(curr,"activateProfile") --DEBUG error: test/Profil_HTML.lua:104: Wrong parameter type, number required. Provided param 'activateProfile' is type of string
    105              --fibaro.profile(ID)
    106             self:debug("ProfileCliqued -Activated profile "..ID)
    107   return ID              
    108   end

    ---

    When the line 104 is not a comment, I got the following error message when profile button is clicked but the QA is not killed:

    Please login or register to see this attachment.

     I found this fibaro call in your Supported functions (v0.33) that you are also using it in your QA ProfSched.fqa

    I did load it into my HC3 without any change but it is not working at all buttons inactive :

    Please login or register to see this image.

    /monthly_2023_10/image.png.c6e3132322931e12070dfe679906c847.png" /> and UI view is like : image.png.ec940d22cf21bdde87d90386bbe644c3.png

     

    What I have done WRONG!

    Edited by Christb
  • Topic Author
  • Posted
    On 10/14/2023 at 3:43 PM, Christb said:

    I have been long to get back to you for feedback because I have worked hard to get to the right QA satisfying my objective.

     

    Even if the code may not be the most efficient, it is doing what I wanted, I may try to improve it later…

     

    To reach that I had to read first your posts from:

    Please login or register to see this link.

     

    Very comprehensive even I cannot understand all at the first reading but trying with the emulator help me to make progress. I even be able to get a proxy QA on my HC3 working well see below:

     

     

     

    Please login or register to see this link.

    Question 1:  why on the emulator web UI  the labels of the QA 701 are not updated online following an action on QA 700? I need to refresh the page to have its status : TQAE limitation of bad coding from myself?

     

    Question 2: Why on the HC3 proxi QA the 2 buttons On/Off are shown on the top ?
     I don’t need them and they are conflicting with the buttons “Marche forcée” (turnOn) and “Arrêt” (turnoff).

     

    TQAE is a marvellous tool which prevent me to kill my Water Heater

     

    Please login or register to see this attachment.

    Please login or register to see this attachment.

     

    1., in TQAE there is no automatic update of the UI - a limitation - you need to reload. (in fibemu there is)

    2. The on/off buttons at the top is something the HC3 does for QAs - it renders its own built-in elements onto of the QA elements.  it's the same if you do a regular QA, like a binarySwitch. 

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

    For you information, This QA is intended to give following features for controlling my water heater:

    -Permanently OFF (Arrêt) - working OK

    -Permanently ON (Marche forcés) -Working OK

    -ON duringn night beetwen "Start Hour" (Commence à:) and "End Hour" (Se termine à:) but only when profile selected is "Home" or "Night", else permanently OFF   - Working OK

    - Possibility to change Start and End Hours via +h and -h buttons - Working OK

    I want know to have the profileClicked function to update the active profile so I modified the function as below:

     

    ---

    97    function QuickApp:profileClicked()
    98    curr = curr+1
    99    if curr > #data then curr=1 end
    100  Profil(self)
    101   update(self)
    102  --Ajout pour la MàJ de la HC3
    103             ID = tonumber(curr)
    104              fibaro.profile(curr,"activateProfile") --DEBUG error: test/Profil_HTML.lua:104: Wrong parameter type, number required. Provided param 'activateProfile' is type of string
    105              --fibaro.profile(ID)
    106             self:debug("ProfileCliqued -Activated profile "..ID)
    107   return ID              
    108   end

    ---

    When the line 104 is not a comment, I got the following error message when profile button is clicked but the QA is not killed:

    Please login or register to see this attachment.

     I found this fibaro call in your Supported functions (v0.33) that you are also using it in your QA ProfSched.fqa

    I did load it into my HC3 without any change but it is not working at all buttons inactive :

     and UI view is like

     

    Seems to be a bug in the documentation, it should be fibaro.profile("activateProfile",curr), e.g. the id as the last argument

  • Topic Author
  • Posted

    Just, to be clear.

    in QAs it's fibaro.profile(<action>,<id>)

    in Scenes it's fibaro.profile(<id>,<action>)

    ER is a QA so it should be the former. Why there is a difference only Fibaro knows...

    Posted

    Thanks for your replies and I will try "fibaro.profile(<action>,<id>)" in a new version.

    Meanwhile I have found a way to upgrade the HC3 profile using a http POST method when the profile button is clicked. Good learning process for to use this method👍

    The issue is that the QA is now showing my credentials so I will not publish it

    I may do when QA using "fibaro.profile(<action>,<id>)" will work.

     

    As you know, changing the profile on HC3 is making some actions defined in the Profile's table which is not accessible from the YUBII smartphone application.

     

    Do you think it will be possible to upgrade my QA with the following structure:

    One ParentQA with 2 buttons:

    Button1: allows changing Active profile

    Button2: toggles all its ChildQAs from Hidden to Visible (I will need for sure to reload the smartphone application)

    Alternatively on the same row: Button2 toggling name of ChidQAs and Button3 changing its visible status

     

    One ChildQA by device to control action which needs to be activated when the profile is changed

    l

    This will be equivalent to the Profile's Table but accessible on smartphone.

    • 4 weeks later...
    Posted (edited)

    For my project of simulating in the smartphone application the profiles action tables , TQAE has been a gorgeous tool for helping me to fulfil this new project.
    One of your posts was talking about metaTable: I have then created a function Meta(table) which is a marvellous debug tool to see what is the structure of a table (as json.encode).

    I have given up using QA children as this will have used more than a hundred of children and same number of device IDs. Also, it will have made very difficult to search in each QA in the main UI of the Yubii application.

    I have created a single QA called “Profile_Mgt” that allows to scroll profiles and create for each its table of Devices action. Each change needs a press on related button to prevent unwanted update.   

    The QA structure is:

    -        A button to get profiles from HC3 and save its profiles.device table

    -        A button to get a new table with only devices with action defined for this profile

    -        Scrolling these devices with display for each, index in table, name of devices, and action

    -        If device is a QA, then right button scrolls all buttons of the QA -in fact Arguments.

    -        Pressing the action buttons change the action (“turnOn”, “turnOff” or QA button id: args:[id])

    -        Press Validate to update the QuickVar profile device table

    -        When needed, upload to HC3 is feasible using top right button

    QA icon is changed according to the selected profile -user can select iconId in a table. It can accept English (lg="en") or French (lg="fr")

     

    This QA does not manage “scenes”, “partitions” and “climatZones” tables but now I know how to add them in this QA.

    For that, I will prefer to create 3 children QA for this purpose but I need your help:

    -        I have not yet been able to create a child QA in the TQAE

    -        I do not know if it is possible to web emulate a child UI and how

    Do you have written posts on the above subjects that can help me?

    Attached Profile_Mgt V5.2.lua file.

     

     

    Note that this code has been made ongoing and there are certainly lot of redundancies, non-usefull debug print :a large cleaning  process is needed...

     

     

    The QA looks like below in the smartphone :

     

    Please login or register to see this image.

    /monthly_2023_11/image.png.79d12ef5435f08df52a546041e051ee5.png" />

     

      

     

    Please login or register to see this attachment.

    Edited by Christb
  • Topic Author
  • Posted (edited)

    Ok, it's easy to create child devices with standard UIs - a bit trickier to get your own custom ui elements.

    Try this qa

    Please login or register to see this attachment.

    it relies on 2 helper files, 'child' and 'ui'.

    With those included you can do

    Please login or register to see this code.

     

    This creates 1 child device of type TestChild with it's own TestChildUI.

    You can define 3 items in the children table and 3 children will be created. They can have their own types and UIs

    The important part is the key, 'uid1' in this example, as they are the unique identifiers (uids) of the children.

    The self:initChildren will create children missing from the list (missing uids), and it will delete existing children not in the list.

    When you develop and need to change the ui of an existing child you just delete it and it will be recreated with the new UI you set.

     

    This works kind of ok in TQAE - the QA will still get the default UI element for the type - but have a check on the HC3/Yubii app how it will look in RL...

    Edited by jgab
    Posted

    Thank you for your reply

    I have found ui.lua in the TQAE "/lib" directory but cannot find child.lua

    I tried this:

    --FILES = child.lua,child;
    --FILES = ui.lua,UI

    but get this error

    [31;1mERROR[0m[30m] [SYSTEM]: modules\files.lua:58: No such file:D:\Mes documents perso\St Loup\St Loup Travaux & Fournisseurs\Electricité\Domotique\Domotique ST Loup\HC3\QA\Profile_Mgt v5.2.lua

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

    Thank you for your reply

    I have found ui.lua in the TQAE "/lib" directory but cannot find child.lua

    I tried this:

    --FILES = child.lua,child;
    --FILES = ui.lua,UI

    but get this error

    [31;1mERROR[0m[30m] [SYSTEM]: modules\files.lua:58: No such file:D:\Mes documents perso\St Loup\St Loup Travaux & Fournisseurs\Electricité\Domotique\Domotique ST Loup\HC3\QA\Profile_Mgt v5.2.lua

    No, the files are included in the TestChild.fqa and you need to copy them from there. The files in TQAE/lib are not up to date yet...

    Posted

    I have been able to load the TestChild.fqa into my HC3 and I have 2 devices: one parent with only the fibaro created on/off buttons  and one child with buttons B1 & B2 and one slider.

    I have copied and created files ui.lua and child.lua into a new TQAE project: they are now loaded without error but when lauching the QA iI am getting the following error:

    [ERROR  [QUICKAPP800]: modules\class.lua:198: Missing parent for TestChild.

    What I have missed? Looking into you code, I have not found where the parent is defined.

    attached TestChild_BC.lua

    Please login or register to see this attachment.

  • Topic Author
  • Posted

    Seems like you fail to load the child.lua file.

    The path in --%%FILE should not start with '/' as they are relative to the TQAE directory that you should have set as working directory.

    So

    --FILES = lib/child.lua,child;
    --FILES = lib/UI.lua,ui

     

    I have updated the TQAE repository now and there is 

    Please login or register to see this code.

     

    that play together. TestChild.lua should be runnable

    Posted
    23 hours ago, jgab said:

    that play together. TestChild.lua should be runnable

    Yes it is ! Thanks for your help.🙂

    Now I have to work for adding 2 another children and then change their UI;

    Will let you know the result

    • 4 weeks later...
    Posted

    Again, for this project of simulating the Profile page in the smartphone application, TQAE has been a gorgeous tool for helping me to fulfil this new project.
    One of your posts was talking about metaTable: I have then created a function Meta(table) which is a marvellous debug tool to see what is the structure of the table (as json.encode).

    I have, with your help, created 3 children QA for this purpose and everything seem to work.

    Mother QA and chidren icons are changing according to selected profile.

    You can program English or French Language.

    The only issue I have is that I have not been able to find a way to update children first label by the name of the selected profile in the mother QA. Using the “Child”:updateUI(name,id), the name and its Id are printed but when I want to use them in self:updateView I am getting this error message :

    ERROR: modules\QuickApp.lua:110: attempt to index a nil value (field '_view')
    see lines 402 to 404, 755 and 756 , 897.

    When pressing the first button of each chid QA, then the first label and first button are updated with the name and id….

    If, in the onInit(), I am launching the function that is used by the first button of the chid, I still have the same error message (lines 1522 to 1524)

     Is there a way to automatically update labels of children from mother data?

    For your information, I have seen that a function that was working in the TQAE for getting the value of a slider change was not working in the PROXY QA because then slider value is a table, not a string so I changed the code accordingly.

    Also, a strange thing is happening while the Profile_Mgt v6.6 is running but no action on the UI interface for a long time, I am getting the error message below:

    [08.12.2023] [16:59:30] [DEBUG] [QUICKAPP466]: ----- end fun ValProg -----
    [08.12.2023] [19:04:54] |ERROR|bad API call:modules\api.lua:160: attempt to concatenate a table value (local 'id')

    You can see around 2 hours between the last action and the error message.
    The QA and its children are still working when any button is activated

    Attached Profile_Mgt V6.6.lua file.

    Please login or register to see this attachment.

  • Topic Author
  • Posted

    So, your problem is that you in some places uses the class instead of self when calling methods on the child.

    The class object has the methods (functions) but not the instance variables (like ._vew) so it will crash when trying to use instance variables.

    In some of the updateUI you do that (sometimes).

    However, in the initialisation when calling the updateIU function for the children you need to fetch the created child objects.

    They are available in the QA's self.children table, indexed on the 'uid'

      self.children['uid1']:updateUI(Nom,ID) --   
      self.children['uid2']:updateUI(Nom,ID) --   
      self.children['uid3']:updateUI(Nom,ID) --   

    (that's why it may be useful to give the children some more descriptive uids...)

     

    Please login or register to see this spoiler.

     

  • Topic Author
  • Posted

    A bit annoying that we didn't get a good error message when the code failed. I have pushed an update to TQAE.lua where errors in :onInit is caught and logged.

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