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

Virtual Device failed with JSON



Hi all

I have 3 different virtual devices that use JSON to request ethernet cards. These devices set some global variables that are used by other virtual devices for display purpose only because from one card, I can get many data (energy comsumption, temperature, etc)

Here is the code of the main loop for one of them:

HC2 = Net.FHttp("")

response ,status, errorCode = HC2:GET("/api/xdevices.json?cmd=10")

fibaro:log("Status = " .. status)

if (tonumber(status) == 200) then

response = json.decode(response)

fibaro:setGlobal("ABO", response.T1_PTEC)

fibaro:setGlobal("CONSO", response.T1_PAPP)


fibaro:log("ErrorCode = " .. errorCode)


Whenever I disconnect from the HC2 web interface, they seem to pause or to failed requesting my cards. That means each time I connect to the HC2 web interface, the display of the devices is not update. So I have to run main loop with debug button and the script restart agains and is working !!!

Sometime, nothing is display with the fibaro:log or I have errorcode = 2

I wonder if running the script each second is not too fast !! I don't know if I can insert a sleep command in so far the script is running each second !!! I'm afraid it will stack all the call to the script !!!

Any idea regarding this issue ?



[ Added: 2013-09-13, 10:44 ]

On the advice of Socha, I had a sleep command at the end of my script. It seems to be better but after some time, I have errorcode=2. Once in this mode, my script seems to be unable to return to a normal operating mode with status = 200

What does this code means ?



Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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