mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Remove aux heat support from mqtt climate (#109513)
This commit is contained in:
parent
29462fc991
commit
00947b708f
@ -44,7 +44,6 @@ from homeassistant.const import (
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||
from homeassistant.helpers.template import Template
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.util.unit_conversion import TemperatureConverter
|
||||
@ -77,7 +76,6 @@ from .const import (
|
||||
CONF_TEMP_STATE_TEMPLATE,
|
||||
CONF_TEMP_STATE_TOPIC,
|
||||
DEFAULT_OPTIMISTIC,
|
||||
DOMAIN,
|
||||
PAYLOAD_NONE,
|
||||
)
|
||||
from .debug_info import log_messages
|
||||
@ -98,13 +96,11 @@ from .util import valid_publish_topic, valid_subscribe_topic
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
MQTT_CLIMATE_AUX_DOCS = "https://www.home-assistant.io/integrations/climate.mqtt/"
|
||||
|
||||
DEFAULT_NAME = "MQTT HVAC"
|
||||
|
||||
# Options CONF_AUX_COMMAND_TOPIC, CONF_AUX_STATE_TOPIC
|
||||
# and CONF_AUX_STATE_TEMPLATE were deprecated in HA Core 2023.9
|
||||
# Support will be removed in HA Core 2024.3
|
||||
# Support was removed in HA Core 2024.3
|
||||
CONF_AUX_COMMAND_TOPIC = "aux_command_topic"
|
||||
CONF_AUX_STATE_TEMPLATE = "aux_state_template"
|
||||
CONF_AUX_STATE_TOPIC = "aux_state_topic"
|
||||
@ -150,7 +146,6 @@ DEFAULT_INITIAL_TEMPERATURE = 21.0
|
||||
|
||||
MQTT_CLIMATE_ATTRIBUTES_BLOCKED = frozenset(
|
||||
{
|
||||
climate.ATTR_AUX_HEAT,
|
||||
climate.ATTR_CURRENT_HUMIDITY,
|
||||
climate.ATTR_CURRENT_TEMPERATURE,
|
||||
climate.ATTR_FAN_MODE,
|
||||
@ -174,7 +169,6 @@ MQTT_CLIMATE_ATTRIBUTES_BLOCKED = frozenset(
|
||||
)
|
||||
|
||||
VALUE_TEMPLATE_KEYS = (
|
||||
CONF_AUX_STATE_TEMPLATE,
|
||||
CONF_CURRENT_HUMIDITY_TEMPLATE,
|
||||
CONF_CURRENT_TEMP_TEMPLATE,
|
||||
CONF_FAN_MODE_STATE_TEMPLATE,
|
||||
@ -204,8 +198,6 @@ COMMAND_TEMPLATE_KEYS = {
|
||||
|
||||
TOPIC_KEYS = (
|
||||
CONF_ACTION_TOPIC,
|
||||
CONF_AUX_COMMAND_TOPIC,
|
||||
CONF_AUX_STATE_TOPIC,
|
||||
CONF_CURRENT_HUMIDITY_TOPIC,
|
||||
CONF_CURRENT_TEMP_TOPIC,
|
||||
CONF_FAN_MODE_COMMAND_TOPIC,
|
||||
@ -266,12 +258,6 @@ def valid_humidity_state_configuration(config: ConfigType) -> ConfigType:
|
||||
|
||||
_PLATFORM_SCHEMA_BASE = MQTT_BASE_SCHEMA.extend(
|
||||
{
|
||||
# Options CONF_AUX_COMMAND_TOPIC, CONF_AUX_STATE_TOPIC
|
||||
# and CONF_AUX_STATE_TEMPLATE were deprecated in HA Core 2023.9
|
||||
# Support will be removed in HA Core 2024.3
|
||||
vol.Optional(CONF_AUX_COMMAND_TOPIC): valid_publish_topic,
|
||||
vol.Optional(CONF_AUX_STATE_TEMPLATE): cv.template,
|
||||
vol.Optional(CONF_AUX_STATE_TOPIC): valid_subscribe_topic,
|
||||
vol.Optional(CONF_CURRENT_HUMIDITY_TEMPLATE): cv.template,
|
||||
vol.Optional(CONF_CURRENT_HUMIDITY_TOPIC): valid_subscribe_topic,
|
||||
vol.Optional(CONF_CURRENT_TEMP_TEMPLATE): cv.template,
|
||||
@ -369,10 +355,10 @@ PLATFORM_SCHEMA_MODERN = vol.All(
|
||||
cv.removed(CONF_POWER_STATE_TOPIC),
|
||||
# Options CONF_AUX_COMMAND_TOPIC, CONF_AUX_STATE_TOPIC
|
||||
# and CONF_AUX_STATE_TEMPLATE were deprecated in HA Core 2023.9
|
||||
# Support will be removed in HA Core 2024.3
|
||||
cv.deprecated(CONF_AUX_COMMAND_TOPIC),
|
||||
cv.deprecated(CONF_AUX_STATE_TEMPLATE),
|
||||
cv.deprecated(CONF_AUX_STATE_TOPIC),
|
||||
# Support was removed in HA Core 2024.3
|
||||
cv.removed(CONF_AUX_COMMAND_TOPIC),
|
||||
cv.removed(CONF_AUX_STATE_TEMPLATE),
|
||||
cv.removed(CONF_AUX_STATE_TOPIC),
|
||||
_PLATFORM_SCHEMA_BASE,
|
||||
valid_preset_mode_configuration,
|
||||
valid_humidity_range_configuration,
|
||||
@ -603,7 +589,6 @@ class MqttClimate(MqttTemperatureControlEntity, ClimateEntity):
|
||||
|
||||
_attr_fan_mode: str | None = None
|
||||
_attr_hvac_mode: HVACMode | None = None
|
||||
_attr_is_aux_heat: bool | None = None
|
||||
_attr_swing_mode: str | None = None
|
||||
_default_name = DEFAULT_NAME
|
||||
_entity_id_format = climate.ENTITY_ID_FORMAT
|
||||
@ -662,11 +647,6 @@ class MqttClimate(MqttTemperatureControlEntity, ClimateEntity):
|
||||
self._attr_swing_mode = SWING_OFF
|
||||
if self._topic[CONF_MODE_STATE_TOPIC] is None or self._optimistic:
|
||||
self._attr_hvac_mode = HVACMode.OFF
|
||||
# Options CONF_AUX_COMMAND_TOPIC, CONF_AUX_STATE_TOPIC
|
||||
# and CONF_AUX_STATE_TEMPLATE were deprecated in HA Core 2023.9
|
||||
# Support will be removed in HA Core 2024.3
|
||||
if self._topic[CONF_AUX_STATE_TOPIC] is None or self._optimistic:
|
||||
self._attr_is_aux_heat = False
|
||||
self._feature_preset_mode = CONF_PRESET_MODE_COMMAND_TOPIC in config
|
||||
if self._feature_preset_mode:
|
||||
presets = []
|
||||
@ -736,32 +716,8 @@ class MqttClimate(MqttTemperatureControlEntity, ClimateEntity):
|
||||
if self._feature_preset_mode:
|
||||
support |= ClimateEntityFeature.PRESET_MODE
|
||||
|
||||
# Options CONF_AUX_COMMAND_TOPIC, CONF_AUX_STATE_TOPIC
|
||||
# and CONF_AUX_STATE_TEMPLATE were deprecated in HA Core 2023.9
|
||||
# Support will be removed in HA Core 2024.3
|
||||
if (self._topic[CONF_AUX_STATE_TOPIC] is not None) or (
|
||||
self._topic[CONF_AUX_COMMAND_TOPIC] is not None
|
||||
):
|
||||
support |= ClimateEntityFeature.AUX_HEAT
|
||||
self._attr_supported_features = support
|
||||
|
||||
async def mqtt_async_added_to_hass(self) -> None:
|
||||
"""Handle deprecation issues."""
|
||||
if self._attr_supported_features & ClimateEntityFeature.AUX_HEAT:
|
||||
async_create_issue(
|
||||
self.hass,
|
||||
DOMAIN,
|
||||
"deprecated_climate_aux_property_{self.entity_id}",
|
||||
breaks_in_ha_version="2024.3.0",
|
||||
is_fixable=False,
|
||||
translation_key="deprecated_climate_aux_property",
|
||||
translation_placeholders={
|
||||
"entity_id": self.entity_id,
|
||||
},
|
||||
learn_more_url=MQTT_CLIMATE_AUX_DOCS,
|
||||
severity=IssueSeverity.WARNING,
|
||||
)
|
||||
|
||||
def _prepare_subscribe_topics(self) -> None: # noqa: C901
|
||||
"""(Re)Subscribe to topics."""
|
||||
topics: dict[str, dict[str, Any]] = {}
|
||||
@ -875,41 +831,6 @@ class MqttClimate(MqttTemperatureControlEntity, ClimateEntity):
|
||||
topics, CONF_SWING_MODE_STATE_TOPIC, handle_swing_mode_received
|
||||
)
|
||||
|
||||
@callback
|
||||
def handle_onoff_mode_received(
|
||||
msg: ReceiveMessage, template_name: str, attr: str
|
||||
) -> None:
|
||||
"""Handle receiving on/off mode via MQTT."""
|
||||
payload = self.render_template(msg, template_name)
|
||||
payload_on: str = self._config[CONF_PAYLOAD_ON]
|
||||
payload_off: str = self._config[CONF_PAYLOAD_OFF]
|
||||
|
||||
if payload == "True":
|
||||
payload = payload_on
|
||||
elif payload == "False":
|
||||
payload = payload_off
|
||||
|
||||
if payload == payload_on:
|
||||
setattr(self, attr, True)
|
||||
elif payload == payload_off:
|
||||
setattr(self, attr, False)
|
||||
else:
|
||||
_LOGGER.error("Invalid %s mode: %s", attr, payload)
|
||||
|
||||
# Options CONF_AUX_COMMAND_TOPIC, CONF_AUX_STATE_TOPIC
|
||||
# and CONF_AUX_STATE_TEMPLATE were deprecated in HA Core 2023.9
|
||||
# Support will be removed in HA Core 2024.3
|
||||
@callback
|
||||
@log_messages(self.hass, self.entity_id)
|
||||
@write_state_on_attr_change(self, {"_attr_is_aux_heat"})
|
||||
def handle_aux_mode_received(msg: ReceiveMessage) -> None:
|
||||
"""Handle receiving aux mode via MQTT."""
|
||||
handle_onoff_mode_received(
|
||||
msg, CONF_AUX_STATE_TEMPLATE, "_attr_is_aux_heat"
|
||||
)
|
||||
|
||||
self.add_subscription(topics, CONF_AUX_STATE_TOPIC, handle_aux_mode_received)
|
||||
|
||||
@callback
|
||||
@log_messages(self.hass, self.entity_id)
|
||||
@write_state_on_attr_change(self, {"_attr_preset_mode"})
|
||||
@ -1002,27 +923,6 @@ class MqttClimate(MqttTemperatureControlEntity, ClimateEntity):
|
||||
self._attr_preset_mode = preset_mode
|
||||
self.async_write_ha_state()
|
||||
|
||||
# Options CONF_AUX_COMMAND_TOPIC, CONF_AUX_STATE_TOPIC
|
||||
# and CONF_AUX_STATE_TEMPLATE were deprecated in HA Core 2023.9
|
||||
# Support will be removed in HA Core 2024.3
|
||||
async def _set_aux_heat(self, state: bool) -> None:
|
||||
await self._publish(
|
||||
CONF_AUX_COMMAND_TOPIC,
|
||||
self._config[CONF_PAYLOAD_ON] if state else self._config[CONF_PAYLOAD_OFF],
|
||||
)
|
||||
|
||||
if self._optimistic or self._topic[CONF_AUX_STATE_TOPIC] is None:
|
||||
self._attr_is_aux_heat = state
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_aux_heat_on(self) -> None:
|
||||
"""Turn auxiliary heater on."""
|
||||
await self._set_aux_heat(True)
|
||||
|
||||
async def async_turn_aux_heat_off(self) -> None:
|
||||
"""Turn auxiliary heater off."""
|
||||
await self._set_aux_heat(False)
|
||||
|
||||
async def async_turn_on(self) -> None:
|
||||
"""Turn the entity on."""
|
||||
if CONF_POWER_COMMAND_TOPIC in self._config:
|
||||
|
@ -4,10 +4,6 @@
|
||||
"title": "MQTT vacuum entities with deprecated `schema` config settings found in your configuration.yaml",
|
||||
"description": "The `schema` setting for MQTT vacuum entities is deprecated and should be removed. Please adjust your configuration.yaml and restart Home Assistant to fix this issue."
|
||||
},
|
||||
"deprecated_climate_aux_property": {
|
||||
"title": "MQTT entities with auxiliary heat support found",
|
||||
"description": "Entity `{entity_id}` has auxiliary heat support enabled, which has been deprecated for MQTT climate devices. Please adjust your configuration and remove deprecated config options from your configuration and restart Home Assistant to fix this issue."
|
||||
},
|
||||
"invalid_platform_config": {
|
||||
"title": "Invalid config found for mqtt {domain} item",
|
||||
"description": "Home Assistant detected an invalid config for a manually configured item.\n\nPlatform domain: **{domain}**\nConfiguration file: **{config_file}**\nNear line: **{line}**\nConfiguration found:\n```yaml\n{config}\n```\nError: **{error}**.\n\nMake sure the configuration is valid and [reload](/developer-tools/yaml) the manually configured MQTT items or restart Home Assistant to fix this issue."
|
||||
|
@ -9,7 +9,6 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant.components import climate, mqtt
|
||||
from homeassistant.components.climate import (
|
||||
ATTR_AUX_HEAT,
|
||||
ATTR_CURRENT_HUMIDITY,
|
||||
ATTR_CURRENT_TEMPERATURE,
|
||||
ATTR_FAN_MODE,
|
||||
@ -1262,91 +1261,6 @@ async def test_set_preset_mode_pessimistic(
|
||||
assert state.attributes.get("preset_mode") == "home"
|
||||
|
||||
|
||||
# Options CONF_AUX_COMMAND_TOPIC, CONF_AUX_STATE_TOPIC
|
||||
# and CONF_AUX_STATE_TEMPLATE were deprecated in HA Core 2023.9
|
||||
# Support will be removed in HA Core 2024.3
|
||||
@pytest.mark.parametrize(
|
||||
"hass_config",
|
||||
[
|
||||
help_custom_config(
|
||||
climate.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
({"aux_command_topic": "aux-topic", "aux_state_topic": "aux-state"},),
|
||||
)
|
||||
],
|
||||
)
|
||||
async def test_set_aux_pessimistic(
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting of the aux heating in pessimistic mode."""
|
||||
await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get("aux_heat") == "off"
|
||||
|
||||
await common.async_set_aux_heat(hass, True, ENTITY_CLIMATE)
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get("aux_heat") == "off"
|
||||
|
||||
async_fire_mqtt_message(hass, "aux-state", "ON")
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get("aux_heat") == "on"
|
||||
|
||||
async_fire_mqtt_message(hass, "aux-state", "OFF")
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get("aux_heat") == "off"
|
||||
|
||||
async_fire_mqtt_message(hass, "aux-state", "nonsense")
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get("aux_heat") == "off"
|
||||
|
||||
|
||||
# Options CONF_AUX_COMMAND_TOPIC, CONF_AUX_STATE_TOPIC
|
||||
# and CONF_AUX_STATE_TEMPLATE were deprecated in HA Core 2023.9
|
||||
# Support will be removed in HA Core 2024.3
|
||||
# "aux_command_topic": "aux-topic"
|
||||
@pytest.mark.parametrize(
|
||||
"hass_config",
|
||||
[
|
||||
help_custom_config(
|
||||
climate.DOMAIN, DEFAULT_CONFIG, ({"aux_command_topic": "aux-topic"},)
|
||||
)
|
||||
],
|
||||
)
|
||||
async def test_set_aux(
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting of the aux heating."""
|
||||
mqtt_mock = await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get("aux_heat") == "off"
|
||||
await common.async_set_aux_heat(hass, True, ENTITY_CLIMATE)
|
||||
mqtt_mock.async_publish.assert_called_once_with("aux-topic", "ON", 0, False)
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get("aux_heat") == "on"
|
||||
|
||||
await common.async_set_aux_heat(hass, False, ENTITY_CLIMATE)
|
||||
mqtt_mock.async_publish.assert_called_once_with("aux-topic", "OFF", 0, False)
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get("aux_heat") == "off"
|
||||
|
||||
support = (
|
||||
ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
| ClimateEntityFeature.AUX_HEAT
|
||||
| ClimateEntityFeature.SWING_MODE
|
||||
| ClimateEntityFeature.FAN_MODE
|
||||
| ClimateEntityFeature.PRESET_MODE
|
||||
| ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
||||
| ClimateEntityFeature.TARGET_HUMIDITY
|
||||
| ClimateEntityFeature.TURN_OFF
|
||||
| ClimateEntityFeature.TURN_ON
|
||||
)
|
||||
|
||||
assert state.attributes.get("supported_features") == support
|
||||
|
||||
|
||||
@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG])
|
||||
async def test_availability_when_connection_lost(
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
@ -1476,7 +1390,6 @@ async def test_get_target_temperature_low_high_with_templates(
|
||||
"temperature_high_command_topic": "temperature-high-topic",
|
||||
"fan_mode_command_topic": "fan-mode-topic",
|
||||
"swing_mode_command_topic": "swing-mode-topic",
|
||||
"aux_command_topic": "aux-topic",
|
||||
"preset_mode_command_topic": "preset-mode-topic",
|
||||
"preset_modes": [
|
||||
"eco",
|
||||
@ -1493,8 +1406,6 @@ async def test_get_target_temperature_low_high_with_templates(
|
||||
"current_humidity_template": "{{ value_json }}",
|
||||
"current_temperature_template": "{{ value_json }}",
|
||||
"temperature_state_template": "{{ value_json }}",
|
||||
# Rendering to a bool for aux heat
|
||||
"aux_state_template": "{{ value == 'switchmeon' }}",
|
||||
# Rendering preset_mode
|
||||
"preset_mode_value_template": "{{ value_json.attribute }}",
|
||||
"action_topic": "action",
|
||||
@ -1503,7 +1414,6 @@ async def test_get_target_temperature_low_high_with_templates(
|
||||
"swing_mode_state_topic": "swing-state",
|
||||
"temperature_state_topic": "temperature-state",
|
||||
"target_humidity_state_topic": "humidity-state",
|
||||
"aux_state_topic": "aux-state",
|
||||
"current_temperature_topic": "current-temperature",
|
||||
"current_humidity_topic": "current-humidity",
|
||||
"preset_mode_state_topic": "current-preset-mode",
|
||||
@ -1590,21 +1500,6 @@ async def test_get_with_templates(
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get("preset_mode") == "eco"
|
||||
|
||||
# Aux mode
|
||||
|
||||
# Options CONF_AUX_COMMAND_TOPIC, CONF_AUX_STATE_TOPIC
|
||||
# and CONF_AUX_STATE_TEMPLATE were deprecated in HA Core 2023.9
|
||||
# Support will be removed in HA Core 2024.3
|
||||
assert state.attributes.get("aux_heat") == "off"
|
||||
async_fire_mqtt_message(hass, "aux-state", "switchmeon")
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get("aux_heat") == "on"
|
||||
|
||||
# anything other than 'switchmeon' should turn Aux mode off
|
||||
async_fire_mqtt_message(hass, "aux-state", "somerandomstring")
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.attributes.get("aux_heat") == "off"
|
||||
|
||||
# Current temperature
|
||||
async_fire_mqtt_message(hass, "current-temperature", '"74656"')
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
@ -1648,7 +1543,6 @@ async def test_get_with_templates(
|
||||
"temperature_high_command_topic": "temperature-high-topic",
|
||||
"fan_mode_command_topic": "fan-mode-topic",
|
||||
"swing_mode_command_topic": "swing-mode-topic",
|
||||
"aux_command_topic": "aux-topic",
|
||||
"preset_mode_command_topic": "preset-mode-topic",
|
||||
"preset_modes": [
|
||||
"eco",
|
||||
@ -2104,7 +1998,6 @@ async def test_unique_id(
|
||||
[
|
||||
("action_topic", "heating", ATTR_HVAC_ACTION, "heating"),
|
||||
("action_topic", "cooling", ATTR_HVAC_ACTION, "cooling"),
|
||||
("aux_state_topic", "ON", ATTR_AUX_HEAT, "on"),
|
||||
("current_temperature_topic", "22.1", ATTR_CURRENT_TEMPERATURE, 22.1),
|
||||
("current_humidity_topic", "60.4", ATTR_CURRENT_HUMIDITY, 60.4),
|
||||
("fan_mode_state_topic", "low", ATTR_FAN_MODE, "low"),
|
||||
@ -2386,13 +2279,6 @@ async def test_precision_whole(
|
||||
"on",
|
||||
"swing_mode_command_template",
|
||||
),
|
||||
(
|
||||
climate.SERVICE_SET_AUX_HEAT,
|
||||
"aux_command_topic",
|
||||
{"aux_heat": "on"},
|
||||
"ON",
|
||||
None,
|
||||
),
|
||||
(
|
||||
climate.SERVICE_SET_TEMPERATURE,
|
||||
"temperature_command_topic",
|
||||
|
Loading…
x
Reference in New Issue
Block a user