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

Simple Quick App help


Question

Posted (edited)

I just can`t get my head around this....

 

I have a GlobalVariable = "Electricpricenow"

I want to display this price in a simple, but nice way.

 

This was the solution in my HC2 and VD:

local ID = fibaro:getSelfId(Label1)
fibaro:call(ID, "setProperty", "ui.Label1.value", (tonumber(fibaro:getGlobalValue("Electricpricenow"))))
fibaro:sleep(120000) -
 

So who do I get this to work in HC3 and Quick App?
What is the correct lua, and what type of Quick App do I use? The globaleVarible updates every hour.

Edited by dorten75

14 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • Posted

    is it possible?

    • 0
    Posted (edited)

    Yes , its

    Create QA and copy follow:

    Please login or register to see this code.

     
    Edited by cag014
    • 0
  • Inquirer
  • Posted

    Thank you @cag014 for replying.


    Do I have to choose a spesific type of QA when creating it?

    Have tryed several different types, mulitsensor, power and so on.

     

    The output should just be : 3,2455  - as an example, but nothing comes up.

    It just stays at: 0

     

    I have the value stored in global variable under "General" -> "Variables", do I have to create it in the QA -> "Variables" ?

    • 0
    Posted
    1 hour ago, dorten75 said:

    The output should just be : 3,2455  - as an example, but nothing comes up.

    It just stays at: 0


    maybe there is a misunderstanding, do you want to show the value in the icon / properties or in the label?

     

    In the example from cag014 you need to create the label within the quickapp, just like your example from the HC2. 

    • 0
  • Inquirer
  • Posted

    @SmartHomeEddy Thank you for trying to clear that up :)
    I would prefer the value to be presented in the icon itself.

    But have also created an label within the QA and c/p the lua code above, but there it still just say "label" and no value from the globalVariable.
    The label id = label     .....as well

    So the type of QA I choose does not matter?

    • 0
    Posted

    Type of Quickapp isn’t that important, multilevel sensor is a save choice and will do the job. 
     

    If you want to update the value in the properties, you can add this line of code to the example of cag014:

     

    Please login or register to see this code.


    Instead of the updateView line or on top of below that line of code. 

    • 0
  • Inquirer
  • Posted

    Happy you are taking your time to try to help me :)

     

    Have these lines in now.
    Suddenly the "label" line works for some reason- so now it atleast seems to be pulling the globalV. there.
    But no change with "value" Property.

     

    Tried to change the last function QuickApp:updateProperty() -- to function QuickApp:onIni(), but stil no value change in property...

     

    function QuickApp:onInit()
        self:updateView("label", "text", "Price Nkr ="..fibaro.getGlobalVariable("StromPrisNaa0rekWh"))
        setInterval (function() self:updateLabel() end, 120000)
    end 
     
    function QuickApp:updateProperty()
        self:updateProperty("value",tonumber(fibaro.getGlobalVariable("StromPrisNaa0rekWh")))
    end
    • 0
    Posted

    I think this works better:

     

    Please login or register to see this code.

     

     

    • 0
  • Inquirer
  • Posted (edited)

    Sorry to say I am not getting wiser :)

     

    This works as an label - but not if I use - function QuickApp:updateLabel()

    Please login or register to see this code.

     

    This does not work - and does not change whatever function I put in front.

    Please login or register to see this code.

    I guess "value" is defined in the Property, but it still stay at 0 in the Dashboard.

     

    You have QA that work like this without any problems?

     

    EDIT:

    If i just do this, the icon changes from 0 to 7, - but it will not pull the globalv. 

    And for a breif moment, I tried "local nr1 = fibaro.getglobal.... and it pulled the global.
    Just to not wanting to pull it again when I tried to make a new QA, so  I am not sure what is happing.

    This works...

    Please login or register to see this code.


     

    Edited by dorten75
    • 0
    Posted (edited)
    11 hours ago, SmartHomeEddy said:

    I think this works better:

     

    Please login or register to see this code.

     

     

    @SmartHomeEddy

    I was strubbeling with the same problem, when you make a QA (multilevel sensor) then is it possible in a "label" to get the value from a globalVariable.

    But when you wil the same value in the icon, no update

    I seems that this code in the updateLabel() not works: self:updateProperty("value", tonumber(fibaro.getGlobalVariable("xxxxxxxx")));

    Edited by twanve
    • Like 1
    • 0
    Posted (edited)

    In my way of work, with some extra debug and variables:

     

    Please login or register to see this code.

     

     

    Edited by SmartHomeEddy
    • Thanks 1
    • 0
    Posted

    @SmartHomeEddyTested and this new code works.

    Thx:-)

    • Thanks 1
    • 0
  • Inquirer
  • Posted

    @SmartHomeEddy
    Thx a lot - you are a star!! :)
    Just had to clean up a few - unexpected symbol near '..' ,but then it worked like a charm!

     

    Not sure about all you did there, but I even learned a bit messing around with this.

    Think I have to have you on "speed dial" for my future plans ;) 

     

    • Thanks 1
    • 0
    Posted

    your welcome ?

     

     

     

    • Thanks 1

    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.

    ×
    ×
    • Create New...