tjmehta / homebridge-eightsleep-platform

Homebridge Plugin for supporting the Eightsleep Pod
Apache License 2.0
13 stars 2 forks source link

Config info is not working #5

Open ChewietheWookiee opened 3 years ago

ChewietheWookiee commented 3 years ago

Sorry maybe i am just being a noob, but I cant get the config to save when I add what you suggested. I also assume one needs to get the oauth ID and secret from somewhere but i am not sure how to find that. mind helping me out?

ChewietheWookiee commented 3 years ago

ok I sorted out the syntax in my config file. but I assume I need help to get the oauth info as this is the error I'm getting:

`[1/6/2021, 8:07:30 AM] [EightSleepPod] Get RotationSpeed Error -> InvalidResponseError: invalid response at Function.wrap (/usr/lib/node_modules/homebridge-eightsleep-pod/node_modules/baseerr/src/index.ts:51:12) at EightSleepClientApi. (/usr/lib/node_modules/homebridge-eightsleep-pod/node_modules/simple-api-client/src/index.ts:244:34) at Generator.throw () at rejected (/usr/lib/node_modules/homebridge-eightsleep-pod/node_modules/simple-api-client/dist/cjs/index.js:6:65) at processTicksAndRejections (internal/process/task_queues.js:93:5) { "status": 401, "headers": {}, "path": "users/oauth-token", "init": { "method": "POST", "headers": { "accept": "application/json", "content-type": "application/json", "user-agent": "Eight/786 CFNetwork/1125.2 Darwin/19.4.0", "accept-language": "en-us", "accept-encoding": "gzip, deflate, br", "user-id": "f2886ebe4e854c178541a919851cf905", "session-token": "f0272abf9cc34486a247c2f90990c515-ce4c7be2275438a8908d96f46d57fdcf" }, "body": "{\"client_id\":\"clientid....\",\"client_secret\":\"clientsecret....\"}" } }

FetchError: invalid json response body at https://client-api.8slp.net/v1/users/oauth-token reason: Unexpected end of JSON input at /usr/lib/node_modules/homebridge-eightsleep-pod/node_modules/node-fetch/lib/index.js:272:32 at processTicksAndRejections (internal/process/task_queues.js:93:5) { status: 401, headers: Headers { [Symbol(map)]: [Object: null prototype] { date: [Array], 'content-length': [Array], connection: [Array], 'x-powered-by': [Array] } }, path: 'users/oauth-token', init: { method: 'POST', headers: { accept: 'application/json', 'content-type': 'application/json', 'user-agent': 'Eight/786 CFNetwork/1125.2 Darwin/19.4.0', 'accept-language': 'en-us', 'accept-encoding': 'gzip, deflate, br', 'user-id': 'f2886ebe4e854c178541a919851cf905', 'session-token': 'f0272abf9cc34486a247c2f90990c515-ce4c7be2275438a8908d96f46d57fdcf' }, body: '{"client_id":"clientid....","client_secret":"clientsecret...."}' } }`

tjmehta commented 3 years ago

hey! I haven't looked at this in a bit you can just provide email and password in the config it should login for you after that. lmk if that works out for you and feel free to update the docs marking oauthClient as optional

EDIT: not true, see comment below - https://github.com/tjmehta/homebridge-eightsleep-platform/issues/5#issuecomment-855593606

nstefanelli commented 3 years ago

Hi - having the same issue as above. If I remove the oAuth line as suggested, I get an error that it is required.

What do you recommend I try? Here is my current config:

{ "name": "Eightsleep", "platform": "EightSleepPod", "email": "myemail@me.com", "password": "mypassword", "oauthClient": { "id": "clientid...." "secret": "clientsecret...." } }

ftoralesacosta commented 3 years ago

Hi - having the same issue as the two above....

fyi: when the oauthClient line in the config is omitted, for example:

        {
          "name": "EighSleep",
          "platform": "EightSleepPod",
          "email": "myemail@me.com"
          "password": "mypassword"
        }

I get the several instances of following oath error in the homebridge logs:

RotationSpeed Error -> BaseError: appApiClient is missing (client should be instantiated with oauthClient)^[[39m
^[[31m    at EightSleepClientApi.getAppApiClient (/usr/local/lib/node_modules/homebridge-eightsleep-pod/node_modules/eightsleep/src/index.ts:144:13

Looking through your very nice Eightsleep api client for Node.js repo, doesn't the client take as input the oath id?

Lmk if I can provide more information to help.

abonstu commented 3 years ago

same issue here - the api client wants oauth token (even with oauth attribute omitted from config):

[Eight Sleep Pod] Get Active Error -> BaseError: appApiClient is missing (client should be instantiated with oauthClient)
    at EightSleepClientApi.getAppApiClient (/usr/local/lib/node_modules/homebridge-eightsleep-pod/node_modules/eightsleep/src/index.ts:144:13)
    at /usr/local/lib/node_modules/homebridge-eightsleep-pod/src/EightSleepPod.ts:44:20
    at Object.<anonymous> (/usr/local/lib/node_modules/homebridge-eightsleep-pod/node_modules/memoize-concurrent/src/index.ts:31:22)
    at Generator.next (<anonymous>)
    at /usr/local/lib/node_modules/homebridge-eightsleep-pod/node_modules/memoize-concurrent/dist/cjs/index.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/usr/local/lib/node_modules/homebridge-eightsleep-pod/node_modules/memoize-concurrent/dist/cjs/index.js:4:12)
    at EightSleepPod.<anonymous> (/usr/local/lib/node_modules/homebridge-eightsleep-pod/node_modules/memoize-concurrent/src/index.ts:29:66)
    at EightSleepPod.getDeviceStatus (/usr/local/lib/node_modules/homebridge-eightsleep-pod/node_modules/mem/index.js:24:21)
    at EightSleepPod.getStatus (/usr/local/lib/node_modules/homebridge-eightsleep-pod/src/EightSleepPod.ts:48:37)
tjmehta commented 3 years ago

alright this took entirely way too long but I think I resolved it. the reason why I never updated this is bc I was providing oauth id and secret directly, so I never saw the issue when providing user/pass only. anyways at somepoint my auth expired and I ran into the problem myself so I think I fixed it. going to test it out in the next few hours.

tjmehta commented 3 years ago

hmm okay nvm I am not able to get it to work using only username/password. the oauthClient id and secret are required. the way that I was able to get this information was using the Charles iOS app to spy on all the requests the Eightsleep app was making on my iPhone. look for a POST request to /v1/users/oauth-token and view the request body.

you will see something like this:

{
    "client_id": "<hex-string>",
    "client_secret": "<hex-string>"
}

plug those values into your config:

{
            "platform": "EightSleepPod",
            "email": "<email address>",
            "password": "<password>",
            "oauthClient": {
                "id": "<hex-string-client-id-from-above>",
                "secret": "<hex-string-client-secret-from-above>"
            }
}
ftoralesacosta commented 3 years ago

Hi tjmehta,

I was able to get my id and secret, and will input that into my config when I get a chance (this week is pretty busy unfortunately). Many thanks for the info!

By the way, I’ve been looking into this since I last posted on this issue, and the home-assistant implementation for 8sleep uses pyeight repo in the background. There are some trade offs compared to your repo but their implementation just required username and password of the eight sleep account: https://github.com/mezz64/pyEight/blob/master/pyeight/user.py

I’ll take a closer look soon, thanks again the the response!

ftoralesacosta commented 3 years ago

Just tried it, works great!

carbonappsx commented 3 years ago

Here's what I have in homebridge and it's not working. Any ideas?

{ "platform": "ExampleHomebridgePlugin", "email": "email", "password": "pass", "oauthClient": { "id": "08xxxxxxx", "secret": "f09xxxxxxx" } }

ftoralesacosta commented 3 years ago

Hm, make sure the platform is "EightSleepPod", and if you're using the home bridge UI to edit the config file, it should point out to you any other syntax errors. Otherwise, you'll have to post the errors your getting to debug.

carbonappsx commented 2 years ago

Getting an error after the new firmware upgrade:

[ExampleHomebridgePlugin] Get TargetHeaterCoolerState Error -> InvalidSideStatusError: invalid currentTargetLevel at validateSideStatus (/usr/local/lib/node_modules/homebridge-eightsleep-pod/node_modules/eightsleep/src/validateDeviceStatus.ts:76:11) at Object.validateDeviceStatus [as default] (/usr/local/lib/node_modules/homebridge-eightsleep-pod/node_modules/eightsleep/src/validateDeviceStatus.ts:51:11) at EightSleepAppApi. (/usr/local/lib/node_modules/homebridge-eightsleep-pod/node_modules/eightsleep/src/EightSleepAppApi.ts:79:32) at Generator.next () at fulfilled (/usr/local/lib/node_modules/homebridge-eightsleep-pod/node_modules/eightsleep/dist/cjs/EightSleepAppApi.js:5:58) at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:95:5) {

steveb85 commented 1 year ago

@carbonappsx same it worked for a few mins before this. any chance you found a fix?

steveb85 commented 1 year ago

It seems the problem occurs when the unit is set to 0 +- on the app. It has an invalid current target level then,

tjmehta commented 1 year ago

if someone has the charles app on ios you should be able to snoop on the eightsleep app and figure out what they do for setting the temp to 0, ill get to it eventually.. feel free to PR :-D

cmlouie17 commented 7 months ago

I've downloaded Charles but am having trouble getting the client id and secret from the request body. Any help would be appreciated! @tjmehta are you still able to collect them?

carmanj commented 2 months ago

I've downloaded Charles but am having trouble getting the client id and secret from the request body. Any help would be appreciated! @tjmehta are you still able to collect them?

Did you ever sort this out? I do notice the ClientID/Secret has changed since the last time I was actively looking at this back in November. Since then, they actually enforce the ClientID/Secret, which they didn't previously.