Ensure flux_led is reloaded when the ICtype is changed (#64016)

This commit is contained in:
J. Nick Koston 2022-01-12 15:57:12 -10:00 committed by GitHub
parent 128256a3ee
commit 7fc1306898
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 6 deletions

View file

@ -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):

View file

@ -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: