mirror of
https://github.com/home-assistant/core.git
synced 2026-12-03 04:08:19 -04:00
Skip Shelly entry reload when plug LED settings change (#188575)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user