Deprecate wled.preset service (#53383)
parent
51e4f66b82
commit
fbe576e93a
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue