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


fibaroExtra


jgab

Recommended Posts

Hi @jgab

I am trying to get your Icalendar to work.

I can get the entries, but when it trys to publish the custom event I keep getting this error:

Please login or register to see this code.

Can you point me in the right direction when you  have some time?

 

Jim

Link to comment
Share on other sites

  • Topic Author
  • 14 hours ago, jimicr said:

    Hi @jgab

    I am trying to get your Icalendar to work.

    I can get the entries, but when it trys to publish the custom event I keep getting this error:

    Please login or register to see this code.

    Can you point me in the right direction when you  have some time?

     

    Jim

    I'm a bit unsure what version of fibaroExtra was included in that iCal (it has changed a lot recently).
    You can try to go into the QA code on line ~208 and change

    Please login or register to see this code.

    to

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    Thanks @jgab

    after changing the code and updating the fibaroExtra the error is gone.

     

    Now after lots of trying it seems that in the latest FW on my box the custom events are broken...

    After a lot of trying I made a block scene that fires an event and one that respons to it..

    Anyone here where the custom events seem broken?

     

    **EDIT**

    Looks like this bug is still present:

    After deleting and recreating it works..

     

    Jim

    Edited by jimicr
    Link to comment
    Share on other sites

    • 3 weeks later...

     

    Hi

    It still worked with v0.950.

    Unfortunately it no longer works with the latest version fibaroExtra v0.955. So far it has worked.
    I thank you in advance.

     

    Please login or register to see this code.

    [30.01.2023] [16:41:00] [DEBUG] [QUICKAPP604]: fibaroExtra v0.955, ©[email protected]

    QuickApp crashed[30.01.2023] [16:41:00] [ERROR] [QUICKAPP604]: main.lua:203: attempt to call a nil value (field 'event')

    Edited by parip69
    Link to comment
    Share on other sites

  • Topic Author
  • 39 minutes ago, parip69 said:

     

    Hi

    It still worked with v0.950.

    Unfortunately it no longer works with the latest version fibaroExtra v0.955. So far it has worked.
    I thank you in advance.

     

    Please login or register to see this code.

    [30.01.2023] [16:41:00] [DEBUG] [QUICKAPP604]: fibaroExtra v0.955, ©[email protected]

    QuickApp crashed[30.01.2023] [16:41:00] [ERROR] [QUICKAPP604]: main.lua:203: attempt to call a nil value (field 'event')

    It doesn't work because the fibaroExtra is not loaded until you enter QuickApp:onInit()

    In the past you could be lucky and the fibaroExtra file was loaded before the main file, but there was no way I could guarantee that or control it.

    The way fibaroExtra now works is that all modules are loaded before QuickApp:onInit() is called.

     

    If you call

    fibaro.event(...)

    on top-level in your main file, the event functions are not yet added to fibaro.*

    The way to solve it is to setup your event listeners from within :onInit().

    Ex.

    Please login or register to see this code.

    In principle this what you need to do to use any functions from an additional QA file, as the load order can not be guaranteed. The only thing we know for sure is that when :onInit() is called, all files are loaded.

     

    @Neo Andersson had the same problem here

     

    Link to comment
    Share on other sites

  • Topic Author
  • Here is another good reason to define the event handlers in a common function.

    Please login or register to see this code.

    :event, :post, :cancel is defined for the QuickApp class too. This allow us to use 

    self:event(...) to define an event handler.

    If we pass 'self' to our function that defines the event handlers (main(self) in this case) we can use those instead.

    Also the Lua functions that are the defined actions can use 'self' functions (aka QuickApp functions). In this example self:debug. 

    Edited by jgab
    Link to comment
    Share on other sites

    I have an issue with fibaro.debug(3,"Suspected START smart motion event") even when debugFlag is set correctly in console there is silence. in TQAE and ZBS works great any ideas ?

    Link to comment
    Share on other sites

  • Topic Author
  • On 1/31/2023 at 5:28 PM, michalt said:

    I have an issue with fibaro.debug(3,"Suspected START smart motion event") even when debugFlag is set correctly in console there is silence. in TQAE and ZBS works great any ideas ?

    It was a bug - fixed in v0.956

    You are probably the only one that have used that feature - I forgot about it myself ;-)

    Maybe the fibaro.debug et.al has become a bit "overloaded"...

    Edited by jgab
    Link to comment
    Share on other sites

    16 godzin temu, jgab napisał:

    It was a bug - fixed in v0.956

    You are probably the only one that have used that feature - I forgot about it myself ;-)

    Maybe the fibaro.debug et.al has become a bit "overloaded"...

     

    Thanks, probably this is not essential feature, but for me it was useful to have levels for trace logs when working with event streams.

    Link to comment
    Share on other sites

    • 3 months later...

    Should enableQA be a PUT rather than a POST? However, if I redefine it to use PUT I got an error/crash in my (QuickerApp) child

     

    However, it isn't this function that is the problem but a problem related to my child UI code which I have not solved yet. 

     

    I am creating children from a lifx lamp controller. A colour lamp is using com.fibaro.colorcontroller as the device type and I add extra UI to allow the setting of fade time, saturation and kelvin white temperature - all using sliders. Example UI below. To do the hard work on the children I'm using fibaroExtra and the UI functions extracted from the @jgab older QA toolbox.

     

    Please login or register to see this attachment.

     

    if I declare my UI as {{label='labelF', text='Fade Time'}, {slider='fadeTime', text='Fade Time', onReleased='parseValueFade'}} then, following the child creation after using the UI toolbox functions I get a function in the child QA of:

     

    function QuickApp:uifadeTimeOnReleased(event)

    parseValueFade

    end

     

    The sliders work, but when the child is created the quickapp initially crashes with a syntax error at the line where the function is referenced. It also crashes when enableQA (with a put) is called.

     

    Alternatively. if I declare my UI as {{label='labelF', text='Fade Time'}, {slider='fadeTime', text='Fade Time', onReleased='parseValueFade()'}} then I get a function in the child QA of:

     

    function QuickApp:uifadeTimeOnReleased(event)

    parseValueFade()

    end

     

    no syntax errors but the sliders do not work and I get a "UI callback for element:", elm, " not found." from the UI handler in fibaroExtra.

     

    So, with the "correct" syntax in the child, so there are no child QA crashes,  the UI event handler in fibaroExtra does not find the callback function. If I change the UIHandler function (around line 1959 in version 0.960) to

          local ii = cb[elm][etyp] 

          if string.sub(ii, -2) == "()" then ii = string.sub(cb[elm][etyp],1, -3) end

          if cb[elm] and cb[elm][etyp] and obj[ii] then return obj:callAction(ii, event) end

     

    This just strips off the () on the end of the cb[elm][etyp] call back value, then it all works. It feels like a horrible hack to create the function reference from the stored callback string to get callAction to work. @jgab is there a more elegant way of doing this??

    Edited by James R
    updated description
    Link to comment
    Share on other sites

  • Topic Author
  • Ok, we are a bit on deep water here as adding custom UIs to children this way is not officially supported.

    ...but anyway.

    If I do

    Please login or register to see this code.

    using the UI.lua library instead of the older QA_toolbox from my repo
    ...then I get a child with a custom slider.
    Yes, the code generated for the child is buggy, but that code should not be looked at. Because we set the interface to "quickApp" the QA gets an "Edit" button in the web UI but that code is never loaded. All events that goes to a child device is sent to the parent of the child, in our case the main QA.

     

    Anyway, my main QA has id 1095 and the child has id 1098 and sliding the slider generates

    Please login or register to see this code.

     

    If you do something different, can you post a minimal example of creating a child that goes wrong for you...?

    Link to comment
    Share on other sites

    Thanks. I will take a look at UI.lua and check if that is doing anything different although it does look very similar to the toolbox functions  which combine everything together helpfully with makeInitialUIProperties.

     

    I appreciate this is pushing the boundaries on official support but it is incredibly useful. I was previously using a definition of a child with a custom UI (as in my first example below) that was working but generated syntax errors on init and when I called enableQA (and a local equivalent visibleQA which was very similar to your enable in fibaroiExtra). This annoyed me so my investigations showed that having a callback which was just e.g. parseValueFade is what was triggering the syntax error. Having parseValueFade() in the UI definition for the callback makes the child code run without errors but creates a problem when the UIhandler in fibaroExtra attempts to get the function value from the defined callbacks for callAction. This all seemed so close to a working solution and gave me error free child code, which seemed useful. To fix it I had the fibaroExtra UIhandler modification which removes the () to allow the function to be used in callAction. It works but it is a bit unsatisfactory as it is a text edit rather than an assignment of a function value. Lua is new to me so I was asking if there was a better way.

     

    Looking at your example above I think I'm doing more or less the same thing. My motivation was to use the foo() form of the callback instead of foo to create "clean" child code which does not throw errors.

     

    It may be deep water,  but helpful for some use cases. It allows fibaroExtra Quicker Children plus a simple UI table to generate child devices with a custom UI and support a controller/child device structure with class code all in the controller. The three sliders in my screenshot above  work well and can be updated if the separate lifx app makes change to a device - all via the parent controller.  It works for me! If only I could find a way to map foo() to foo so I don't feel like it is a text edit and more like a function reference.

    Edited by James R
    Link to comment
    Share on other sites

    I can avoid any modification of the fibaroExtra UIHandler by modifying the callback form (removing the () ) to be compatible with callAction after the children have been loaded or  created

    Edited by James R
    Link to comment
    Share on other sites

    • 1 month later...

    @jgab, I have explored using the UI.lua in your fibaroExtra library. It is doing what I want to do but I want to know if there's a means to lay out controls in the UI horizontally. When I use the HC3 gui I can add 1, 2, 3, 4, or 5 buttons on a single row. But I couldn't figure out how to make that happen with child devices. When I started down the path of using the UI.lua library I could create the buttons I want but they are stacked up one on top of the other. I am attaching a screenshot of what I am looking for (or something similar). I see in the code that there are about 7-8 controls available but I'm not sure how to go about using anything but buttons and labels. Originally I wanted to use a slider with six discrete positions but I struggled to make that work and that was without the UI.lua library. I guess the real question is, do you have documentation on the UI.lua library yet? I really it's unsupported by Fibaro and subject to breakage. This is, so far, just for my use but I may put it on github for this ceiling fan device.

     

    The code fragment I have working follows. It's fragile, and ragged, but I'm learning. In my sample I only created three buttons, not six, because I wanted to see what they looked like.

     

    Please login or register to see this code.

     

    Thanks for your patience in dealing with a newbie.

     

    Peter

    Please login or register to see this attachment.

    Edited by PeterV959
    clarification
    Link to comment
    Share on other sites

    Ok, never mind. I saw in your code that it's a table inside a table of the UI elements.

     

    One minor thing I've come across. When I use a com.fibaro.multilevelswitch there are two startLevelIncrease events associated with the increase & decrease level buttons. I think in the lib/ui.lua file around line 229 one of those Increases should be a decrease. Not a big deal, but it bothered my OCDness.

     

    Thank you.

    Link to comment
    Share on other sites

  • Topic Author
  • Thanks,  it should be

        {button='__sld', text="⇩",onReleased="startLevelDecrease"},
    sld as in start level decrease...

    pushed fix to GitHub

    Link to comment
    Share on other sites

    Ugh. I am still struggling with the UI. It works fine in the emulator but not in a QuickApp on my Z-Box hub. I believe the Z-Box is based on the Home Center Lite, not the Home Center 3. Is that my problem, perhaps? I am also running version 5.141 beta in my hub. The following code snippet is in a test QA, it has no child devices because I wanted to see what happens in the simplest case. It is of type com.fibaro.binarySwitch. I have installed the ui.lua file from github and version 9.60 of fibaroExtra. I have also tried to figure out how I can use a select (or multi?) and a switch. Haven't made that work in the emulator at all but that remnant is still here. At the very least I would expect to see two rows of three buttons.

     

    Please login or register to see this code.

     

    The only log output is

    Please login or register to see this code.

     

    What am I doing wrong?

    Edited by PeterV959
    more info
    Link to comment
    Share on other sites

  • Topic Author
  • I can confirm that it doesn't work with the "custom" elements.

    If you have an UI with just the label and the 6 buttons it works.

    The unsupported elements have always been a hit and miss... I usually can't save the code in the editor after I changed to unsupported elements (which could make it work for child devices as we don't need to edit/open their QAs)

    However, now I don't get the elements either now (they appear in the device struct's viewLayout but doesn't show).

     

    It could very well be that they have changed something since this was hacked

     

     

     

     

    Link to comment
    Share on other sites

    • 2 weeks later...

    Hi, I cant figure out how to set opp a sourcetrigger to exampel check state off 2 quickvars in the quickapp I am trying to make. 

     

     

    check quickvar1 is value=1 and quickvar2 is value=1 then trigger a method in the quickapp

     

     

    Would love to get an exampel on how to 😃

     

     

     

     

     

    Link to comment
    Share on other sites

  • Topic Author
  • Please login or register to see this code.

     

    Here we trigger on one variable and check the other... 

     

     

    Link to comment
    Share on other sites

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