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!



Smart Home Forum by FIBARO Team

  • 0

json - decoding issue


I need some help with json decoding. 

I'm succesfully got the data in HC2 from Rasspery/Pyton but I'm not able to decode that data in HC2.

Any advice, please?!



--starting LUA code here

local smartmeter= Net.FHttp('');
response = smartmeter:GET("/index.py")

fibaro:debug('Answer: ' ..response) --this is the data response coming from Rasppery/Pyton:  {"Amp": 13.29, "Volt": 98.01}



if (tonumber(status)==200 and tonumber(errorCode)==0) and response~=nil 

   local harduino = json.decode(response)

   fibaro:debug('Decode: ', harduino)

   fibaro:debug('Or decode: ', harduino.Volt) 

else fibaro:debug('Not able to decode!') -- this is the executed code


--end LUA code here







Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0


I'm a bit new in this but ...

For me it seems the if statement returns FALSE so you land in else part.


One of the following is not what you think it is:

- tonumber(status) == 200

- tonumber(errorCode) == 0

- response ~= nil (this one should be TRUE, you debug it)

Just debug "status" and "errorCode" maybe it will give you a hint what's wrong.


  • Like 1
Link to post
Share on other sites
  • 0
  • Inquirer
  • Just fix it:

    in Pyton / Raspberry, the header reffered to html by default. Just remove any header and it 's working now.


    Behind Raspberry I am collected data with Arduino... so still plenty of other things to do it in order to running smoothlly all togheter.

    Link to post
    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.

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