From 110fd261ee196daabf05b4ebaca3156619f1d804 Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Mon, 29 Nov 2021 05:18:15 +0100 Subject: [PATCH] Fix & update for latest Shelly Valve firmware (#60458) --- homeassistant/components/shelly/__init__.py | 3 +-- homeassistant/components/shelly/climate.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/shelly/__init__.py b/homeassistant/components/shelly/__init__.py index 4109130ab80..27f25211a96 100644 --- a/homeassistant/components/shelly/__init__.py +++ b/homeassistant/components/shelly/__init__.py @@ -68,13 +68,12 @@ from .utils import ( BLOCK_PLATFORMS: Final = [ "binary_sensor", "button", - "climate", "cover", "light", "sensor", "switch", ] -BLOCK_SLEEPING_PLATFORMS: Final = ["binary_sensor", "sensor"] +BLOCK_SLEEPING_PLATFORMS: Final = ["binary_sensor", "climate", "sensor"] RPC_PLATFORMS: Final = ["binary_sensor", "button", "light", "sensor", "switch"] _LOGGER: Final = logging.getLogger(__name__) diff --git a/homeassistant/components/shelly/climate.py b/homeassistant/components/shelly/climate.py index 8574ac17f46..f2db157ecf2 100644 --- a/homeassistant/components/shelly/climate.py +++ b/homeassistant/components/shelly/climate.py @@ -49,6 +49,9 @@ async def async_setup_entry( if get_device_entry_gen(config_entry) == 2: return + device_block: Block | None = None + sensor_block: Block | None = None + wrapper = hass.data[DOMAIN][DATA_CONFIG_ENTRY][config_entry.entry_id][BLOCK] for block in wrapper.device.blocks: if block.type == "device": @@ -176,7 +179,10 @@ class ShellyClimate(ShellyBlockEntity, RestoreEntity, ClimateEntity): return preset_index = self._attr_preset_modes.index(preset_mode) - await self.set_state_full_path( - schedule=(0 if preset_index == 0 else 1), - schedule_profile=f"{preset_index}", - ) + + if preset_index == 0: + await self.set_state_full_path(schedule=0) + else: + await self.set_state_full_path( + schedule=1, schedule_profile=f"{preset_index}" + )