Eight Sleep component

Great, thanks for you hard work on this and for creating the component in the first place. I’ll give it a go with the next release.

Do you know why the following switch won’t get the state in the value template? I also tried “Heating Active” and it does’t seem to work

  eight_heat:
    value_template: '{{ is_state_attr("sensor.eight_left_bed_state", "heating_active", "true") or is_state_attr("sensor.eight_right_bed_state", "heating_active", "true") }}'
    turn_on:
      service: script.turn_on
      entity_id: script.eight_heat_on
    turn_off:
      service: script.turn_on
      entity_id: script.eight_heat_off

I was using the following syntax style for some template sensors during testing:

{{ states.sensor.eight_left_sleep_session.attributes['Bed Temperature'] }}

Perfect. That worked thanks!

I was finally able to add this component to my setup after a new build with AIO installer. Works great so far. I have a question about the “partner” option. Will this work only with one account or do I need to have another Eight Sleep account in order to detect presence? Also is the “false” or “true” case sensitive? I see in the component that it list false with a capital “F”.

Partner as defined by Eight is a second account associated with the other side of the bed. I don’t believe it will work if there is only one account associated with your mattress/cover.

False/True shouldn’t be case sensitive. It’s just a boolean in the underlying code.

OK, great … thanks for your reply. I’ll setup a second account to see if I can track presence.

Thank you very much for the eight plugin.
It works very well for my side of the bed, but not for my partner’s.

My partner’s presence is always off, and I’m missing most of the sensors( except for presence and state).

Also, in the logs I can see some errors:

2017-08-03 00:35:54 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py”, line 381, in async_process_entity
new_entity, self, update_before_add=update_before_add
File “/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py”, line 210, in async_add_entity
yield from entity.async_update()
File “/usr/lib/python3.5/asyncio/coroutines.py”, line 206, in coro
res = func(*args, **kw)
File “/usr/local/lib/python3.5/dist-packages/homeassistant/components/sensor/eight_sleep.py”, line 178, in async_update
temp = self._usrobj.current_values[‘bed_temp’]
File “/home/liviu/.homeassistant/deps/lib/python3.5/site-packages/pyeight/user.py”, line 283, in current_values
‘date’: self.current_session_date,
File “/home/liviu/.homeassistant/deps/lib/python3.5/site-packages/pyeight/user.py”, line 135, in current_session_date
date = self.intervals[0][‘ts’]
IndexError: list index out of range
2017-08-03 00:35:54 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py”, line 381, in async_process_entity
new_entity, self, update_before_add=update_before_add
File “/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py”, line 210, in async_add_entity
yield from entity.async_update()
File “/usr/lib/python3.5/asyncio/coroutines.py”, line 206, in coro
res = func(*args, **kw)
File “/usr/local/lib/python3.5/dist-packages/homeassistant/components/sensor/eight_sleep.py”, line 175, in async_update
self._state = self._usrobj.last_sleep_score
File “/home/liviu/.homeassistant/deps/lib/python3.5/site-packages/pyeight/user.py”, line 322, in last_sleep_score
score = self.intervals[1][‘score’]
IndexError: list index out of range
2017-08-03 00:35:54 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py”, line 381, in async_process_entity
new_entity, self, update_before_add=update_before_add
File “/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py”, line 210, in async_add_entity
yield from entity.async_update()
File “/usr/lib/python3.5/asyncio/coroutines.py”, line 206, in coro
res = func(*args, **kw)
File “/usr/local/lib/python3.5/dist-packages/homeassistant/components/sensor/eight_sleep.py”, line 172, in async_update
self._state = self._usrobj.current_sleep_score
File “/home/liviu/.homeassistant/deps/lib/python3.5/site-packages/pyeight/user.py”, line 188, in current_sleep_score
score = self.intervals[0][‘score’]
IndexError: list index out of range
2017-08-03 00:35:54 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py”, line 381, in async_process_entity
new_entity, self, update_before_add=update_before_add
File “/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py”, line 210, in async_add_entity
yield from entity.async_update()
File “/usr/lib/python3.5/asyncio/coroutines.py”, line 206, in coro
res = func(*args, **kw)
File “/usr/local/lib/python3.5/dist-packages/homeassistant/components/sensor/eight_sleep.py”, line 256, in async_update
temp = self._eight.room_temperature()
File “/home/liviu/.homeassistant/deps/lib/python3.5/site-packages/pyeight/eight.py”, line 179, in room_temperature
if obj.current_values[‘processing’]:
File “/home/liviu/.homeassistant/deps/lib/python3.5/site-packages/pyeight/user.py”, line 283, in current_values
‘date’: self.current_session_date,
File “/home/liviu/.homeassistant/deps/lib/python3.5/site-packages/pyeight/user.py”, line 135, in current_session_date
date = self.intervals[0][‘ts’]
IndexError: list index out of range
2017-08-03 00:35:54 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py”, line 381, in async_process_entity
new_entity, self, update_before_add=update_before_add
File “/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py”, line 210, in async_add_entity
yield from entity.async_update()
File “/usr/lib/python3.5/asyncio/coroutines.py”, line 206, in coro
res = func(*args, **kw)
File “/usr/local/lib/python3.5/dist-packages/homeassistant/components/sensor/eight_sleep.py”, line 184, in async_update
self._state = self._usrobj.current_values[‘stage’]
File “/home/liviu/.homeassistant/deps/lib/python3.5/site-packages/pyeight/user.py”, line 283, in current_values
‘date’: self.current_session_date,
File “/home/liviu/.homeassistant/deps/lib/python3.5/site-packages/pyeight/user.py”, line 135, in current_session_date
date = self.intervals[0][‘ts’]
IndexError: list index out of range

Thank you very much,
Liviu

Is your partner sharing their data with you? I was never able to confirm during development if that step was required for a single user to access sleep data for both sides, so if they are not sharing it may be the cause of the issue.

If you are not sure, have your partner go into the app and look at the “Manage Bed Sides” section in the menu. The share data toggle should be on.

I made sure the sharing is enabled both ways :slight_smile:

Can you enable debug logging for the pyeight library and post a startup log? The errors you posted seem to indicate that either your partner doesn’t have a certain api endpoint or their user id is not being received.

You can add debug logging like this in your configuration.yaml:

logger:
  default: info
  logs:
    homeassistant.components.eight_sleep: debug
    homeassistant.components.sensor.eight_sleep: debug
    pyeight: debug

Well … This is interesting. The entries started appearing and feeding in data.
The issues must be that I created the partner’s account and allowed data sharing only 2 days ago.
Maybe there is a delay in the eight servers :slight_smile:

Only previous sleep stats value does not show up, but I believe it will in a day or two :slight_smile:

It does seem like sometimes there can be a bit of a delay when things are newly setup. Glad it started working for you.

hi folks,
anyone had issues with the eightsleep app not allowing to use the same user creds as the Hass account info. I have my account and partner account - is there a way to create a 3rd account? or do you sacrifice the phone app?

still no joy - eightsleep works every so often, but on reboot sometimes doesnt initiate properly:
Unable to authenticate and fetch eight token

Yeah I find it sometimes can’t find the component on restarts. But more often then not, Eight has lost connection with even the app so I just have to unplug it and starts working again.

thanks for the reply - anything more reliable than just unplugging it?

Its hard enough getting things working, without the things that do needing to be reset/rebooted/unplugged so often?

should i raise this as a bug?

Yeah I’d raise it. Not sure if this component is causing it to crash or if it’s the Eight Sleep that gives up every once in awhile but it definitely happens more frequently than would like.

1 Like

@jaburges I gave a response on your github issue for this, but I figured i’d repeat it here for completeness.

Unfortunately, the way this component works is to act as if it’s the app, using the same api endpoint and commands, since Eight has never officially released the api.

This means that the component relies upon the Eight api servers to function and can’t do any local interaction with your eight device. Essentially, if you can’t get the app to work, this component also will not work.

It does make a connect/disconnect with each update call, so as long as you can perform the initial authentication to allow the component to be setup, any subsequent failure should only affect the data for that particular update.

1 Like

ah ha, thanks - should we apply some pressure to eight to release an api? :wink:

the app now functions, but when i reboot (which has been a lot as i’ve been making a lot of changes to hass) it fails to initialize the component - which means i cant use it to trigger rules/sleep/wake etc

anything we can do to make it more reliable?