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


energy meters - how to get consumption for a period ?


Recommended Posts

Posted

If device is main energy meter its measurements are pulled to variable responsible for summary home consumption - it is like this right now.
Unfortunately this means that this data is removed from this API

Anyway I have put a task to the backlog to change it (to show the energy on this API even if device is set as main energy meter) - I hope that this will be soon available. 

Posted
On 11/9/2021 at 11:30 AM, m.roszak said:

For simple summary of Hourly, Daily, Weekly, Monthy or Yearly energy consumption from the specific device you can use /api/panels/energy?id=x 

Could you please give me an example how to get consumption of the previous day or month?

Posted

Here is some inspiration:

 

 

 

  • Thanks 1
  • Topic Author
  • Posted
    20 hours ago, SmartHomeEddy said:

    Here is some inspiration:

     

     

     

    This is the topic  - In 5.090 Fibaro changed API for Energy Meters and link above is not helps.

     

    now is only  /api/panels/energy?id=x 

     

    but there is only fixed data - Hour, Day, Week, Month, Year

     

    You can't request consumption for any period :(

     

    Posted

    As I said before you can pull data for desired periods using new API (used on Savings tab in energy panel) - this one do not have public documentation right now but you can check it out using devTools of your browser.

     

    I will add here some examples of using this API next week :)

    Posted
    3 hours ago, m.roszak said:

    I will add here some examples of using this API next week

    Thank you, I am looking forward to it :-)

    • 2 weeks later...
    Posted
    On 11/21/2021 at 12:21 PM, m.roszak said:

    I will add here some examples of using this API next week

    Any update here? ?

    Posted

    Ah, sorry.

    Forgot to paste here some examples.

     

    All swagger docs are available on web interface but on monday I will past here some usage examples.

    Posted

    So, all documentation of current API can be found in Swagger:

    Please login or register to see this image.

    /monthly_2021_12/image.png.811c9f33b0ce4760c7f47c38e4c79624.png" />


    Then selectng definition "energy":
    image.png.4707ef31e53ec3b823f2e0566227bc08.png


     

    On 11/20/2021 at 12:21 AM, danidani said:

    Could you please give me an example how to get consumption of the previous day or month?

     

    Using this definition we can get a summary consumption and production of a specific day or month (or whole year or specific hour), example:

    Consumpton and production for specific day:
    GET at http://IP_HC/api/energy/consumption/summary?period=2021-12-01

    "period" according to the API docs:

    String representing time period for which we want data to be returned. It is complient with ISO-8601 and accepts values like:
    YYYY (2019)
    YYYY-MM (2019-07)
    YYYY-Www (2020-W01 week 01 is the week containing first Thursday of a year)
    YYYY-MM-DD (2020-01-12)
    YYYY-MM-DDThh (2020-01-12T13).
    This parameter must be in gateway (not browser) timezone.

    Also by similiar request we can pull more specific data (with rooms/categories summary) for specific period:
    GET at http://IP_HC/api/energy/consumption/detail?period=2021-12-01T13

    Or we can pull energy consumption/production with details between startDate and endDate with desired interval:

    GET at http://IP_HC/api/energy/savings/detail?startDate=2021-12-01&endDate=2021-12-02&intervalType=Hourly

    "IntervalType" according to the API docs:
    [ Quarterly, Hourly, Daily, Weekly, Monthly, Yearly ]

    The best way to learn how to use it is to play with it a bit using build-in swagger definitions.

    Posted

    Great explanation. I really thank you. ?

    Posted

    Two more questions.

     

    1. I have a power meter device with a very nice chart, but I am not able to get data using the Swagger.

    2. For how long data are stored in the system? Are they deleted automaticaly after some period?

     

    Please login or register to see this attachment.

    Posted

    This is power consumption chart (W), not kWh which is used in Energy Panel.
    Those Watts are not used in any way in the panel, this is only instant power graph.

    To get those data (which is used in the graph) just use this request:

    http://IP_HC3/api/energy/startTimestamp/endTimestamp/summary-graph/devices/power/deviceId

     

    timestamps are simple epoch format (unix timestamp) and deviceId is the device you want to get the power (W) data - those can be com.fibaro.powerMeters or any actor with interface "power". 

    Posted

    Works great for me, thank you again.

     

    2 hours ago, danidani said:

    2. For how long data are stored in the system? Are they deleted automaticaly after some period?

     

    Posted

    There is the limit of events in the system, so this is not related directly with time period.
    If you will have a lot of devices which reports instant power frequently then this period will be shorter.

    Posted

    Is it possible to get the current power (consumption) of all devices with the power interface?

     

    I am able to get it with http://IP_HC3/api/energy/now/now/summary-graph/devices/power/deviceId but have to run it for each device separately. It takes 44 seconds for 25 devices so when I run it from my web page it is a litle bit slow :-)


    The list of all active devices I get with http://IP_HC3/api/devices?enabled=true&visible=true&isPlugin=false&interface=power&property=[state,true]

     

    Posted

    Current power is stored in property "power" for actors with interface "power" directly in /api/devices/ 

    Using the filters you will be able to pull exactly what you need :)

     

     

    Posted

    ?

     

    Thank you ?

    • 2 weeks later...
    Posted
    On 12/6/2021 at 5:46 PM, m.roszak said:

    GET at http://IP_HC/api/energy/savings/detail?startDate=2021-12-01&endDate=2021-12-02&intervalType=Hourly

    The result is json.

     

    Please login or register to see this image.

    /monthly_2021_12/obrazek.png.689da5726c822f91df40b7d2242e11dc.png" />

     

    How can I go through the results in lua? I would like to print id and consumption for each device.

    Posted
    5 hours ago, danidani said:

    How can I go through the results in lua? I would like to print id and consumption for each device.

    Maybe this LUA code will help you: 

    Please login or register to see this code.

     

    Posted

    Thank you. This is not the solution I am looking for, with the energy panel it is different now.

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