diff --git a/homeassistant/components/flux_led/__init__.py b/homeassistant/components/flux_led/__init__.py index 0284bf90ba0..717b4a685df 100644 --- a/homeassistant/components/flux_led/__init__.py +++ b/homeassistant/components/flux_led/__init__.py @@ -58,7 +58,12 @@ PLATFORMS_BY_TYPE: Final = { Platform.SENSOR, Platform.SWITCH, ], - DeviceType.Switch: [Platform.BUTTON, Platform.SELECT, Platform.SWITCH], + DeviceType.Switch: [ + Platform.BUTTON, + Platform.SELECT, + Platform.SENSOR, + Platform.SWITCH, + ], } DISCOVERY_INTERVAL: Final = timedelta(minutes=15) REQUEST_REFRESH_DELAY: Final = 1.5 diff --git a/tests/components/flux_led/__init__.py b/tests/components/flux_led/__init__.py index 2f4e5d62dcc..34f592110d0 100644 --- a/tests/components/flux_led/__init__.py +++ b/tests/components/flux_led/__init__.py @@ -175,6 +175,8 @@ def _mocked_switch() -> AIOWifiLedBulb: switch.pixels_per_segment = None switch.segments = None switch.music_pixels_per_segment = None + switch.paired_remotes = 2 + switch.remote_config = RemoteConfig.OPEN switch.music_segments = None switch.operating_mode = None switch.operating_modes = None @@ -183,6 +185,8 @@ def _mocked_switch() -> AIOWifiLedBulb: switch.ic_types = None switch.ic_type = None switch.requires_turn_on = True + switch.async_config_remotes = AsyncMock() + switch.async_unpair_remotes = AsyncMock() switch.async_set_time = AsyncMock() switch.async_reboot = AsyncMock() switch.async_setup = AsyncMock(side_effect=_save_setup_callback) diff --git a/tests/components/flux_led/test_button.py b/tests/components/flux_led/test_button.py index 992d8b18ce6..010b7f329ed 100644 --- a/tests/components/flux_led/test_button.py +++ b/tests/components/flux_led/test_button.py @@ -44,8 +44,8 @@ async def test_button_reboot(hass: HomeAssistant) -> None: switch.async_reboot.assert_called_once() -async def test_button_unpair_remotes(hass: HomeAssistant) -> None: - """Test that remotes can be unpaired.""" +async def test_button_unpair_remotes_bulb(hass: HomeAssistant) -> None: + """Test that remotes can be unpaired from a bulb.""" _mock_config_entry_for_bulb(hass) bulb = _mocked_bulb() bulb.discovery = FLUX_DISCOVERY @@ -60,3 +60,21 @@ async def test_button_unpair_remotes(hass: HomeAssistant) -> None: BUTTON_DOMAIN, "press", {ATTR_ENTITY_ID: entity_id}, blocking=True ) bulb.async_unpair_remotes.assert_called_once() + + +async def test_button_unpair_remotes_smart_switch(hass: HomeAssistant) -> None: + """Test that remotes can be unpaired from a smart switch.""" + _mock_config_entry_for_bulb(hass) + switch = _mocked_switch() + switch.discovery = FLUX_DISCOVERY + with _patch_discovery(device=FLUX_DISCOVERY), _patch_wifibulb(device=switch): + await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}}) + await hass.async_block_till_done() + + entity_id = "button.bulb_rgbcw_ddeeff_unpair_remotes" + assert hass.states.get(entity_id) + + await hass.services.async_call( + BUTTON_DOMAIN, "press", {ATTR_ENTITY_ID: entity_id}, blocking=True + ) + switch.async_unpair_remotes.assert_called_once()