From 64e235285d13051c74b649fad0d2c31c2a316b11 Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Thu, 12 Jan 2023 09:49:14 +0100 Subject: [PATCH] Deprecate power_command_topic for MQTT climate (#85229) * Deprecate mode_command_topic for MQTT climate * Correct deprecation and remove support release inf * Do not use future tense for comment * Extend deprecation period to 6 months --- homeassistant/components/mqtt/climate.py | 16 ++++++++++++++++ tests/components/mqtt/test_climate.py | 11 +++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/mqtt/climate.py b/homeassistant/components/mqtt/climate.py index b64e5ed08c3..a58ccf8a190 100644 --- a/homeassistant/components/mqtt/climate.py +++ b/homeassistant/components/mqtt/climate.py @@ -116,6 +116,10 @@ CONF_MODE_COMMAND_TOPIC = "mode_command_topic" CONF_MODE_LIST = "modes" CONF_MODE_STATE_TEMPLATE = "mode_state_template" CONF_MODE_STATE_TOPIC = "mode_state_topic" + +# CONF_POWER_COMMAND_TOPIC, CONF_POWER_STATE_TOPIC and CONF_POWER_STATE_TEMPLATE are deprecated, +# support for CONF_POWER_STATE_TOPIC and CONF_POWER_STATE_TEMPLATE was already removed or never added +# support was deprecated with release 2023.2 and will be removed with release 2023.8 CONF_POWER_COMMAND_TOPIC = "power_command_topic" CONF_POWER_STATE_TEMPLATE = "power_state_template" CONF_POWER_STATE_TOPIC = "power_state_topic" @@ -371,6 +375,12 @@ PLATFORM_SCHEMA_MODERN = vol.All( cv.removed(CONF_HOLD_STATE_TEMPLATE), cv.removed(CONF_HOLD_STATE_TOPIC), cv.removed(CONF_HOLD_LIST), + # CONF_POWER_COMMAND_TOPIC, CONF_POWER_STATE_TOPIC and CONF_POWER_STATE_TEMPLATE are deprecated, + # support for CONF_POWER_STATE_TOPIC and CONF_POWER_STATE_TEMPLATE was already removed or never added + # support was deprecated with release 2023.2 and will be removed with release 2023.8 + cv.deprecated(CONF_POWER_COMMAND_TOPIC), + cv.deprecated(CONF_POWER_STATE_TEMPLATE), + cv.deprecated(CONF_POWER_STATE_TOPIC), _PLATFORM_SCHEMA_BASE, valid_preset_mode_configuration, valid_humidity_range_configuration, @@ -400,6 +410,12 @@ DISCOVERY_SCHEMA = vol.All( cv.removed(CONF_HOLD_STATE_TEMPLATE), cv.removed(CONF_HOLD_STATE_TOPIC), cv.removed(CONF_HOLD_LIST), + # CONF_POWER_COMMAND_TOPIC, CONF_POWER_STATE_TOPIC and CONF_POWER_STATE_TEMPLATE are deprecated, + # support for CONF_POWER_STATE_TOPIC and CONF_POWER_STATE_TEMPLATE was already removed or never added + # support was deprecated with release 2023.2 and will be removed with release 2023.8 + cv.deprecated(CONF_POWER_COMMAND_TOPIC), + cv.deprecated(CONF_POWER_STATE_TEMPLATE), + cv.deprecated(CONF_POWER_STATE_TOPIC), valid_preset_mode_configuration, valid_humidity_range_configuration, valid_humidity_state_configuration, diff --git a/tests/components/mqtt/test_climate.py b/tests/components/mqtt/test_climate.py index 817d0734567..cdf85ae5f76 100644 --- a/tests/components/mqtt/test_climate.py +++ b/tests/components/mqtt/test_climate.py @@ -273,6 +273,9 @@ async def test_set_operation_optimistic(hass, mqtt_mock_entry_with_yaml_config): assert state.state == "heat" +# CONF_POWER_COMMAND_TOPIC, CONF_POWER_STATE_TOPIC and CONF_POWER_STATE_TEMPLATE are deprecated, +# support for CONF_POWER_STATE_TOPIC and CONF_POWER_STATE_TEMPLATE was already removed or never added +# support was deprecated with release 2023.2 and will be removed with release 2023.8 async def test_set_operation_with_power_command(hass, mqtt_mock_entry_with_yaml_config): """Test setting of new operation mode with power command enabled.""" config = copy.deepcopy(DEFAULT_CONFIG[mqtt.DOMAIN]) @@ -1410,14 +1413,14 @@ async def test_unique_id(hass, mqtt_mock_entry_with_yaml_config): climate.DOMAIN: [ { "name": "Test 1", - "power_state_topic": "test-topic", - "power_command_topic": "test_topic", + "mode_state_topic": "test_topic1/state", + "mode_command_topic": "test_topic1/command", "unique_id": "TOTALLY_UNIQUE", }, { "name": "Test 2", - "power_state_topic": "test-topic", - "power_command_topic": "test_topic", + "mode_state_topic": "test_topic2/state", + "mode_command_topic": "test_topic2/command", "unique_id": "TOTALLY_UNIQUE", }, ]