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

How to get the value in this JSON respons?


Question

Posted

Hi all,

 

I am trying to get the last value in the following JSON response:

Please login or register to see this code.

So I am looking to get the 962 value.

This is a collection of timestamps and power metering values from my Flukso, 962 is 962 Watts being used in my home measured using a s0 kWh meter.
I have two, one for my total house consumption and one for my solar panels. The Flukso counts these and can make graphs and keeps historic values.
Ideally I'd like the power panel to use this value as it's input, but it doesn't look that will happen anytime soon.
I tried the following in a VD to get the value, the xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx is the number the sensor is known in the Flukso, I removed it for privacy purposes:

Please login or register to see this code.

But I am stuck and doing something wrong but I can't see what, the error I get is in the json.decode line and this is the error:

Please login or register to see this code.

Thanks in advance for your help.

 

3 answers to this question

Recommended Posts

  • 0
Posted

Is that the exact string that you want to parse? That's not JSON encoded... See

Please login or register to see this link.

You'll have to find a different way to parse that. Probably by using string.match, see

Please login or register to see this link.

I might be able to do that, but my wife forbids me to write parsers during holidays!

Please login or register to see this image.

/emoticons/default_icon_wink.gif" alt=";-)" />

  • 0
  • Inquirer
  • Posted

    Hi Peter,

     

    Yes that is the exact string I want to parse and it is being "sold" as a JSON response: "response: a JSON array containing [unix timestamp, value] array elements".
    But I figured it wasn't exactly as it didn't work and the JSON decode expected something else.
     

    And I can totally understand your wife. =-)

    I'll start trying something else myself.

     

    Happy Holidays!

    • 0
  • Inquirer
  • Posted

    Fixed it but you pointed me in the right direction, although I didn't use string match, but just with some string trimming and reversing I was able to get the values I need.

    Thanks!

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