From fbe576e93ad33bb1f2096ea6b47129c36dc3c5c4 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Mon, 26 Jul 2021 11:01:02 +0200 Subject: [PATCH] Deprecate wled.preset service (#53383) --- homeassistant/components/wled/light.py | 8 ++++++++ homeassistant/components/wled/services.yaml | 5 ++--- tests/components/wled/test_light.py | 7 ++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/wled/light.py b/homeassistant/components/wled/light.py index f4251a90343..403aa5e7368 100644 --- a/homeassistant/components/wled/light.py +++ b/homeassistant/components/wled/light.py @@ -36,6 +36,7 @@ from .const import ( ATTR_SEGMENT_ID, ATTR_SPEED, DOMAIN, + LOGGER, SERVICE_EFFECT, SERVICE_PRESET, ) @@ -164,6 +165,13 @@ class WLEDMasterLight(WLEDEntity, LightEntity): preset: int, ) -> None: """Set a WLED light to a saved preset.""" + # The WLED preset service is replaced by a preset select entity + # and marked deprecated as of Home Assistant 2021.8 + LOGGER.warning( + "The 'wled.preset' service is deprecated and replaced by a " + "dedicated preset select entity; Please use that entity to " + "change presets instead" + ) await self.coordinator.wled.preset(preset=preset) diff --git a/homeassistant/components/wled/services.yaml b/homeassistant/components/wled/services.yaml index f8d636686be..9ca73fac0a3 100644 --- a/homeassistant/components/wled/services.yaml +++ b/homeassistant/components/wled/services.yaml @@ -34,14 +34,13 @@ effect: max: 255 reverse: name: Reverse effect - description: - Reverse the effect. Either true to reverse or false otherwise. + description: Reverse the effect. Either true to reverse or false otherwise. default: false selector: boolean: preset: - name: Set preset + name: Set preset (deprecated) description: Set a preset for the WLED device. target: entity: diff --git a/tests/components/wled/test_light.py b/tests/components/wled/test_light.py index d61b675e2f2..14166e1956e 100644 --- a/tests/components/wled/test_light.py +++ b/tests/components/wled/test_light.py @@ -566,7 +566,10 @@ async def test_effect_service_error( async def test_preset_service( - hass: HomeAssistant, init_integration: MockConfigEntry, mock_wled: MagicMock + hass: HomeAssistant, + init_integration: MockConfigEntry, + mock_wled: MagicMock, + caplog: pytest.LogCaptureFixture, ) -> None: """Test the preset service of a WLED light.""" await hass.services.async_call( @@ -595,6 +598,8 @@ async def test_preset_service( assert mock_wled.preset.call_count == 2 mock_wled.preset.assert_called_with(preset=2) + assert "The 'wled.preset' service is deprecated" in caplog.text + async def test_preset_service_error( hass: HomeAssistant,