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

handle HTTP request error


Peppe

Question

Hi All,

I'm no a professional programmer but I'm trying to make some basic code for my needs on HC2.

I wrote a code in order to get information from my SolarEdge system and based on that perform some actions like turn on the water heater, etc...

Unfortunately the SolarEdge system some times (from my test typically ones per day) responds with an error that generates a Lua fail aborting the scene.

This is the code I'm using for the HTTP request:

 

  local http = net.HTTPClient() 
  http:request("https://monitoringapi.solaredge.com/site/"..SE_CLIENT_ID.."/powerDetails?meters=FeedIn&startTime="..SEendTime.."&endTime="..SEendTime.."&api_key="..SE_API.."",{
      --options = {method = 'GET', timeout = 2000 },
    options = {method = 'GET'},
      success = process, 
    --success = function(response) fibaro:debug(response.data) end, 
      --error = error
    error = function(err) fibaro:debug("Error:"..err) end
    })

 

and this is one of the errors that I got during the day running the full code:

 

[DEBUG] 18:39:02: Error:Host not found (non-authoritative), try again later

 

Is there a way to avoid this issue and in case of an error in HTTP response just skip it and retry?

Thank you

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • Hi,

    Yes I started with the posted code, making some changes since I have a different scope.

    Anyhow also the posted code has the same issue. The serve responses with a wrong message and the scene fails.

    Thank you

     

    Link to comment
    Share on other sites

    • 0

    In the source of @D-Vine there is:

     

    Please login or register to see this code.

     

     

    So errors (response.status ~= 200) will be handled ok. 

     

    On 11/19/2021 at 11:35 AM, Peppe said:

    [DEBUG] 18:39:02: Error:Host not found (non-authoritative), try again later

     

    This could just be a temporary error from the SolarEdge cloud. That could happen, I sometimes see it in the HC3 quickapp also. 

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Hi thank you for the feedback!

    Unfortunately I had no chance to play with the code in the last months....

    Yes the piece of code processing the returned message from the SE API performs the status test, but it seems to me, that the fibaro scene is terminated before the response.status test with a fatal LUA error due to an invalid SE server response.

     

    [ fatal] LUA error: Host not found (non-authoritative), try again later

     

    Is there a way to keep the scene working even with a wrong response from the SE server?

    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.

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