From 7fc1306898fa3639782adda78582606cbf86e73e Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 12 Jan 2022 15:57:12 -1000 Subject: [PATCH] Ensure flux_led is reloaded when the ICtype is changed (#64016) --- homeassistant/components/flux_led/select.py | 4 ++++ tests/components/flux_led/test_select.py | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/flux_led/select.py b/homeassistant/components/flux_led/select.py index 1f86f79d511..916dacda97f 100644 --- a/homeassistant/components/flux_led/select.py +++ b/homeassistant/components/flux_led/select.py @@ -137,6 +137,10 @@ class FluxICTypeSelect(FluxConfigSelect): async def async_select_option(self, option: str) -> None: """Change the ic type.""" await self._device.async_set_device_config(ic_type=option) + # reload since we need to reinit the device + self.hass.async_create_task( + self.hass.config_entries.async_reload(self.coordinator.entry.entry_id) + ) class FluxWiringsSelect(FluxConfigSelect): diff --git a/tests/components/flux_led/test_select.py b/tests/components/flux_led/test_select.py index e41ec8957ac..5a34e36dc65 100644 --- a/tests/components/flux_led/test_select.py +++ b/tests/components/flux_led/test_select.py @@ -105,13 +105,19 @@ async def test_select_addressable_strip_config(hass: HomeAssistant) -> None: {ATTR_ENTITY_ID: ic_type_entity_id, ATTR_OPTION: "INVALID"}, blocking=True, ) - await hass.services.async_call( - SELECT_DOMAIN, - "select_option", - {ATTR_ENTITY_ID: ic_type_entity_id, ATTR_OPTION: "UCS1618"}, - blocking=True, - ) + + with patch( + "homeassistant.components.flux_led.async_setup_entry" + ) as mock_setup_entry: + await hass.services.async_call( + SELECT_DOMAIN, + "select_option", + {ATTR_ENTITY_ID: ic_type_entity_id, ATTR_OPTION: "UCS1618"}, + blocking=True, + ) + await hass.async_block_till_done() bulb.async_set_device_config.assert_called_once_with(ic_type="UCS1618") + assert len(mock_setup_entry.mock_calls) == 1 async def test_select_mutable_0x25_strip_config(hass: HomeAssistant) -> None: