lukas-clarke / eight_sleep

Home Assistant Eight Sleep integration that works with Eight Sleep's new API and OAUTH2
MIT License
89 stars 17 forks source link

Unable to load integration when away mode is turned on #40

Closed Mrtenz closed 3 weeks ago

Mrtenz commented 1 month ago

Found a small bug when setting up the integration again while my pod was in away mode. It fails to load with this error:

2024-08-09 17:31:34.943 ERROR (MainThread) [custom_components.eight_sleep] Unexpected error fetching eight_sleep_user data
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 354, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 271, in _async_update_data
    return await self.update_method()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/eight_sleep/pyEight/eight.py", line 233, in update_user_data
    await obj.update_user()
  File "/config/custom_components/eight_sleep/pyEight/user.py", line 674, in update_user
    current_side_temp_raw = await self.get_current_device_level()
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/eight_sleep/pyEight/user.py", line 748, in get_current_device_level
    return int(resp["currentDeviceLevel"])
               ~~~~^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'currentDeviceLevel'

Not a big deal and turning off away mode before loading the integration fixes it, but I figured I'd make an issue anyway in case others run into this.

johnser commented 1 month ago

Having this issue as I am not subscribed and I can't change the pod from away mode. Anyone have a workaround if you're in this boat?