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


solved: failing HTTP-request to local HomeWizzard P1-meter on HC2


Theo

Recommended Posts

Hi all,

 

I would like to register the readings of my P1 meter on a daily basis and retrieve them from the HC2 at a later time.  The raw data give much more information then the app that comes with the HomeWizzard.

I got it working for a Shelly lightbulb, but the Homewizzard keeps silent. Entering that url in any browser on any device does give me results however.

 

Also, a small program in Freepascal on my desktop does the job:

Please login or register to see this code.

 

This gives results for both the Homewizzard and the lightbulb (partly shown below):

 

Quote

{"wifi_ssid":"MostlyHarmless","wifi_strength":30,"smr_version":50,"meter_model":"ISKRA 2M550T-1013",  (...)  }

{"wifi_sta":{"connected":true,"ssid":"MostlyHarmless","ip":"192.168.178.101", (...)   }

 

The code in my HC2:

 

Please login or register to see this code.

Gives only a response for the lightbulb. Commenting out the lightbulb line does not make the difference (for the Homewizzard).

 

Please login or register to see this image.

/monthly_2023_04/image.png.f458a1c942a8aa9ea2e6bfe29bdef76a.png" />

 

So the code is working just fine (although the code in FreePascal is much cleaner).

 

Thanks for any suggestions.

Edited by Theo
Typo
Link to comment
Share on other sites

  • Topic Author
  • The HomeWizzard does send 1088 bytes of data. Is that too much?
    The stream of the Homewizzard in the Pascal program ends {after the last curly bracket} with four extra hexademical characters: x02, x00, x00, x00. Is that a problem? The lightbulb data end with the last curly bracket.

    Link to comment
    Share on other sites

    • Theo changed the title to solved: failing HTTP-request to local HomeWizzard P1-meter on HC2
  • Topic Author
  • I did some creative experiments to get results.

    Change url_HomeWizzard to http://192.168.178.10/api/v1

    In a browser this returns a html text:  "This URI does not exist"

    And some luck at last: I got this response in the HC2:

    Quote

    [DEBUG] 16:29:49: http://192.168.178.10/api/v1/:{}
    [DEBUG] 16:29:49: pong
    [DEBUG] 16:29:49: success for http://192.168.178.10/api/v1/
    [DEBUG] 16:29:49: encoded to json: {"status":404,"data":"This URI does not exist","headers":{"Content-Type":"text\/html","Content-Length":"23"}}
    [DEBUG] 16:29:49: ping

     

     

    For some reason the code handles status 404 as a succes.

     

    Next step: first send this request to the HomeWizzard and then one to the lightbulb.

     

    Please login or register to see this code.

     

    Result: the respons from the lightbulb is handled first and then the respons from the HomeWizzard.

    This suggests that there is some connection time-out when asking for a proper data response.

    So I added as header: Connection = "keep-alive"

    That does indeed the trick. Here the working code for the HomeWizzard, which also works for the Shelly.

     

    Please login or register to see this code.

     

    Still, in the output the Shelly will come first (data length and status in bold):

    Quote


    [DEBUG] 17:03:25: http://192.168.178.10/api/v1/data/:{}
     [DEBUG] 17:03:25: pong
     [DEBUG] 17:03:25: http://192.168.178.101/status:{}
     [DEBUG] 17:03:25: pong
     [DEBUG] 17:03:25: success for http://192.168.178.101/status
     [DEBUG] 17:03:25: encoded to json: {"headers":{"Content-Length":"714","Content-Type":"application\/json","Server":"Mongoose\/6.18","Connection":"close"},"status":200,"data":"{\"wifi_sta\":    (...)    }
     [DEBUG] 17:03:25: ping
     [DEBUG] 17:03:25: success for http://192.168.178.10/api/v1/data/
     [DEBUG] 17:03:25: encoded to json: {"headers":{"Access-Control-Allow-Origin":"*","Content-Type":"application\/json","Content-Length":"1084"},"status":200,"data":"{\"wifi_ssid\":   (...)  }
     [DEBUG] 17:03:25: ping

     

     

    • Like 1
    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
    Reply to this topic...

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