diff --git a/homeassistant/components/shelly/coordinator.py b/homeassistant/components/shelly/coordinator.py index 2eef9b6120e..f2a43accb0e 100644 --- a/homeassistant/components/shelly/coordinator.py +++ b/homeassistant/components/shelly/coordinator.py @@ -161,6 +161,7 @@ class ShellyBlockCoordinator(ShellyCoordinatorBase[BlockDevice]): self._last_mode: str | None = None self._last_effect: int | None = None self._last_input_events_count: dict = {} + self._last_target_temp: float | None = None entry.async_on_unload( self.async_add_listener(self._async_device_updates_handler) @@ -194,6 +195,18 @@ class ShellyBlockCoordinator(ShellyCoordinatorBase[BlockDevice]): if block.type == "device": cfg_changed = block.cfgChanged + if self.model == "SHTRV-01": + # Reloading the entry is not needed when the target temperature changes + if "targetTemp" in block.sensor_ids: + if self._last_target_temp != block.targetTemp: + self._last_cfg_changed = None + self._last_target_temp = block.targetTemp + # Reloading the entry is not needed when the mode changes + if "mode" in block.sensor_ids: + if self._last_mode != block.mode: + self._last_cfg_changed = None + self._last_mode = block.mode + # For dual mode bulbs ignore change if it is due to mode/effect change if self.model in DUAL_MODE_LIGHT_MODELS: if "mode" in block.sensor_ids: diff --git a/tests/components/shelly/test_climate.py b/tests/components/shelly/test_climate.py index 527aa44c892..f7f451f80e2 100644 --- a/tests/components/shelly/test_climate.py +++ b/tests/components/shelly/test_climate.py @@ -35,8 +35,13 @@ ENTITY_ID = f"{CLIMATE_DOMAIN}.test_name" async def test_climate_hvac_mode(hass, mock_block_device, monkeypatch): """Test climate hvac mode service.""" monkeypatch.delattr(mock_block_device.blocks[DEVICE_BLOCK_ID], "targetTemp") + monkeypatch.setattr( + mock_block_device.blocks[SENSOR_BLOCK_ID], + "sensor_ids", + {"battery": 98, "valvePos": 50, "targetTemp": 21.0}, + ) monkeypatch.setattr(mock_block_device.blocks[DEVICE_BLOCK_ID], "valveError", 0) - await init_integration(hass, 1, sleep_period=1000) + await init_integration(hass, 1, sleep_period=1000, model="SHTRV-01") # Make device online mock_block_device.mock_update() @@ -131,7 +136,7 @@ async def test_climate_set_preset_mode(hass, mock_block_device, monkeypatch): monkeypatch.delattr(mock_block_device.blocks[DEVICE_BLOCK_ID], "targetTemp") monkeypatch.setattr(mock_block_device.blocks[DEVICE_BLOCK_ID], "valveError", 0) monkeypatch.setattr(mock_block_device.blocks[DEVICE_BLOCK_ID], "mode", None) - await init_integration(hass, 1, sleep_period=1000) + await init_integration(hass, 1, sleep_period=1000, model="SHTRV-01") # Make device online mock_block_device.mock_update()