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


  • 0

Quick App - Starting to translate simple VD to QA


Juanjo
 Share

Question

Hi!

I have been trying to migrate a very simple VD from my HC2 to my new HC3 but the truth is that I am having a hard time understanding the new operation of the QA. The VD have one ON button and another OFF, to activate and deactivate some scenes and to change the VD icon (to know if it is activated or not).

 

Here you can see it:

Please login or register to see this image.

/monthly_2021_03/247803022_Capturadepantalla2021-03-07alas18_56_13.png.a34f924adffd91313c835ecc6020185a.png" />

 

And for each button this is the LUA code:

174308524_Capturadepantalla2021-03-07alas18_57_11.png.839c99f5d3dc7ad9f80b641af3ce5813.png

 

As you can see is very very simple:

- If push ON button: scenes enabled and icon in color

- If push OFF button: scenes disabled and icon in grey

 

This is the QA that I'm trying to create,  but the truth is that it does not work and I think I am not doing it well. The code is only for button ON, OFF is easy when other work:

Please login or register to see this attachment.

 

The code is this:

 

function QuickApp:onInit()
    self:debug("onInit")
end
 
function QuickApp:OnButton()
-- fibaro:setSceneEnabled(94, true);
    self:setSceneEnabled(94true)
    self:debug("Scene 94: ENABLE")
 
-- fibaro:setSceneEnabled(95, true);
    self:setSceneEnabled(95true)
    self:debug("Scene 95: ENABLE")
end
 

These are the errors it shows me:

[07.03.2021] [19:34:38] [DEBUG] [QUICKAPP914]: onInit
[07.03.2021] [19:34:42] [TRACE] [QUICKAPP914]: UIEvent: {"elementName":"OnButton","values":[null],"eventType":"onReleased","deviceId":914}
[07.03.2021] [19:34:42] [DEBUG] [QUICKAPP914]: ./include/main.lua:20: attempt to call a nil value (field 'setSceneEnabled')
[07.03.2021] [19:34:42] [ERROR] [QUICKAPP914]: QuickApp crashed
[07.03.2021] [19:34:42] [ERROR] [QUICKAPP914]: Unknown error occurred: handleJsonRpc

 

Could you help me to see if I'm on the right track or I'm completely wrong?

 

Of course, icon settings are missing because I haven't been able to find how to set them.

 

Thanks a lot!

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

@Juanjo

Please login or register to see this code.

 

iconID is the number of the icon on your HC3

 

Please login or register to see this code.

 

sceneID is the number of your scene 

 

 

Edited by SmartHomeEddy
  • Like 1
Link to comment
Share on other sites

  • 0
  • Inquirer
  • Hi @SmartHomeEddy,

     

    I have tried this code:

    function QuickApp:onInit()
        self:debug("onInit")
    end
     
    function QuickApp:OnButton()
        fibaro.setSceneEnabled(145,true)
        self:debug("Scene 145: ENABLE")
    end

     

    This is the scene I'm trying to enable:

    Please login or register to see this image.

    /monthly_2021_03/1989139048_Capturadepantalla2021-03-08alas21_21_27.png.8ce0838c43a7fd646676ee01716ff502.png" />

     

    But I have this errors:

    [08.03.2021] [21:17:00] [DEBUG] [QUICKAPP914]: onInit

    [08.03.2021] [21:17:50] [TRACE] [QUICKAPP914]: UIEvent: {"eventType":"onReleased","elementName":"OnButton","values":[],"deviceId":914}

    [08.03.2021] [21:17:50] [DEBUG] [QUICKAPP914]: ./include/main.lua:19: attempt to call a nil value (field 'setSceneEnabled')

    [08.03.2021] [21:17:50] [ERROR] [QUICKAPP914]: QuickApp crashed

    [08.03.2021] [21:17:50] [ERROR] [QUICKAPP914]: Unknown error occurred: handleJsonRpc

     

    What am I doing wrong?

     

    On the other hand I have tried to load the icons but the QA does not allow to add any icon.

    1789759193_Capturadepantalla2021-03-08alas21_27_16.png.22d814777d750d53372141a4e29860a6.png

     

    Is there any other way to upload them to get the ID?

     

    As always, thank you very much for your help. Beginnings are always difficult :)
     

     

     

     

    Link to comment
    Share on other sites

    • 0
    22 hours ago, Juanjo said:

    Is there any other way to upload them to get the ID?


    upload your icons with any other device. Then lookup the number, for example with right mouse and “save as”. 

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • @SmartHomeEddy

     

    Nice fix, I have already try this code and it works!

     

    function QuickApp:OnButton()
        self:updateProperty("deviceIcon"1017)
    end

     

    I have also been checking the function that you had pasted me:

    Please login or register to see this code.

     

    And the problem is that this function is not implemented in the system. You need to declare the function and its implementation before using it:

     

    function fibaro.setSceneEnabled(sceneID, enabled)
        return api.put("/scenes/"..sceneID,{enabled=enabled})
    end

     

    Then it can be used perfectly as you indicate. This is the fully functional code.

     

    function QuickApp:onInit()
        self:debug("onInit")
    end
     
    function fibaro.setSceneEnabled(sceneID, enabled)
        return api.put("/scenes/"..sceneID,{enabled=enabled})
    end
     
    function QuickApp:OnButton()
        fibaro.setSceneEnabled(145,true)
        self:updateProperty("deviceIcon"1017)
    end
     
    function QuickApp:OffButton()
        fibaro.setSceneEnabled(145,false)
        self:updateProperty("deviceIcon"1016)
    end

     

    Thank you very much for your help

    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
    Answer this question...

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

     Share

    ×
    ×
    • Create New...