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

net.HTTPClient() URL parameters not passed correctly


Question

Posted

I am losing my mind on this one. I consumed the URL on my HC2 and now having issues on HC3. I am consuming public API on 

Please login or register to see this link.

. It works so that if parameters are left out it always retrieve default dataset.  I need to get default data with for example this URL: 

Please login or register to see this link.

 

What ever parameter I pass in Fibaro scene I always get back default dataset. The parameters work well in Postman or any browser, but FIbaro net.HTTPClient() seems to mess them up.

 

Here os my test script, any advice would be appreciated.

 

local url = "https://dashboard.elering.ee/api/nps/price?start=2025-11-19T00%3A00%3A00%2B02%3A00&end=2025-11-19T00%3A20%3A59%2B02%3A00"
 
--local url = "https://dashboard.elering.ee/api/nps/price" .. start .. "&end=" .. endt
 
print(url)
 
local http = net.HTTPClient()
 
http:request(url, {
  options = {
    method = 'GET',
    checkCertificate = true,
    headers = { ["accept"] = "application/json" },
    timeout = 5000
  },
  success = function(response)
    fibaro.debug("API", "Status: " .. response.status)
    if response.status == 200 then
      local data = json.decode(response.data)
      if data and data.data and data.data.ee then
        for _, entry in ipairs(data.data.ee) do
          -- Convert timestamp (UTC) to local Tallinn time
         local utcSeconds = entry.timestamp
            local utcTime = os.date("!%Y-%m-%d %H:%M:%S", utcSeconds)
        local tallinnTime = os.date("%Y-%m-%d %H:%M:%S", utcSeconds + 2*3600) -- +2h offset
 
         
          fibaro.debug("API", "Timestamp: " .. utcSeconds ..
                                " | Local Tallinn time: " .. tallinnTime ..
                                " | Price: " .. tostring(entry.price))
        end
      else
        fibaro.debug("API", "No EE data found in response")
      end
    else
      fibaro.debug("API", "Error: " .. response.status .. " " .. response.data)
    end
  end,
  error = function(err)
    fibaro.debug("API", "HTTP request failed: " .. err)
  end
})

2 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • Posted
    On 11/18/2025 at 11:01 PM, Sergeyyoud said:

    I am losing my mind on this one. I consumed the URL on my HC2 and now having issues on HC3. I am consuming public API on 

    Please login or register to see this link.

    . It works so that if parameters are left out it always retrieve default dataset.  I need to get default data with for example this URL: 

    Please login or register to see this link.

     

    What ever parameter I pass in Fibaro scene I always get back default dataset. The parameters work well in Postman or any browser, but FIbaro net.HTTPClient() seems to mess them up.

     

    Here os my test script, any advice would be appreciated.

     

    local url = "https://dashboard.elering.ee/api/nps/price?start=2025-11-19T00%3A00%3A00%2B02%3A00&end=2025-11-19T00%3A20%3A59%2B02%3A00"
     
    --local url = "https://dashboard.elering.ee/api/nps/price" .. start .. "&end=" .. endt
     
    print(url)
     
    local http = net.HTTPClient()
     
    http:request(url, {
      options = {
        method = 'GET',
        checkCertificate = true,
        headers = { ["accept"] = "application/json" },
        timeout = 5000
      },
      success = function(response)
        fibaro.debug("API", "Status: " .. response.status)
        if response.status == 200 then
          local data = json.decode(response.data)
          if data and data.data and data.data.ee then
            for _, entry in ipairs(data.data.ee) do
              -- Convert timestamp (UTC) to local Tallinn time
             local utcSeconds = entry.timestamp
                local utcTime = os.date("!%Y-%m-%d %H:%M:%S", utcSeconds)
            local tallinnTime = os.date("%Y-%m-%d %H:%M:%S", utcSeconds + 2*3600) -- +2h offset
     
             
              fibaro.debug("API", "Timestamp: " .. utcSeconds ..
                                    " | Local Tallinn time: " .. tallinnTime ..
                                    " | Price: " .. tostring(entry.price))
            end
          else
            fibaro.debug("API", "No EE data found in response")
          end
        else
          fibaro.debug("API", "Error: " .. response.status .. " " .. response.data)
        end
      end,
      error = function(err)
        fibaro.debug("API", "HTTP request failed: " .. err)
      end
    })

     

    I ran this call through API proxy and it seems that Fibaro is not passing on any query parameters in URL. Could this be a bug in  version 5.190.38

    • 0
    Posted (edited)

    use following in scenes (that's the way since 5yrs so not a bug in 5.190.38)

     

    Please login or register to see this code.

     

    Edited by tinman

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