From 9d04ba280470d945c24faf1a19384e85b96073ae Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Fri, 2 Jul 2021 01:36:48 -0400 Subject: [PATCH] Bump eight sleep dependency to fix bug (#52408) --- .../components/eight_sleep/__init__.py | 27 ++++++++----------- .../components/eight_sleep/binary_sensor.py | 14 +++++----- .../components/eight_sleep/manifest.json | 2 +- requirements_all.txt | 2 +- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/homeassistant/components/eight_sleep/__init__.py b/homeassistant/components/eight_sleep/__init__.py index 67c195da3e6..4e16cd1087f 100644 --- a/homeassistant/components/eight_sleep/__init__.py +++ b/homeassistant/components/eight_sleep/__init__.py @@ -11,10 +11,10 @@ from homeassistant.const import ( CONF_PASSWORD, CONF_SENSORS, CONF_USERNAME, - EVENT_HOMEASSISTANT_STOP, ) from homeassistant.core import callback from homeassistant.helpers import discovery +from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv from homeassistant.helpers.dispatcher import ( async_dispatcher_connect, @@ -29,7 +29,6 @@ _LOGGER = logging.getLogger(__name__) CONF_PARTNER = "partner" DATA_EIGHT = "eight_sleep" -DEFAULT_PARTNER = False DOMAIN = "eight_sleep" HEAT_ENTITY = "heat" @@ -86,12 +85,15 @@ SERVICE_EIGHT_SCHEMA = vol.Schema( CONFIG_SCHEMA = vol.Schema( { - DOMAIN: vol.Schema( - { - vol.Required(CONF_USERNAME): cv.string, - vol.Required(CONF_PASSWORD): cv.string, - vol.Optional(CONF_PARTNER, default=DEFAULT_PARTNER): cv.boolean, - } + DOMAIN: vol.All( + cv.deprecated(CONF_PARTNER), + vol.Schema( + { + vol.Required(CONF_USERNAME): cv.string, + vol.Required(CONF_PASSWORD): cv.string, + vol.Optional(CONF_PARTNER): cv.boolean, + } + ), ) }, extra=vol.ALLOW_EXTRA, @@ -104,7 +106,6 @@ async def async_setup(hass, config): conf = config.get(DOMAIN) user = conf.get(CONF_USERNAME) password = conf.get(CONF_PASSWORD) - partner = conf.get(CONF_PARTNER) if hass.config.time_zone is None: _LOGGER.error("Timezone is not set in Home Assistant") @@ -112,7 +113,7 @@ async def async_setup(hass, config): timezone = str(hass.config.time_zone) - eight = EightSleep(user, password, timezone, partner, None, hass.loop) + eight = EightSleep(user, password, timezone, async_get_clientsession(hass)) hass.data[DATA_EIGHT] = eight @@ -190,12 +191,6 @@ async def async_setup(hass, config): DOMAIN, SERVICE_HEAT_SET, async_service_handler, schema=SERVICE_EIGHT_SCHEMA ) - async def stop_eight(event): - """Handle stopping eight api session.""" - await eight.stop() - - hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, stop_eight) - return True diff --git a/homeassistant/components/eight_sleep/binary_sensor.py b/homeassistant/components/eight_sleep/binary_sensor.py index 803b20383b6..d8a763c2e54 100644 --- a/homeassistant/components/eight_sleep/binary_sensor.py +++ b/homeassistant/components/eight_sleep/binary_sensor.py @@ -1,7 +1,10 @@ """Support for Eight Sleep binary sensors.""" import logging -from homeassistant.components.binary_sensor import BinarySensorEntity +from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_OCCUPANCY, + BinarySensorEntity, +) from . import CONF_BINARY_SENSORS, DATA_EIGHT, NAME_MAP, EightSleepHeatEntity @@ -34,13 +37,15 @@ class EightHeatSensor(EightSleepHeatEntity, BinarySensorEntity): self._sensor = sensor self._mapped_name = NAME_MAP.get(self._sensor, self._sensor) - self._name = f"{name} {self._mapped_name}" self._state = None self._side = self._sensor.split("_")[0] self._userid = self._eight.fetch_userid(self._side) self._usrobj = self._eight.users[self._userid] + self._attr_name = f"{name} {self._mapped_name}" + self._attr_device_class = DEVICE_CLASS_OCCUPANCY + _LOGGER.debug( "Presence Sensor: %s, Side: %s, User: %s", self._sensor, @@ -48,11 +53,6 @@ class EightHeatSensor(EightSleepHeatEntity, BinarySensorEntity): self._userid, ) - @property - def name(self): - """Return the name of the sensor, if any.""" - return self._name - @property def is_on(self): """Return true if the binary sensor is on.""" diff --git a/homeassistant/components/eight_sleep/manifest.json b/homeassistant/components/eight_sleep/manifest.json index d0f86d5a5e4..fb3762cf738 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.1.5"], + "requirements": ["pyeight==0.1.8"], "codeowners": ["@mezz64"], "iot_class": "cloud_polling" } diff --git a/requirements_all.txt b/requirements_all.txt index 5ae7791e591..3a7808389df 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1409,7 +1409,7 @@ pyeconet==0.1.14 pyedimax==0.2.1 # homeassistant.components.eight_sleep -pyeight==0.1.5 +pyeight==0.1.8 # homeassistant.components.emby pyemby==1.7