Skip Shelly entry reload when plug LED settings change (#188575)

This commit is contained in:
Christopher Pruijsen
2026-10-25 20:18:49 +02:00
committed by GitHub
parent a619a3938c
commit 49fd295776
2 changed files with 45 additions and 0 deletions
@@ -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(
@@ -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,