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


  • 1

Presence detection with UniFi: error accessing HTTPS controller site


Question

Posted

I'm working on a scene for presence detection by reading the active Wi-Fi devices log from my UniFi Controller and put the state into a Virtual Device button.

To access the web API I have to login with a JSON post before I get the data. The UniFi website has a self signed certificate and I access it with an IP address.

 

I made the following code:

Please login or register to see this code.

When I run it the following error occurs:

 

Quote

 

[DEBUG] 17:14:01: Error getting data (GetUserData): wrong version number

 

After some research I think it is a TLS version issue. The LUA HTTP library maybe tries to open the secure HTTPS channel with an incorrect version, or the self signed certificate is not accepted.

As I cannot get more logging than this on the HC2 I'm asking if some other developer on the forum had encountered this problem and has a fix for it?

17 answers to this question

Recommended Posts

  • 0
Posted

node-red

 

Please login or register to see this code.

 

Please login or register to see this image.

6WXcL7Q3MX.png

 

  • Like 1
  • 0
  • Inquirer
  • Posted

    You flip the Virtual Device switch with Node-RED? and the Fibaro HTTP API?

    I don't get the Node-RED/Fibaro thing yet, I seems a hack with scenes to get it working.

    • 0
    Posted

    try following

     

    Please login or register to see this link.

     

     

     

    • 0
    Posted
    7 hours ago, tinman said:

    try following

     

    Please login or register to see this link.

     

    TLS23 issue here... FIBARO use tlsv1

     

     

     

    • 0
    Posted
    37 minutes ago, 10der said:

    TLS23 issue here... FIBARO use tlsv1

     

    it's not issue, is something which can be fixed, all one need is to change system.properties from Unifi controller to:

     

    Please login or register to see this code.

    and HC2 can get the data

     

    Please login or register to see this image.

    /monthly_2018_07/image.png.1972490fffa8d33f913a784bb3df0a31.png" alt="image.png.1972490fffa8d33f913a784bb3df0a31.png" />

     

    so no reason to cry^^ 

     

    • Thanks 1
    • 0
    Posted

    he-he... ok, will install windows 3.11.

     

    thank you!

    • 1
  • Inquirer
  • Posted

    You are right 10der. It's insecure and I'm not going to edit my TLS settings on the UniFi controller. 

    I installed an Node-Red/MQTT server and now I'm playing with it.

    • Like 1
    • 0
    Posted (edited)

    no worries, you have to create user with read-only access to stats, nothing more. That user is being used by HC2, with TLS1. To access from outside your home, you can use cloud access or reverse proxy, with websocket ssl/tls1.2

     

    However, when you already have raspi, you can run controller on it, and allow access only to specific hosts - or run even better let node-red and controller on same raspi.

     

    HC2 could support TLS1.2, websockettls (form plugin level only) has been already added, so let's hope for more.

     

    One can of course take the frak off way (oh how fitting to my 1000th posting):

     

    Please login or register to see this spoiler.

     

    Edited by tinman
    • 0
    Posted (edited)
    8 hours ago, tinman said:

    frak off way

    You seem to be running a special firmware version - am I right?

    ;-)

     

    13 hours ago, 10der said:

    ok, will install windows 3.11.

    You've made my day!

    :-)

    Edited by petergebruers
    • 0
    Posted
    6 minutes ago, petergebruers said:

    You seem to be running a special firmware version - am I right?

    Your Honor @petergebruers

     

    it's MS VSCode + see attachments

    Please login or register to see this code.

    Please login or register to see this code.

     

    Please login or register to see this attachment.

    • 0
    Posted (edited)

    Ok, thanks, I can run that locally but not on the HC2 4.054 because Fibaro sets "require" to nil... I saw you other post but I did not (yet) implement it because I use ZeroBrane Studio + link to HC2 (+ offline simulator) similar to yours. I see how that ssl.https fits in. Cheers!

     

    Edit: I'll install the "Microsoft Visual Code" on my Mac, just for fun, and try your integration ;-) - I know it is a very popular editor. But so is "vim" :-D

     

    Edited by petergebruers
    • Like 1
    • 0
    Posted

    with some other funny hidden API calls, one can assign e.g. the RSSI from any wifi device to virtual temperature sensors,

    and show them (well, unfortunately one room per wifi device) in UI (-dBm values)
     

    Please login or register to see this spoiler.

     

    For sure not perfect implementation of VD into initialstate plugin (as one can't read labels directly), but at least something.

     

     

     

    • Thanks 1
    • 0
    Posted
    6 hours ago, tinman said:

    Fibaro have added initialstate plugin,

    Hi @tinman,

     

    is this plugin documented somewhere, or is it the same a with all HC2 documentation?

     

    • 0
    Posted
    39 minutes ago, Bodyart said:

    is this plugin documented somewhere, or is it the same a with all HC2 documentation?

     

    you made my day !

    • 0
    Posted

    Hmmm the same old story!

    • 0
    Posted
    3 hours ago, Bodyart said:

    Hmmm the same old story!

     

     

    • Like 1
    • Thanks 2
    • 0
    Posted

    Hi @tinman,

     

    thank you very much for the elaborated how to. Great job!

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