stfnhmplr / homebridge-homee

use your homee with homebridge
MIT License
15 stars 6 forks source link

Can't get access token #12

Closed lowrents closed 5 years ago

lowrents commented 5 years ago

Hey, I've an issue setting up the homee plugin. Homebridge is running on a RaspberryPi 3B via WLAN as well as the homee. The version of the web interface and the homee are both up to date (2.22.1). The password and username to access the homee api is correct (I also copy/paste from the ~/.homebridge/config.json into the web interface). The following message appears, after I installed the homee plugin:

1|homebridge  |  ---
1|homebridge  | Loading 1 platforms...
1|homebridge  | Initializing homee platform...
1|homebridge  | connected to homee. Retrying...
1|homebridge  | connected to homee. Retrying...
1|homebridge  | [homee] Error: cannot recieve access token, error Error: connect EHOSTUNREACH 192.1xx.1xx.1xx:7xxx
1|homebridge  |     at Request.request.post [as _callback] (/home/pi/.nvm/versions/node/v10.14.2/lib/node_modules/homebridge-homee/node_modules/homee-api/homee.js:90:28)
1|homebridge  |     at self.callback (/home/pi/.nvm/versions/node/v10.14.2/lib/node_modules/homebridge-homee/node_modules/request/request.js:185:22)
1|homebridge  |     at Request.emit (events.js:182:13)
1|homebridge  |     at Request.onRequestError (/home/pi/.nvm/versions/node/v10.14.2/lib/node_modules/homebridge-homee/node_modules/request/request.js:881:8)
1|homebridge  |     at ClientRequest.emit (events.js:182:13)
1|homebridge  |     at Socket.socketErrorListener (_http_client.js:392:9)
1|homebridge  |     at Socket.emit (events.js:182:13)
1|homebridge  |     at emitErrorNT (internal/streams/destroy.js:82:8)
1|homebridge  |     at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
1|homebridge  |     at args.(anonymous function) (/home/pi/.nvm/versions/node/v10.14.2/lib/node_modules/pm2/node_modules/event-loop-inspector/index.js:138:29)
1|homebridge  | Not connected to homee. Retrying...
1|homebridge  | Not connected to homee. Retrying...
1|homebridge  | Not connected to homee. Retrying...
1|homebridge  | connected to homee. Retrying...
1|homebridge  | Can't get devices or homeegrams. Please check that homee is online and your config is right

This ist the code snippet mentioned above in the 7. line (homee.js:90:28)

 _getAccessToken() {
        debug('get access token')
        const options = {
            url: this._url() + '/access_token',
            headers: {'Content-Type': 'application/x-www-form-urlencoded'},
            form: {
                device_name: this._device,
                device_hardware_id: this._deviceId,
                device_os: 5, // Linux
                device_type: 3, // Desktop
                device_app: 1 // homee
            },
            auth: {
                user: this._user,
                pass: shajs('sha512').update(this._password).digest('hex')
            }
        };

If I try to access the URL url: this._url() + '/access_token' from a browser, it's only downloading an empty file with no extension. Maybe the API or the endpoint to get an access token changed...or am I getting something wrong? I tried to google the problem but without any success. I only found out that the access token last for 1 year, maybe that's why no one else has that issue at this time.
If you need further information, feel free to ask. Thanks for your help!

stfnhmplr commented 5 years ago

You can't just call this URL from the browser, because a POST request is required. Please double check homee's IP and make sure that your homee is reachable in the network. EHOSTUNREACH means, that no host can be reached under the given address.