Skip to content

Commit

Permalink
Deprecate support for undocumented value_template in MQTT light (home…
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery authored Jun 8, 2021
1 parent 4e5ec26 commit a4587b5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions homeassistant/components/mqtt/light/schema_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@
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,
Expand Down Expand Up @@ -179,7 +181,7 @@
}
)
.extend(MQTT_ENTITY_COMMON_SCHEMA.schema)
.extend(MQTT_LIGHT_SCHEMA_SCHEMA.schema)
.extend(MQTT_LIGHT_SCHEMA_SCHEMA.schema),
)


Expand Down
4 changes: 3 additions & 1 deletion tests/components/mqtt/test_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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

Expand Down

0 comments on commit a4587b5

Please sign in to comment.