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 meter: Query your hourly, daily, weekly, monthly consumption


Mini

Recommended Posts

Hello

 

I want to read the power meter data with the code below, but despite successful reading it will always have a NIL value. Can anyone help me, where I went wrong?

With HC2 get api:

http://192.168.1.222/api/panels/energy?type=devices&id=95

Return raw data as follows:

Please login or register to see this code.



This is my short code:
local Energys, status = api.get("/panels/energy?type=devices&id=95")

fibaro:debug("Status: "..status)

fibaro:debug("Energys length: "..#Energys)

local h = Energys.powerH

fibaro:debug("EnergyH: "..h)

 

I get this answer:

[DEBUG] 19:40:25: Status: 200
[DEBUG] 19:40:25: Energys length: 1
[DEBUG] 19:40:25: 2020-01-13 19:40:25.222739 [ fatal] Unknown exception: /opt/fibaro/scenes/226.lua:11: attempt to concatenate local 'h' (a nil value)

 

Link to comment
Share on other sites

Crazy! you asking about Len via #
Got answer - 1 

do not care about this what its array and trying to get prop ;) 

try it

Energys[1].powerH

Link to comment
Share on other sites

May I ask what is the purpose of this code because I am trying to find a virtual device to pull values from Aeotec energy meter to display it on a vd.

Link to comment
Share on other sites

  • Topic Author
  • This was only for the purpose of accessing the data. Similarly, the hourly, daily, weekly and monthly consumption values and their costs will be displayed on the VD to be produced. This helps you get a quick overview.

    Link to comment
    Share on other sites

    Are you planning to do a vd too? If so, it would be extremely helpful as i have no experience with LUA at all. Thanks!

    Link to comment
    Share on other sites

  • Topic Author
  • You can find a lot of help at this link:

    Please login or register to see this link.

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