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

What is the best way to get consumed/produced energy from PowerMeter devices?


Question

Posted

Hello,

 

Currently I'm using following call to get consumed/produced energy from midnight to the current time:

Please login or register to see this code.

This works, but it takes too much time to get this value, at least few seconds in some occasions.

 

QUESTION:

 

Is there a better and faster way to get consumed energy from PowerMeter devices?

 

Thank you!

10 answers to this question

Recommended Posts

  • 0
Posted

I was playing around with that when I tried to make a chart/graph QA.
I think it is some filter option you can use to only get the value closest to "today" time (00:00) and a normal hub.call to get what it is now. and do a subtration of thoose 2 values in your QA. 
(now you are getting all the value inbetween that time, if I am not wrong?) 
And dont know if it is faster to only ask for the closest value to 00:00 just a thought :D 
 

  • 0
  • Inquirer
  • Posted

    Hi @Brors94,

     

    The thing is that suggested way will not give correct value, since power measured in time can fluctuate and is not just subtraction of the first and last measurement.

    What I get now is table:

     

    Please login or register to see this code.

     

    and what I need is "kWh" part. I was just hoping if there is some other type of call which is faster in calculating energy consumed between two points in time.

    Maybe @m.roszak can shed some light on this one?

    • 0
    Posted
    3 hours ago, Sankotronic said:

    Hi @Brors94,

     

    The thing is that suggested way will not give correct value, since power measured in time can fluctuate and is not just subtraction of the first and last measurement.

    What I get now is table:

     

    Please login or register to see this code.

     

    and what I need is "kWh" part. I was just hoping if there is some other type of call which is faster in calculating energy consumed between two points in time.

    Maybe @m.roszak can shed some light on this one?

    I see you are using the "energy api" and I used the history api  :D 


    And you want the kWh right? (energy from 00:00 to now) 
    And now the power part (Wattage)? 


    But this gives 

    local data = api.get("/events/history?eventType=DevicePropertyUpdatedEvent&from="..from.."&to="..too.."&objectType=device&objectId="..sensorid.."&numberOfRecords=10")

     

    if sensorid is a kWh meter:

    data: [{"id":29270780,"objects":[{"id":973,"type":"device"}],"type":"DevicePropertyUpdatedEvent","timestamp":1765234691,"sourceId":0,"sourceType":"system","data":{"id":973,"oldValue":140161.9,"newValue":140162.2,"property":"value"}},{"id":29270735,"objects":[{"id":973,"type":"device"}],"type":"DevicePropertyUpdatedEvent","timestamp":1765234510,"sourceId":0,"sourceType":"system","data":{"id":973,"oldValue":140161.6,"newValue":140161.9,"property":"value"}},{"id":29270709,"objects":[{"id":973,"type":"device"}],"type":"DevicePropertyUpdatedEvent","timestamp":1765234415,"sourceId":0,"sourceType":"system","data":{"id":973,"oldValue":140161.4,"newValue":140161.6,"property":"value"}},{"id":29270683,"objects":[{"id":973,"type":"device"}],"type":"DevicePropertyUpdatedEvent","timestamp":1765234319,"sourceId":0,"sourceType":"system","data":{"id":973,"oldValue":140160.6,"newValue":140161.4,"property":"value"}},{"id":29270580,"objects":[{"id":973,"type":"device"}],"type":"DevicePropertyUpdatedEvent","timestamp":1765233941,"sourceId":0,"sourceType":"system","data":{"id":973,"oldValue":140159.9,"newValue":140160.6,"property":"value"}},{"id":29270472,"objects":[{"id":973,"type":"device"}],"type":"DevicePropertyUpdatedEvent","timestamp":1765233620,"sourceId":0,"sourceType":"system","data":{"id":973,"oldValue":140159.6,"newValue":140159.9,"property":"value"}},{"id":29270416,"objects":[{"id":973,"type":"device"}],"type":"DevicePropertyUpdatedEvent","timestamp":1765233466,"sourceId":0,"sourceType":"system","data":{"id":973,"oldValue":140159.3,"newValue":140159.6,"property":"value"}},{"id":29270391,"objects":[{"id":973,"type":"device"}],"type":"DevicePropertyUpdatedEvent","timestamp":1765233357,"sourceId":0,"sourceType":"system","data":{"id":973,"oldValue":140158.9,"newValue":140159.3,"property":"value"}},{"id":29270316,"objects":[{"id":973,"type":"device"}],"type":"DevicePropertyUpdatedEvent","timestamp":1765233076,"sourceId":0,"sourceType":"system","data":{"id":973,"oldValue":140157.7,"newValue":140158.9,"property":"value"}},{"id":29270099,"objects":[{"id":973,"type":"device"}],"type":"DevicePropertyUpdatedEvent","timestamp":1765232266,"sourceId":0,"sourceType":"system","data":{"id":973,"oldValue":140157.3,"newValue":140157.7,"property":"value"}}]


     

    • 0
  • Inquirer
  • Posted

    Hi @Brors94,

     

    Thanks. It is nice to be able to get events from device property change, but that is not what I'm looking for.

    As I pointed out, I have power meter that shows current consumption power W (kW) and I need to get consumed energy kWh from the midnight to the present time of the day.

     

    On my HC2 I use following API call and it works much faster:

    Please login or register to see this code.

     

    It takes around 0.00328 sec. of CPU time, while same call on HC3 takes between 2 to 3 seconds.

    Is it possible that on HC3 it takes much longer because energy is read from Quick app of power meter type, while on my HC2 energy is read from z-wave power meter?

    • 0
    Posted
    2 hours ago, Sankotronic said:

    Hi @Brors94,

     

    Thanks. It is nice to be able to get events from device property change, but that is not what I'm looking for.

    As I pointed out, I have power meter that shows current consumption power W (kW) and I need to get consumed energy kWh from the midnight to the present time of the day.

     

    On my HC2 I use following API call and it works much faster:

    Please login or register to see this code.

     

    It takes around 0.00328 sec. of CPU time, while same call on HC3 takes between 2 to 3 seconds.

    Is it possible that on HC3 it takes much longer because energy is read from Quick app of power meter type, while on my HC2 energy is read from z-wave power meter?

     

    Aha, so you calculate the kWh from the Watt data? Instead of reading the kWh the device report? 🤔

     

    • 0
  • Inquirer
  • Posted

    Hi @Brors94,

     

    I'm talking about power meter, a child device added by Enphase Envoy Monitor Quick app. This child device is of power meter type and it shows current consumption power in watt (W). Looking at the JSON of this child, there is only value in watt (W). It is updated by the value read from Envoy gateway and updated regularly.

     

    There is also a child device of type energy meter that shows consumed energy for current day, but problem is that due to some bug in Envoy API, sometimes reported consumed energy is not correct. Therefore I need to get consumed energy from consumption power meter child and show more accurate value.

     

    I use Fibaro API call to get total consumed energy from power meter child device with the following code:

    Please login or register to see this code.

    and that works OK. Only problem with this api call is that it takes 2 to 3 seconds, while same call on my HC2 reading consumed energy from Aeotec HEM gen5 or Fibaro plug takes much less than a second. BTW I checked this with LUA function os.clock() ;-) 

     

    So, I'm asking if there is maybe some undocumented faster way to get energy for a given period from power meter device on HC3.

     

    Also I want to report that this api call is probably not optimized properly as it is on HC2. @m.roszak, any comment on that, please?

     

    10 hours ago, Brors94 said:

    Aha, so you calculate the kWh from the Watt data? Instead of reading the kWh the device report? 🤔

    No, I do not calculate consumed energy from the power meter device because it is possible to get it by mentioned api call.

    • Like 1
    • 0
    Posted

    I think I would use new energy panel API for that:

    Please login or register to see this attachment.


    Please login or register to see this image.

    /monthly_2026_01/image.png.1744076aba23de306c6569d17ace9c7a.png" />

    It will pull energy consumed by specific device (based on energy property) for specific period, for example - last day.
    It should be super fast. 

    • Thanks 1
    • 0
  • Inquirer
  • Posted

    Hi @m.roszak,

     

    thanks for suggestion, but I'm not getting anything with this API call:

    Please login or register to see this code.

    I guess I'm not providing proper period string or I have configured device wrongly?

     

    Here is info of the device that I need to read energy from:

    Please login or register to see this spoiler.

     

    Also this device is selected in the energy panel for "Instantaneous power consumption meters".

    • 0
    Posted

    Ah, you want to pull energy readings, but from powert meter device type... I did read this in a hurry and thats the problem. Sorry. 
    This device will respond with the data if it whould be a com.fibaro.energyMeter or device with interace energy (the ones which measures energy consumption, not instantenous power). 

    There is a system way which could be helpfull in your case, its not ideal but maybe this will allow you to make a workaround for the issue you are having with Enphase Envoy.
    System can calulate the energy consumed based on power meter reading, but this feature is available for binary switches for example... Then you won't need to calculate it manually based on power consumption and time passed.


    Please login or register to see this attachment.

     

    If you create a switch, enable this feature including energy calculation...
    By putting the power consumption from Envoy to property "powerConsumption" it will calculate energy consumption in property "energy".
    Then you can pull it from there to feed any other device type - ofcourse I would hide this switch and use it only as a "technical" device.

    Then, you can reuse it as you like.
     

     

    PS
    Calculation works when this "virtual" switch is turned on.

     

    • Thanks 1
    • 0
  • Inquirer
  • Posted

    Hi @m.roszak,

     

    thanks for suggestion. Will try it and revert if it helps. All this would not be necessary if Enphase Envoy gateway is capable of storing and calculate consumed and produced energy, but unfortunately it is not. All that is done on cloud, so local connection does not give accurate energy reading, specially if gateway was turned off during day time. Energy consumed/produced is in that case reset and unusable.

     

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