1
mirror of https://github.com/home-assistant/core synced 2024-09-09 12:51:22 +02:00

Deprecate wled.preset service (#53383)

This commit is contained in:
Franck Nijhof 2021-07-26 11:01:02 +02:00 committed by GitHub
parent 51e4f66b82
commit fbe576e93a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 4 deletions

View File

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

View File

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

View File

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