Deprecate support for undocumented value_template in MQTT light (#51589)

pull/51607/head
Erik Montnemery 2021-06-08 08:23:51 +02:00 committed by GitHub
parent 4e5ec26ce6
commit a4587b5f3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -122,7 +122,9 @@ VALUE_TEMPLATE_KEYS = [
CONF_XY_VALUE_TEMPLATE,
]
PLATFORM_SCHEMA_BASIC = (
PLATFORM_SCHEMA_BASIC = vol.All(
# CONF_VALUE_TEMPLATE is deprecated, support will be removed in 2021.10
cv.deprecated(CONF_VALUE_TEMPLATE, CONF_STATE_VALUE_TEMPLATE),
mqtt.MQTT_RW_PLATFORM_SCHEMA.extend(
{
vol.Optional(CONF_BRIGHTNESS_COMMAND_TOPIC): mqtt.valid_publish_topic,
@ -179,7 +181,7 @@ PLATFORM_SCHEMA_BASIC = (
}
)
.extend(MQTT_ENTITY_COMMON_SCHEMA.schema)
.extend(MQTT_LIGHT_SCHEMA_SCHEMA.schema)
.extend(MQTT_LIGHT_SCHEMA_SCHEMA.schema),
)

View File

@ -1103,7 +1103,7 @@ async def test_controlling_state_via_topic_with_templates(hass, mqtt_mock):
assert state.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES) == color_modes
async def test_controlling_state_via_topic_with_value_template(hass, mqtt_mock):
async def test_controlling_state_via_topic_with_value_template(hass, mqtt_mock, caplog):
"""Test the setting of the state with undocumented value_template."""
config = {
light.DOMAIN: {
@ -1118,6 +1118,8 @@ async def test_controlling_state_via_topic_with_value_template(hass, mqtt_mock):
assert await async_setup_component(hass, light.DOMAIN, config)
await hass.async_block_till_done()
assert "The 'value_template' option is deprecated" in caplog.text
state = hass.states.get("light.test")
assert state.state == STATE_OFF