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

json.decode problem


Question

Posted

i'm trying to get some values from my smart meter via json. i need the data value

 

the lua code i'm using:

Please login or register to see this code.

the debug output:

 

[DEBUG] 21:21:25: { "ActTime" : 1454012495, "ServerTime" : "2016-01-28 21:21:35", "Sunrise" : "08:25", "Sunset" : "17:19", "result" : [ { "AddjMulti" : 1.0, "AddjMulti2" : 1.0, "AddjValue" : 0.0, "AddjValue2" : 0.0, "BatteryLevel" : 255, "Counter" : "3141.216", "CounterToday" : "2.501 m3", "CustomImage" : 0, "Data" : "3141.216", "Description" : "", "Favorite" : 1, "HardwareID" : 2, "HardwareName" : "Slimmemeter", "HardwareType" : "P1 Smart Meter USB", "HardwareTypeVal" : 4, "HaveTimeout" : false, "ID" : "1", "LastUpdate" : "2016-01-28 21:20:04", "Name" : "Gasmeter", "Notifications" : "false", "PlanID" : "0", "PlanIDs" : [ 0 ], "Protected" : false, "ShowNotifications" : true, "SignalLevel" : "-", "SubType" : "Gas", "SwitchTypeVal" : 1, "Timers" : "false", "Type" : "P1 Smart Meter", "TypeImg" : "counter", "Unit" : 2, "Used" : 1, "XOffset" : "0", "YOffset" : "0", "idx" : "8" } ], "status" : "OK", "title" : "Devices" }
[DEBUG] 21:21:25: OK
[ERROR] 21:21:25: line :debug (arg 2), expected 'string const &' got 'nil'

 

what am i doing wrong? can anyone help?

 

the json output when i type the adres in my browser.

Please login or register to see this code.

6 answers to this question

Recommended Posts

  • 0
Posted

  1. And if you try?

  2. fibaro:debug(verbruik.result[1].Data)

  • 0
  • Inquirer
  • Posted

    KristianO,

     

    you are my hero. it works

     

    Thanks

    • 0
    Posted

    Above post really helped me as well.

     

    How can I split data is the response is this,: 

     

    "Data" : "5437050;6103325;0;0;320;0"

     

     

    Result should be 6 different measurements which are combined in above data string:

     

    5437.050

    - 6103.325

    - 0

    - 0

    - 320

    - 0

    • 0
    Posted

    Try:

    Please login or register to see this code.

    • 0
    Posted

    Following this one, because I want to get some of the "value" measurments and values from the below response, but until now without any success.

     

    [DEBUG] 21:16:16:"{\"ok\":true,\"type\":\"response\",\"time\":0.001937499968335,\"rv\":{\"propsval\":[{\"id\":\"name\",\"value\":\"Smart meter\"},{\"id\":\"usage\",\"value\":679},{\"id\":\"T1\",\"value\":4078.789},{\"id\":\"T2\",\"value\":2875.591},{\"id\":\"-T1\",\"value\":0},{\"id\":\"-T2\",\"value\":0},{\"id\":\"L1I\",\"value\":3},{\"id\":\"L1Pimp\",\"value\":0.679},{\"id\":\"L1Pexp\",\"value\":0},{\"id\":\"c_tariff\",\"value\":1},{\"id\":\"gas_usage\",\"value\":0},{\"id\":\"gas\",\"value\":1662.304},{\"id\":\"Cost-T1\",\"value\":0.2166},{\"id\":\"Cost-T2\",\"value\":0.2166},{\"id\":\"Cost-nT1\",\"value\":0},{\"id\":\"Cost-nT2\",\"value\":0},{\"id\":\"Cost-gas\",\"value\":0.597},{\"id\":\"Client-blob\",\"value\":\"\"},{\"id\":\"available\",\"value\":true}]},

    \"systime\":1455826499,\"seq\":1,\"error\":false}"

     

    Edit:

    Started a new topic on this. 

    Please login or register to see this link.

    • 0
    Posted

    Thanx for the fast response, somehow i didn't marked the topic.

     

    I tried above without succes.

     

    This is my code:;

    Please login or register to see this code.

     

    [ERROR] 09:48:55: line :debug (arg 2), expected 'string const &' got 'nil'

     

    Any ideas?

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