Eight Sleep component

I got tired of waiting for the official API to become available and wrote up a component based on what I could intercept from the mobile app. I’ve been building and testing it over the past month or so and I think it’s at a point where feedback from others would be beneficial while I wrap up a few of the remaining loose ends.

If anyone is interested in testing please send me a PM and i’ll give you the details on how to set things up.

Support for Eight Sleep covers and mattresses has been submitted to HASS. Please feel free to checkout the PR to test if you’d like before it gets merged.

3 Likes

Awesome! No longer need to rely on partial send support via IFTTT.
So much added usability and sensing data from the new component.

Question: how responsive is the presence detection, is there much delay?

I would say presence detection is just OK at the moment. It definitely needs work, but I didn’t want to hold up the PR process any longer while I played around with it.

In bed detection happens fairly quickly, usually within 1-3 minutes, but out of bed detection is slower, usually 5-10 minutes. With the data available it’s hard to find a balance between quick detection and false positives since in my tests there are often natural temperature drops during sleep that when looked at over a small window look the same as if someone actually left the bed.

Oh not too bad.
I guess we won’t be able to get anything more timely until the open up an API for the raw status on the hub rather than having to rely on their processed data.

Yes and no. It all depends on what kind of information they have available that they aren’t exposing to the api. Everything is temperature based right now, if they have something available related to pressure that would be the easiest to use to get faster status.

This has now been merged into dev so running the latest dev build is currently the easiest way to test things out before the next release.

Cool, I didn’t realise it was currently based off of the temperature readings. As the next full release is a few days away I will wait for that, but will be checking this out first thing!

I hope this integration with HASS will automatically detect when someone leaves/enters the bed? And both sides of the bed?

It is unbelievable that their current app requires you to first choose for day / night mode, which then launches an IFTTT request. What is the added value to that?

Pinged them twice about an automatic IFTTT request, no luck so far. But this integration would even be beter then

Got it setup, no issues there!

Anyone have any examples of templates or automations they have setup or planned using the new Eight component?

It does detect when someone leaves/enters the bed for both sides, but unfortunately due to limitations with the data available from the api (all temperature based) it’s not exactly realtime, typically a 5-10 min delay.

@Pawny Glad it’s working for you!

Thanks for your hard work @mezz64 on this. Got it all setup!

@Pawny so far I built into my morning alarm a tts over my Sonos that summarizes my last nights sleep score and a few stats. I plan to replace my ifttt switch with one that I can select the heating temp and turn it on or off. Then expose to emulated_hue for Alexa. I third, I was also going to try a morning alarm delay based on my sleep state but since the API is behind by 10 minutes or so not sure how accurate it will be. I’ll give it a try and see how it works anyway. Let me know if there’s something you’re interested in and I can post the config for it here.

Hi there,

I am just not having any luck in trying to set this up. I’ve tried many times last night and I still get:

2017-05-12 16:42:53 ERROR (MainThread) [homeassistant.setup] Setup failed for script: Invalid config.
2017-05-12 16:43:00 ERROR (MainThread) [homeassistant.setup] Error during setup of component eight_sleep

Is the only thing required the addition of these 3 lines in configuration.yaml?
eight_sleep:
username: “[email protected]
password: “password”

And the user id and password should be in quotes?
Should it be under a certain category such as a sensor or just by itself in configuration.yaml?

Any help would be great.

This is all that’s required in the configuration.yaml (spaces are important):

eight_sleep:
  username: "[email protected]"
  password: "password"

If that doesn’t work make sure you are on at least release 0.44. If all that matches up you can add in the partner line just to verify, although it’s set to optional so it shouldn’t be required.

  partner: false

Thanks for chiming in mezz64
But I am still having the same issue. I did fix the spacing issue, I had 4 spaces instead of 2 in front of user and password. I’ve also rebooted and had 0.44 and upgraded to 0.44.1. Still no luck.
I made sure that I had the correct credentials by loging out and back in the mobile app.
I was really looking forward into getting this going

Based on the two log lines you posted it seems to be a configuration issue. It hasn’t even tried to load the component yet so it’s not a bad password or user.

Am I correct in assuming that everything works OK once you remove the eight_sleep section from your configuration.yaml?

Can you check in the home assistant installation directory and verify you have the following files present:

homeassistant/components/eight_sleep.py
homeassistant/components/sensor/eight_sleep.py
homeassistant/components/binary_sensor/eight_sleep.py

Is there a service to turn off the bed heat? Preferably something other than heat_set since if I put it to 0 my daily schedule from the app will warm to 0 which is essentially off. Thanks

Setting the duration to 0 (keep the level the same) will turn off the heat.

You could probably make an automation to turn it off without changing the level by fetching the Target Heat Level attribute from the Bed State sensor for your side of the bed and passing that along with a duration of 0 to the service.

Are those directories under the hass/.homeassistant directory? if so, I have no directory name “components”. I would then think that it’s somewhere else, but I would have no idea where it would be located.

I wouldn’t rack your brain too long with this one, I may have some other underlying issues. I tried to install the Ring component, and that’s not working either.

Some other errors that shows up are:
File “/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/eight_sleep.py”, line 112, in async_setup
success = yield from eight.start()
File “/home/hass/.homeassistant/deps/pyeight/eight.py”, line 110, in start
yield from self.assign_users()
File “/home/hass/.homeassistant/deps/pyeight/eight.py”, line 161, in assign_users
EightUser(self, data[‘result’][‘leftUserId’], ‘left’)
KeyError: ‘leftUserId’

But again, I may have some other issues. I would hate to have to redo everything from scratch, but I may have to.

Looks like you may have found a bug with only looking at one side of the bed actually. I’ll take a look through that scenario and let you know.

There was a race condition for single users on the right side of the bed. I was checking the left first without thinking that in a single user situation the left may not even exist.

I’ve implemented a fix and submitted a PR. It may make it’s way into a hotfix release, but otherwise i’d expect it to be merged for 0.45.