Bump pyeight to 0.3.0 (#73151)

This commit is contained in:
Raman Gupta 2022-06-07 00:07:49 -04:00 committed by GitHub
parent 05e5dd7baf
commit 16bf6903bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 13 deletions

View File

@ -63,9 +63,10 @@ CONFIG_SCHEMA = vol.Schema(
def _get_device_unique_id(eight: EightSleep, user_obj: EightUser | None = None) -> str: def _get_device_unique_id(eight: EightSleep, user_obj: EightUser | None = None) -> str:
"""Get the device's unique ID.""" """Get the device's unique ID."""
unique_id = eight.deviceid unique_id = eight.device_id
assert unique_id
if user_obj: 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 return unique_id
@ -133,9 +134,10 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
for sens in sensor: for sens in sensor:
side = sens.split("_")[1] side = sens.split("_")[1]
userid = eight.fetch_userid(side) user_id = eight.fetch_user_id(side)
usrobj = eight.users[userid] assert user_id
await usrobj.set_heating_level(target, duration) usr_obj = eight.users[user_id]
await usr_obj.set_heating_level(target, duration)
await heat_coordinator.async_request_refresh() await heat_coordinator.async_request_refresh()
@ -163,7 +165,7 @@ class EightSleepBaseEntity(CoordinatorEntity[DataUpdateCoordinator]):
self._user_id = user_id self._user_id = user_id
self._sensor = sensor self._sensor = sensor
self._user_obj: EightUser | None = None self._user_obj: EightUser | None = None
if self._user_id: if user_id:
self._user_obj = self._eight.users[user_id] self._user_obj = self._eight.users[user_id]
mapped_name = NAME_MAP.get(sensor, sensor.replace("_", " ").title()) mapped_name = NAME_MAP.get(sensor, sensor.replace("_", " ").title())

View File

@ -36,7 +36,7 @@ async def async_setup_platform(
entities = [] entities = []
for user in eight.users.values(): for user in eight.users.values():
entities.append( entities.append(
EightHeatSensor(heat_coordinator, eight, user.userid, "bed_presence") EightHeatSensor(heat_coordinator, eight, user.user_id, "bed_presence")
) )
async_add_entities(entities) async_add_entities(entities)

View File

@ -2,7 +2,7 @@
"domain": "eight_sleep", "domain": "eight_sleep",
"name": "Eight Sleep", "name": "Eight Sleep",
"documentation": "https://www.home-assistant.io/integrations/eight_sleep", "documentation": "https://www.home-assistant.io/integrations/eight_sleep",
"requirements": ["pyeight==0.2.0"], "requirements": ["pyeight==0.3.0"],
"codeowners": ["@mezz64", "@raman325"], "codeowners": ["@mezz64", "@raman325"],
"iot_class": "cloud_polling", "iot_class": "cloud_polling",
"loggers": ["pyeight"] "loggers": ["pyeight"]

View File

@ -73,11 +73,11 @@ async def async_setup_platform(
for obj in eight.users.values(): for obj in eight.users.values():
for sensor in EIGHT_USER_SENSORS: for sensor in EIGHT_USER_SENSORS:
all_sensors.append( all_sensors.append(
EightUserSensor(user_coordinator, eight, obj.userid, sensor) EightUserSensor(user_coordinator, eight, obj.user_id, sensor)
) )
for sensor in EIGHT_HEAT_SENSORS: for sensor in EIGHT_HEAT_SENSORS:
all_sensors.append( all_sensors.append(
EightHeatSensor(heat_coordinator, eight, obj.userid, sensor) EightHeatSensor(heat_coordinator, eight, obj.user_id, sensor)
) )
for sensor in EIGHT_ROOM_SENSORS: for sensor in EIGHT_ROOM_SENSORS:
all_sensors.append(EightRoomSensor(user_coordinator, eight, sensor)) all_sensors.append(EightRoomSensor(user_coordinator, eight, sensor))
@ -109,7 +109,7 @@ class EightHeatSensor(EightSleepBaseEntity, SensorEntity):
) )
@property @property
def native_value(self) -> int: def native_value(self) -> int | None:
"""Return the state of the sensor.""" """Return the state of the sensor."""
assert self._user_obj assert self._user_obj
return self._user_obj.heating_level return self._user_obj.heating_level
@ -270,4 +270,4 @@ class EightRoomSensor(EightSleepBaseEntity, SensorEntity):
@property @property
def native_value(self) -> int | float | None: def native_value(self) -> int | float | None:
"""Return the state of the sensor.""" """Return the state of the sensor."""
return self._eight.room_temperature() return self._eight.room_temperature

View File

@ -1468,7 +1468,7 @@ pyedimax==0.2.1
pyefergy==22.1.1 pyefergy==22.1.1
# homeassistant.components.eight_sleep # homeassistant.components.eight_sleep
pyeight==0.2.0 pyeight==0.3.0
# homeassistant.components.emby # homeassistant.components.emby
pyemby==1.8 pyemby==1.8