From 16bf6903bd2b0fd4a70c961edb929a9a796eb5f6 Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Tue, 7 Jun 2022 00:07:49 -0400 Subject: [PATCH] Bump pyeight to 0.3.0 (#73151) --- homeassistant/components/eight_sleep/__init__.py | 14 ++++++++------ .../components/eight_sleep/binary_sensor.py | 2 +- homeassistant/components/eight_sleep/manifest.json | 2 +- homeassistant/components/eight_sleep/sensor.py | 8 ++++---- requirements_all.txt | 2 +- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/homeassistant/components/eight_sleep/__init__.py b/homeassistant/components/eight_sleep/__init__.py index e986a7f6d60..1bf22defd74 100644 --- a/homeassistant/components/eight_sleep/__init__.py +++ b/homeassistant/components/eight_sleep/__init__.py @@ -63,9 +63,10 @@ CONFIG_SCHEMA = vol.Schema( def _get_device_unique_id(eight: EightSleep, user_obj: EightUser | None = None) -> str: """Get the device's unique ID.""" - unique_id = eight.deviceid + unique_id = eight.device_id + assert unique_id if user_obj: - unique_id = f"{unique_id}.{user_obj.userid}.{user_obj.side}" + unique_id = f"{unique_id}.{user_obj.user_id}.{user_obj.side}" return unique_id @@ -133,9 +134,10 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: for sens in sensor: side = sens.split("_")[1] - userid = eight.fetch_userid(side) - usrobj = eight.users[userid] - await usrobj.set_heating_level(target, duration) + user_id = eight.fetch_user_id(side) + assert user_id + usr_obj = eight.users[user_id] + await usr_obj.set_heating_level(target, duration) await heat_coordinator.async_request_refresh() @@ -163,7 +165,7 @@ class EightSleepBaseEntity(CoordinatorEntity[DataUpdateCoordinator]): self._user_id = user_id self._sensor = sensor self._user_obj: EightUser | None = None - if self._user_id: + if user_id: self._user_obj = self._eight.users[user_id] mapped_name = NAME_MAP.get(sensor, sensor.replace("_", " ").title()) diff --git a/homeassistant/components/eight_sleep/binary_sensor.py b/homeassistant/components/eight_sleep/binary_sensor.py index 868a5177cfe..94ec423390f 100644 --- a/homeassistant/components/eight_sleep/binary_sensor.py +++ b/homeassistant/components/eight_sleep/binary_sensor.py @@ -36,7 +36,7 @@ async def async_setup_platform( entities = [] for user in eight.users.values(): entities.append( - EightHeatSensor(heat_coordinator, eight, user.userid, "bed_presence") + EightHeatSensor(heat_coordinator, eight, user.user_id, "bed_presence") ) async_add_entities(entities) diff --git a/homeassistant/components/eight_sleep/manifest.json b/homeassistant/components/eight_sleep/manifest.json index e4c5a1e0029..e83b2977b77 100644 --- a/homeassistant/components/eight_sleep/manifest.json +++ b/homeassistant/components/eight_sleep/manifest.json @@ -2,7 +2,7 @@ "domain": "eight_sleep", "name": "Eight Sleep", "documentation": "https://www.home-assistant.io/integrations/eight_sleep", - "requirements": ["pyeight==0.2.0"], + "requirements": ["pyeight==0.3.0"], "codeowners": ["@mezz64", "@raman325"], "iot_class": "cloud_polling", "loggers": ["pyeight"] diff --git a/homeassistant/components/eight_sleep/sensor.py b/homeassistant/components/eight_sleep/sensor.py index b405617e276..b2afa496149 100644 --- a/homeassistant/components/eight_sleep/sensor.py +++ b/homeassistant/components/eight_sleep/sensor.py @@ -73,11 +73,11 @@ async def async_setup_platform( for obj in eight.users.values(): for sensor in EIGHT_USER_SENSORS: all_sensors.append( - EightUserSensor(user_coordinator, eight, obj.userid, sensor) + EightUserSensor(user_coordinator, eight, obj.user_id, sensor) ) for sensor in EIGHT_HEAT_SENSORS: all_sensors.append( - EightHeatSensor(heat_coordinator, eight, obj.userid, sensor) + EightHeatSensor(heat_coordinator, eight, obj.user_id, sensor) ) for sensor in EIGHT_ROOM_SENSORS: all_sensors.append(EightRoomSensor(user_coordinator, eight, sensor)) @@ -109,7 +109,7 @@ class EightHeatSensor(EightSleepBaseEntity, SensorEntity): ) @property - def native_value(self) -> int: + def native_value(self) -> int | None: """Return the state of the sensor.""" assert self._user_obj return self._user_obj.heating_level @@ -270,4 +270,4 @@ class EightRoomSensor(EightSleepBaseEntity, SensorEntity): @property def native_value(self) -> int | float | None: """Return the state of the sensor.""" - return self._eight.room_temperature() + return self._eight.room_temperature diff --git a/requirements_all.txt b/requirements_all.txt index c968971cb54..6ae6cdbaa1a 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1468,7 +1468,7 @@ pyedimax==0.2.1 pyefergy==22.1.1 # homeassistant.components.eight_sleep -pyeight==0.2.0 +pyeight==0.3.0 # homeassistant.components.emby pyemby==1.8