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

Type Device: energyMeter


Question

Posted (edited)

Please login or register to see this code.

Please login or register to see this code.

 

Total
Today
This Week
This month
This Year

 

Please login or register to see this code.

Please login or register to see this code.

Please login or register to see this code.

Total
Today
This Week
This month
This Year

 

Thanks

 

Please login or register to see this code.

 

 

Please login or register to see this attachment.

Edited by PasqualeOK

15 answers to this question

Recommended Posts

  • 0
Posted

Welcome to the forum @PasqualeOK

 

what are you trying to do? You are writing about an image you uploaded? 

  • 0
  • Inquirer
  • Posted

    Please login or register to see this code.

    • 0
    Posted

    You are a bit frugal with your information. If you give more info, the answers will be more accurate. I think you are writing about a QuickApp you build? 
     

    The devicetype indeed should be energy meter (com.fibaro.energyMeter).
    And you need to update the value property with a kWh value (number). The kWh value should add up (increase) during the day. 

    Please login or register to see this code.

     

    • 0
  • Inquirer
  • Posted

    Good morning,
    I'm creating a QuickApp on the Fibaro platform.
    The type of QuickApp is meterEnergy.
    I created the QuickApp. The following QuickApp queries a device, extracts information and reads it to me on the QuickApp.

    The devicetype indeed should be energy meter (com.fibaro.energyMeter).
    And you need to update the value property with a kWh value (number). The kWh value should add up (increase) during the day.


    Yes.

    In fact, that's what you suggested to me. Yes

    Image, show: Total = 0, Today = 0, This week = 0, This Month = 0, This Year = 0

    If I wanted to save the energy of "Today". I have to:

    self:updateProperty("value",value)


    "value" is a stardard key ?

    To historicize the values: "Total", "Today", "This Week", ...
    Are there any keys? Some standard Fibaro variables?


    I hope I have been clearer and given you an idea of what I want to do.

     

    Thank you

    Please login or register to see this attachment.

    • 0
    Posted

    Just checking, the value you insert in the value property, does it increase every time you insert the value? 
     

    like for example 100 - 120 - 125 - 140 - 151 - 156 - etc

    • 0
  • Inquirer
  • Posted

    Thank you for the reply. Very kind indeed

    Just checking, the value you insert in the value property, does it increase every time you insert the value?

    Yes. But sometimes the value is constant.

    So my question is: to update the value of "Today", I just need to apply the following function:

    self:updateProperty("value",value)

    "value"

    Is "value" the default key or field to store "Today"?
    Is "Total" an automatic field? or do I have to create an algorithm that calculates it?
    The same goes for the other values: "This week".
    Is there any GET type API to get these values?
    I thought that the historicization of these values occurred through POST type APIs

    Thank you very much for your availability

    • 0
    Posted
    40 minutes ago, PasqualeOK said:

    the value you insert in the value property, does it increase every time you insert the value?

    Yes. But sometimes the value is constant.

    That is OK

     

    41 minutes ago, PasqualeOK said:

    So my question is: to update the value of "Today", I just need to apply the following function:

    self:updateProperty("value",value)

    "value"

    value (the second one) is you variabele containing the kWh as a number

     

    42 minutes ago, PasqualeOK said:

    Is "Total" an automatic field?

    yes

     

    42 minutes ago, PasqualeOK said:

    The same goes for the other values: "This week".

    Yes, also

     

    43 minutes ago, PasqualeOK said:

    Is there any GET type API to get these values?

    Yes, see Swagger to get the values. But they aren’t there in your screen, so the API won’t return them.

     

    btw the energy values are on my HC3 under the general tab, not the advanced tab. Are you on a HC3? 

    • 0
  • Inquirer
  • Posted (edited)

    value (the second one) is you variabele containing the kWh as a number. OK

    self:updateProperty("value",value)

    where "value" is a field or key.

     

    Please login or register to see this code.

     

    Is "Total" an automatic field?
    OK.

    Please login or register to see this code.

     

    Please login or register to see this code.

     

    the energy values are on my HC3 under the general tab, not the advanced tab. Are you on a HC3? Yes

     

    Please login or register to see this code.

     

    self:updateProperty("value",value_by_me)

     

    Please login or register to see this code.

    Please login or register to see this code.

    Please login or register to see this code.

    Please login or register to see this code.

     

    Please login or register to see this code.

     

     

     

    Please login or register to see this attachment.

    Edited by PasqualeOK
    • 0
    Posted
    1 hour ago, PasqualeOK said:

    But my question is: "value" is a global key or variable, I don't know how to express myself. Is "value" in the Json of the QuickApp or is it a "database" field and is it standard for the QuickApp?

    it is like this:

    Please login or register to see this code.

    “value” is a property of the device, so you update the property. 
    ProductionkWh is a number, not a string
     

    1 hour ago, PasqualeOK said:

    the "value" value is historicized and the remaining values as in the image change because there is already an algorithm in the Fibaro system, which changes the values? Right?

    Indeed

     

    1 hour ago, PasqualeOK said:

    I know Swagger. I used it, but through the API I didn't find it. So the values that are in the image have no reference in Swagger. Right? Did I understand correctly?

    The values are zero, so the API will also return zeros. 
     

    1 hour ago, PasqualeOK said:

    Is it important that the menu is on "Production" at the bottom?

    If the kWh value is production, for example from your solar panels, yes. 
     

    1 hour ago, PasqualeOK said:

    Once the field is historicized, will the other values take on their value as the minutes pass, thanks to the Fibaro Platform? Right.

    The HC3 will do its thing with weekly, monthly, yearly in de energy database. 
     

    Maybe share your sourcecode. 

    • 0
  • Inquirer
  • Posted

    function QuickApp:automateReadingProcess()
        -- Imposta un intervallo personalizzato (in millisecondi) per tutte le letture
        local readingInterval = tonumber(self:getVariable("interval"))

        fibaro.setTimeout(readingInterval, function()
            self:leggiEnergiaImporta()
            fibaro.setTimeout(readingInterval, function()
                self:leggiPotenzaImporta()
                fibaro.setTimeout(readingInterval, function()
                    self:leggiFrequenza()
                    -- Ricomincia il ciclo di lettura
                    self:automateReadingProcess()
                end)
            end)
        end)
    end

    All comments in "italian Language"


    interval is a parameterized value, from variables of Fibaro

     

    function QuickApp:processData(data, label, unit)
        local values = self:parseModbusResponse(data)
        if values then
            self:debug("Valore 1:", values[1])

            -- Aggiorna il label con il valore e l'unità di misura
            self:updateLabel(label , values[1] .. " " .. unit)

            self:debug("Valore assegnato ")
        else
            self:error("Errore nel parsing dei dati della risposta Modbus.")
        end
    end

     

    where should I replace:

    self:updateLabel(label , values[1] .. " " .. unit)

    with

    self:updateProperty("value", value_my .. " " .. unit)

     

     


    So I understood well that:

    self:updateProperty("value",ProductionkWh)

    will do its job, that of assigning its value:

    Energy Production: kWh and must be numeric.

    As I described I set the interval every 10,000 ms (i.e. 10 seconds).
    But from the first measurement, it will assign the value to "Today", but from what you explained to me also to Total.
    If at the first assignment:
    for example:
    185,456
    at the second
    189,456
    to the third:
    185,456,
    how does it behave? Does it average?
    I hope you understand what I mean


    Thanks for your time

    • 0
    Posted
    9 minutes ago, PasqualeOK said:

    self:updateProperty("value", value_my .. " " .. unit)

    This isn’t ok. It should only be the value, not the unit. 
     

    If you want to use a unit, do

    Please login or register to see this code.

     

    I cannot see in the code you enclosed where value_my comes from, or if it is a number or string. I think there is some code missing. 

     

    • 0
  • Inquirer
  • Posted (edited)

    Please login or register to see this code.

    this example:

    Please login or register to see this code.

     

    Please login or register to see this code.

     

    Please login or register to see this code.

    Please login or register to see this code.

    Please login or register to see this code.

    First value: 185,900

    Second value: 190,900

    .....

    185,900

    186,900

     

    Please login or register to see this code.

    Please login or register to see this code.

    Please login or register to see this code.

     

    Please login or register to see this code.

    Please login or register to see this code.

    Please login or register to see this code.

    Please login or register to see this code.

     

     

    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 PasqualeOK
    • 0
    Posted

    I am sorry, you make it too much of a puzzle for me. All the answers are in me previous post. Please read them carefully. 

    • 0
    Posted

     

    I think it is this you might be after @PasqualeOK ?

     

    self:updateProperty("today", kWh)  

     

     

    it updates the today value and all the others come automatic. 

    but you can only increase it.   so the QA should also store the value  kWh even when it is restarted! 

     

     

    too store values in the QA even when it is saved/restarted without using Qvars look at this exampel by @jgab   

     

     

     

     

     

     

     

    • 0
  • Inquirer
  • Posted

    Please login or register to see this code.

    Please login or register to see this code.

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