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

Access the HC2 API


tnesheim
 Share

Question

Hi

I'm trying to access the Fibaro API from a M5Stack-device. I'm already interfacing a Homey to my HC2 using "embedded user/password" in the url...and this works.

On on the M5Stack i get a 401/(unauthorized access) in return when using the "embedded username/password" approach, so I guess that this is not a feasible way.

It seems that i need to enter the url (which should be ok), and some information in as "headers" and "data". It's probably in there I need to enter the username and password....as well as "Content-type"??

 

Can anyone point me in the correct direction...what information to put where?

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

I don't have code for you but it is called "Basic Authentication" and wiki says

 

Please login or register to see this link.

 

"a header field in the form of Authorization: Basic <credentials>, where credentials is the base64 encoding of id and password joined by a single colon :."

 

Wireshark:


Hypertext Transfer Protocol
    GET /api/devices HTTP/1.1\r\n
    Host: 192.168.1.1\r\n
    User-Agent: LuaSocket 3.0-rc1\r\n
    Authorization: Basic <<<<<<<credentials here>>>>>>>>\r\n
    TE: trailers\r\n
    Connection: close, TE\r\n
    \r\n
    [Full request URI: http://192.168.0.51/api/devices]
    [HTTP request 1/1]
    [Response in frame: 1638]
 

 

Link to comment
Share on other sites

  • 0
  • Inquirer
  • One step further....my HC2 is now complaining about unauthorized login attempts?

    Link to comment
    Share on other sites

    • 0

    Okay! Try "wireshark" if you have a managed hub with monitoring port. Or a 20 year old dumb hub. Or set your ESP to send to your PC with wireshark (assuming you have a web server listening. Because this tool will decode all your stuff and probably reveals the error. You have to wait 30 minutes to get unblocked anyway.

    Edited by petergebruers
    • Thanks 1
    Link to comment
    Share on other sites

    • 0
    4 hours ago, tnesheim said:

    Hi

    I'm trying to access the Fibaro API from a M5Stack-device. I'm already interfacing a Homey to my HC2 

    Hi @tnesheim ... something different. I see you have Homey and HC2. If you must choose between one of them ... ? ... which one would you choose. 

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 3 minutes ago, Sjekke said:

    Hi @tnesheim ... something different. I see you have Homey and HC2. If you must choose between one of them ... ? ... which one would you choose. 

    I think the two controllers are complementary. I´ve heard that the Homey z-wave range is poor, but on the other hand there are a lot of apps for all sorts of non-z-wave-stuff. So I use the HC2 for the core smart house stuff, z-wave and Hue, and the Homey as a multiprotocol bridge for my Somfys, Doorbird, Doorman, Push-messages etc... I use the API-to tie the together...

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • I finally made it... I used a key-generator 

    Please login or register to see this link.

     that made a key that I inserted into the header in my M5Stack program. I now display the value of HC2-global variables in the M5-display?

     

    My plan i to have a discrete display that can show alerts....eg before nighttime that shows that all doors are locked (I already have sensors for this)...

    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.

     Share

    ×
    ×
    • Create New...