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

HTTP request HC3





I am trying this HTTP request in HC3 which always returns this statement:


{"error":{"message":"Cast to number failed for value \"NaN\" at path \"__QueryCasting__\" for model \"Ozone1\"","name":"CastError","stringValue":"\"NaN\"","kind":"number","value":"NaN","path":"__QueryCasting__"}}


I also get an 500 error code with this call


This request works flawlessly in HC2, so I am bit lost here. I adapted the HC2 code (hub.debug  command only).

Might this be a bug in HC3? I just don't know what's wrong here.


This script has some more code, but that's just handling and data for input of the HTTP request (like token variable). I only copied the HTTP request here.



Please login or register to see this link.


local http = net.HTTPClient({timeout=20000})
function httpGetJson(url, body, func)
  http:request(url, { 
      options = { 
        method = 'GET',
        headers = {
          ['x-access-token'] = token
      success = function(response)
          hub.debug("Scene6 API response",response.data)
        local isOk, dataTable = pcall(json.decode,response.data)
        if (isOk == false) then
          func(false, "getResponseData ERROR: Invalid JSON: " .. dataTable ..
            "\nWeb Server Data: ".. tostring(response.data))
          if type(dataTable)=="table" then
            func(true, dataTable)
            func(false, "Data returned by json.decode is not a table")
      error = function(err)
        func(false, "HTTPClient error: ".. err)


Any help is appreciated.




Edited by Rikbast
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hi Rik, I just did a test after your email with the same question, this code works, but I get an API rate limit error now:


Please login or register to see this code.



Please login or register to see this code.


Link to comment
Share on other sites

  • 0
  • Inquirer
  • Apparently this only works in QA's and not scenes, I tested this on advice of @Sankotronic

    Why that is, I don't know. That's why I think it might be a bug? Will send Fibaro support an e-mail about it.


    Local API calls (with internal IP address) work fine with the above code in scenes on HC3.



    Thanks for your input!

    Edited by Rikbast
    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.

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