Skip to content

Commit

Permalink
Set deprection date to 2022.9 (6 months)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbouwh committed Feb 10, 2022
1 parent 4b37e28 commit 41c7d34
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
27 changes: 18 additions & 9 deletions homeassistant/components/mqtt/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
CONF_PRESET_MODE_VALUE_TEMPLATE = "preset_mode_value_template"
CONF_PRESET_MODE_COMMAND_TEMPLATE = "preset_mode_command_template"
CONF_PRESET_MODES_LIST = "preset_modes"
# CONF_SEND_IF_OFF is deprecated, support will be removed with release 2022.4
# CONF_SEND_IF_OFF is deprecated, support will be removed with release 2022.9
CONF_SEND_IF_OFF = "send_if_off"
CONF_SWING_MODE_COMMAND_TEMPLATE = "swing_mode_command_template"
CONF_SWING_MODE_COMMAND_TOPIC = "swing_mode_command_topic"
Expand Down Expand Up @@ -294,7 +294,7 @@ def valid_preset_mode_configuration(config):
[PRECISION_TENTHS, PRECISION_HALVES, PRECISION_WHOLE]
),
vol.Optional(CONF_RETAIN, default=mqtt.DEFAULT_RETAIN): cv.boolean,
# CONF_SEND_IF_OFF is deprecated, support will be removed with release 2022.4
# CONF_SEND_IF_OFF is deprecated, support will be removed with release 2022.9
vol.Optional(CONF_SEND_IF_OFF, default=True): cv.boolean,
vol.Optional(CONF_ACTION_TEMPLATE): cv.template,
vol.Optional(CONF_ACTION_TOPIC): mqtt.valid_subscribe_topic,
Expand Down Expand Up @@ -337,16 +337,26 @@ def valid_preset_mode_configuration(config):
).extend(MQTT_ENTITY_COMMON_SCHEMA.schema)

PLATFORM_SCHEMA = vol.All(
# CONF_SEND_IF_OFF is deprecated, support will be removed with release 2022.4
cv.deprecated(CONF_SEND_IF_OFF),
_PLATFORM_SCHEMA_BASE,
# CONF_SEND_IF_OFF is deprecated, support will be removed with release 2022.9
cv.deprecated(CONF_SEND_IF_OFF),
# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.7
cv.deprecated(CONF_AWAY_MODE_COMMAND_TOPIC),
cv.deprecated(CONF_AWAY_MODE_STATE_TEMPLATE),
cv.deprecated(CONF_AWAY_MODE_STATE_TOPIC),
cv.deprecated(CONF_HOLD_COMMAND_TEMPLATE),
cv.deprecated(CONF_HOLD_COMMAND_TOPIC),
cv.deprecated(CONF_HOLD_STATE_TEMPLATE),
cv.deprecated(CONF_HOLD_STATE_TOPIC),
cv.deprecated(CONF_HOLD_LIST),
valid_preset_mode_configuration,
)

_DISCOVERY_SCHEMA_BASE = _PLATFORM_SCHEMA_BASE.extend({}, extra=vol.REMOVE_EXTRA)

DISCOVERY_SCHEMA = vol.All(
# CONF_SEND_IF_OFF is deprecated, support will be removed with release 2022.4
_DISCOVERY_SCHEMA_BASE,
# CONF_SEND_IF_OFF is deprecated, support will be removed with release 2022.9
cv.deprecated(CONF_SEND_IF_OFF),
# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.7
cv.deprecated(CONF_AWAY_MODE_COMMAND_TOPIC),
Expand All @@ -357,7 +367,6 @@ def valid_preset_mode_configuration(config):
cv.deprecated(CONF_HOLD_STATE_TEMPLATE),
cv.deprecated(CONF_HOLD_STATE_TOPIC),
cv.deprecated(CONF_HOLD_LIST),
_DISCOVERY_SCHEMA_BASE,
)


Expand Down Expand Up @@ -832,7 +841,7 @@ async def _set_temperature(
# optimistic mode
setattr(self, attr, temp)

# CONF_SEND_IF_OFF is deprecated, support will be removed with release 2022.4
# CONF_SEND_IF_OFF is deprecated, support will be removed with release 2022.9
if (
self._config[CONF_SEND_IF_OFF]
or self._current_operation != HVAC_MODE_OFF
Expand Down Expand Up @@ -875,7 +884,7 @@ async def async_set_temperature(self, **kwargs):

async def async_set_swing_mode(self, swing_mode):
"""Set new swing mode."""
# CONF_SEND_IF_OFF is deprecated, support will be removed with release 2022.4
# CONF_SEND_IF_OFF is deprecated, support will be removed with release 2022.9
if self._config[CONF_SEND_IF_OFF] or self._current_operation != HVAC_MODE_OFF:
payload = self._command_templates[CONF_SWING_MODE_COMMAND_TEMPLATE](
swing_mode
Expand All @@ -888,7 +897,7 @@ async def async_set_swing_mode(self, swing_mode):

async def async_set_fan_mode(self, fan_mode):
"""Set new target temperature."""
# CONF_SEND_IF_OFF is deprecated, support will be removed with release 2022.4
# CONF_SEND_IF_OFF is deprecated, support will be removed with release 2022.9
if self._config[CONF_SEND_IF_OFF] or self._current_operation != HVAC_MODE_OFF:
payload = self._command_templates[CONF_FAN_MODE_COMMAND_TEMPLATE](fan_mode)
await self._publish(CONF_FAN_MODE_COMMAND_TOPIC, payload)
Expand Down
28 changes: 14 additions & 14 deletions tests/components/mqtt/test_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
}
}

# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.7
# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.9
DEFAULT_LEGACY_CONFIG = {
CLIMATE_DOMAIN: {
"platform": "mqtt",
Expand Down Expand Up @@ -138,7 +138,7 @@ async def test_preset_none_in_preset_modes(hass, mqtt_mock, caplog):
assert state is None


# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.7
# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.9
@pytest.mark.parametrize(
"parameter,config_value",
[
Expand Down Expand Up @@ -618,7 +618,7 @@ async def test_set_preset_mode_pessimistic(hass, mqtt_mock, caplog):
assert state.attributes.get("preset_mode") == "home"


# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.7
# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.9
async def test_set_away_mode_pessimistic(hass, mqtt_mock):
"""Test setting of the away mode."""
config = copy.deepcopy(DEFAULT_LEGACY_CONFIG)
Expand Down Expand Up @@ -646,7 +646,7 @@ async def test_set_away_mode_pessimistic(hass, mqtt_mock):
assert state.attributes.get("preset_mode") == "none"


# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.7
# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.9
async def test_set_away_mode(hass, mqtt_mock):
"""Test setting of the away mode."""
config = copy.deepcopy(DEFAULT_LEGACY_CONFIG)
Expand Down Expand Up @@ -688,7 +688,7 @@ async def test_set_away_mode(hass, mqtt_mock):
assert state.attributes.get("preset_mode") == "away"


# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.7
# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.9
async def test_set_hold_pessimistic(hass, mqtt_mock):
"""Test setting the hold mode in pessimistic mode."""
config = copy.deepcopy(DEFAULT_LEGACY_CONFIG)
Expand All @@ -712,7 +712,7 @@ async def test_set_hold_pessimistic(hass, mqtt_mock):
assert state.attributes.get("preset_mode") == "none"


# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.7
# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.9
async def test_set_hold(hass, mqtt_mock):
"""Test setting the hold mode."""
assert await async_setup_component(hass, CLIMATE_DOMAIN, DEFAULT_LEGACY_CONFIG)
Expand Down Expand Up @@ -744,7 +744,7 @@ async def test_set_hold(hass, mqtt_mock):
assert state.attributes.get("preset_mode") == "none"


# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.7
# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.9
async def test_set_preset_away(hass, mqtt_mock):
"""Test setting the hold mode and away mode."""
assert await async_setup_component(hass, CLIMATE_DOMAIN, DEFAULT_LEGACY_CONFIG)
Expand Down Expand Up @@ -778,7 +778,7 @@ async def test_set_preset_away(hass, mqtt_mock):
assert state.attributes.get("preset_mode") == "hold-on-again"


# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.7
# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.9
async def test_set_preset_away_pessimistic(hass, mqtt_mock):
"""Test setting the hold mode and away mode in pessimistic mode."""
config = copy.deepcopy(DEFAULT_LEGACY_CONFIG)
Expand Down Expand Up @@ -829,7 +829,7 @@ async def test_set_preset_away_pessimistic(hass, mqtt_mock):
assert state.attributes.get("preset_mode") == "hold-on-again"


# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.7
# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.9
async def test_set_preset_mode_twice(hass, mqtt_mock):
"""Test setting of the same mode twice only publishes once."""
assert await async_setup_component(hass, CLIMATE_DOMAIN, DEFAULT_LEGACY_CONFIG)
Expand Down Expand Up @@ -1052,7 +1052,7 @@ async def test_get_with_templates(hass, mqtt_mock, caplog):
)


# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.7
# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.9
async def test_get_with_hold_and_away_mode_and_templates(hass, mqtt_mock, caplog):
"""Test getting various for hold and away mode attributes with templates."""
config = copy.deepcopy(DEFAULT_LEGACY_CONFIG)
Expand Down Expand Up @@ -1177,7 +1177,7 @@ async def test_set_and_templates(hass, mqtt_mock, caplog):
assert state.attributes.get("target_temp_high") == 23


# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.7
# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.9
async def test_set_with_away_and_hold_modes_and_templates(hass, mqtt_mock, caplog):
"""Test setting various attributes on hold and away mode with templates."""
config = copy.deepcopy(DEFAULT_LEGACY_CONFIG)
Expand Down Expand Up @@ -1328,11 +1328,11 @@ async def test_unique_id(hass, mqtt_mock):
("action_topic", "heating", ATTR_HVAC_ACTION, "heating"),
("action_topic", "cooling", ATTR_HVAC_ACTION, "cooling"),
("aux_state_topic", "ON", ATTR_AUX_HEAT, "on"),
# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.7
# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.9
("away_mode_state_topic", "ON", ATTR_PRESET_MODE, "away"),
("current_temperature_topic", "22.1", ATTR_CURRENT_TEMPERATURE, 22.1),
("fan_mode_state_topic", "low", ATTR_FAN_MODE, "low"),
# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.7
# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.9
("hold_state_topic", "mode1", ATTR_PRESET_MODE, "mode1"),
("mode_state_topic", "cool", None, None),
("mode_state_topic", "fan_only", None, None),
Expand All @@ -1347,7 +1347,7 @@ async def test_encoding_subscribable_topics(
):
"""Test handling of incoming encoded payload."""
config = copy.deepcopy(DEFAULT_CONFIG[CLIMATE_DOMAIN])
# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.7
# AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.9
if topic in ["hold_state_topic", "away_mode_state_topic"]:
config["hold_modes"] = ["mode1", "mode2"]
del config["preset_modes"]
Expand Down

0 comments on commit 41c7d34

Please sign in to comment.