From 49fd29577641f60df15ec82cb8fa1e3bd2c13221 Mon Sep 17 00:00:00 2001 From: Christopher Pruijsen Date: Sun, 25 Oct 2026 18:18:49 +0000 Subject: [PATCH] Skip Shelly entry reload when plug LED settings change (#188575) --- .../components/shelly/coordinator.py | 4 ++ tests/components/shelly/test_coordinator.py | 41 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/homeassistant/components/shelly/coordinator.py b/homeassistant/components/shelly/coordinator.py index 11e44def1d28..c8d02ff959bd 100644 --- a/homeassistant/components/shelly/coordinator.py +++ b/homeassistant/components/shelly/coordinator.py @@ -662,6 +662,10 @@ class ShellyRpcCoordinator(ShellyCoordinatorBase[RpcDevice]): for event_callback in self._event_listeners: event_callback(event) + # Plug LED settings do not change any entity, so they need no reload + if event_type == "config_changed" and component == "plugs_ui": + continue + if event_type in ("component_added", "component_removed", "config_changed"): self.update_sleep_period() LOGGER.info( diff --git a/tests/components/shelly/test_coordinator.py b/tests/components/shelly/test_coordinator.py index 6467ef968b1e..e955a4978ffd 100644 --- a/tests/components/shelly/test_coordinator.py +++ b/tests/components/shelly/test_coordinator.py @@ -447,6 +447,47 @@ async def test_rpc_reload_on_cfg_change( assert hass.states.get(entity_id) is None +async def test_rpc_no_reload_on_plugs_ui_cfg_change( + hass: HomeAssistant, + freezer: FrozenDateTimeFactory, + mock_rpc_device: Mock, + monkeypatch: pytest.MonkeyPatch, +) -> None: + """Test RPC plug LED config change does not reload the entry.""" + entity_id = "switch.test_name_test_switch_0" + monkeypatch.delitem(mock_rpc_device.status, "cover:0") + monkeypatch.setitem(mock_rpc_device.status["sys"], "relay_in_thermostat", False) + await init_integration(hass, 2) + + # A reload would turn the switch into a light + monkeypatch.setitem( + mock_rpc_device.config["sys"]["ui_data"], "consumption_types", ["lights"] + ) + inject_rpc_device_event( + monkeypatch, + mock_rpc_device, + { + "events": [ + { + "component": "plugs_ui", + "event": "config_changed", + "restart_required": False, + "ts": 1668522399.2, + "cfg_rev": 16, + }, + ], + "ts": 1668522399.2, + }, + ) + await hass.async_block_till_done() + + freezer.tick(timedelta(seconds=ENTRY_RELOAD_COOLDOWN)) + async_fire_time_changed(hass) + await hass.async_block_till_done() + + assert hass.states.get(entity_id) + + async def test_rpc_reload_with_invalid_auth( hass: HomeAssistant, freezer: FrozenDateTimeFactory,