staromeste / homebridge-http-advanced-accessory

Supports all devices on HomeBridge Platform / Bridges devices to http
Apache License 2.0
65 stars 22 forks source link

How to work with SessionID ? #19

Open e1l52 opened 4 years ago

e1l52 commented 4 years ago

Hi guys,

Thanks a lot for that excellent plugin. I am trying to add my Siemens OZW672 web interface to HomeKit. Unfortunately the API uses SessionID. I have to get once a SessionID with this call

http://ADDRESS/api/auth/login.json?user=USER&pwd=PASSWORD

The result looks like

{

    "SessionId": "c74c026b-2b9f-48e0-9145-9ef05511ee66",

    "Result": {
        "Success": "true"
    }
}

For all next queries I have to use a call e.g.

http://192.168.1.48/api/menutree/read_datapoint.json?SessionId=6571ac2f-d0bc-4d10-80b4-ef5ebb860626&Id=870

with the SessionID in the URL.

Unfortunately I do not have an idea how to run this method with your plugin. Hope you can help me ?

ThierryS75 commented 2 years ago

Hello,

Many thanks for this very powerful plugin. I am trying to use it to access the Synology Web API, and I am running into the same issue, i.e. the login URL returns a session key that needs to be passed in the ensuing URLs (&_sid=). Would it be possible to add support for this type of authentication, maybe with an optional "login" url with a mapper that would extract the session key in a global variable, which could then be used in subsequent getXXX / setXXX URLs? As in for instance:

{ "accessory": "HttpAdvancedAccessory", "service": "Switch", "name": "SSHomeMode", "forceRefreshDelay": 5, "username": "admin", "password": "admin", "debug": false, "urls": { "login": { "url": "http://xxx.com:5000/webapi/auth.cgi?api=SYNO.API.Auth&method=login&version=7&account=admin&passwd=admin", "mappers": [ { "type": "jpath", "parameters": { "jpath": "$.data.sid" } } ] } "getOn": { "url": "http://xxx.com:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&method=GetInfo&version=1&_sid=${sessionkey}", "mappers": [ { "type": "jpath", "parameters": { "jpath": "$.data.on" } } ] }, "setOn": { "url": "http://xxx.com:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&method=Switch&version=1&on=${value}&_sid=${sessionkey}", "mappers": [] } } }

Many thanks once again,

T