From d17e3974555d9fe38e19e8b6539a67232bb91a7f Mon Sep 17 00:00:00 2001 From: Shay Levy Date: Sat, 16 Mar 2024 16:18:41 +0200 Subject: [PATCH] Ignore Shelly block update with cfgChanged None (#113587) --- homeassistant/components/shelly/coordinator.py | 2 +- tests/components/shelly/test_coordinator.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/shelly/coordinator.py b/homeassistant/components/shelly/coordinator.py index 6d2170bf941..22f81e21b6c 100644 --- a/homeassistant/components/shelly/coordinator.py +++ b/homeassistant/components/shelly/coordinator.py @@ -217,7 +217,7 @@ class ShellyBlockCoordinator(ShellyCoordinatorBase[BlockDevice]): # Check for input events and config change cfg_changed = 0 for block in self.device.blocks: - if block.type == "device": + if block.type == "device" and block.cfgChanged is not None: cfg_changed = block.cfgChanged # Shelly TRV sends information about changing the configuration for no diff --git a/tests/components/shelly/test_coordinator.py b/tests/components/shelly/test_coordinator.py index 4c169998104..c16f78b83ff 100644 --- a/tests/components/shelly/test_coordinator.py +++ b/tests/components/shelly/test_coordinator.py @@ -68,6 +68,18 @@ async def test_block_reload_on_cfg_change( mock_block_device.mock_update() await hass.async_block_till_done() + # Make sure cfgChanged with None is ignored + monkeypatch.setattr(mock_block_device.blocks[DEVICE_BLOCK_ID], "cfgChanged", None) + mock_block_device.mock_update() + await hass.async_block_till_done() + + # Wait for debouncer + freezer.tick(timedelta(seconds=ENTRY_RELOAD_COOLDOWN)) + async_fire_time_changed(hass) + await hass.async_block_till_done() + + assert hass.states.get("switch.test_name_channel_1") is not None + # Generate config change from switch to light monkeypatch.setitem( mock_block_device.settings["relays"][RELAY_BLOCK_ID], "appliance_type", "light"