From 9479ef0a3497d333e87f19df1382ada94733dd9a Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Mon, 10 Jan 2022 01:16:13 +0100 Subject: [PATCH] Fix climate channel for Shelly (#63756) * Revert "Improve availability for Shelly Valve" This reverts commit d8cbd81b456820153522e6d86bbd00c4a4a31129. * Fix channel for climate --- homeassistant/components/shelly/climate.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/shelly/climate.py b/homeassistant/components/shelly/climate.py index cd2a5c247d5..4fc6fb33bb8 100644 --- a/homeassistant/components/shelly/climate.py +++ b/homeassistant/components/shelly/climate.py @@ -143,16 +143,17 @@ class BlockSleepingClimate( if self.block is not None and self.device_block is not None: self._unique_id = f"{self.wrapper.mac}-{self.block.description}" - assert self.block.channel self._preset_modes = [ PRESET_NONE, - *wrapper.device.settings["thermostats"][int(self.block.channel)][ + *wrapper.device.settings["thermostats"][cast(int, self.block.channel)][ "schedule_profile_names" ], ] elif entry is not None: self._unique_id = entry.unique_id + self._channel = cast(int, self._unique_id.split("_")[1]) + @property def unique_id(self) -> str: """Set unique id of entity.""" @@ -234,13 +235,6 @@ class BlockSleepingClimate( "connections": {(device_registry.CONNECTION_NETWORK_MAC, self.wrapper.mac)} } - @property - def channel(self) -> str | None: - """Device channel.""" - if self.block is not None: - return self.block.channel - return self.last_state_attributes.get("channel") - def _check_is_off(self) -> bool: """Return if valve is off or on.""" return bool( @@ -254,7 +248,7 @@ class BlockSleepingClimate( try: async with async_timeout.timeout(AIOSHELLY_DEVICE_TIMEOUT_SEC): return await self.wrapper.device.http_request( - "get", f"thermostat/{self.channel}", kwargs + "get", f"thermostat/{self._channel}", kwargs ) except (asyncio.TimeoutError, OSError) as err: _LOGGER.error(