Filter MQTT climate JSON attributes (#52280)
This commit is contained in:
parent
91b4f7d1d5
commit
040c88f982
2 changed files with 36 additions and 0 deletions
|
@ -119,6 +119,31 @@ CONF_TEMP_MAX = "max_temp"
|
|||
CONF_TEMP_MIN = "min_temp"
|
||||
CONF_TEMP_STEP = "temp_step"
|
||||
|
||||
MQTT_CLIMATE_ATTRIBUTES_BLOCKED = frozenset(
|
||||
{
|
||||
climate.ATTR_AUX_HEAT,
|
||||
climate.ATTR_CURRENT_HUMIDITY,
|
||||
climate.ATTR_CURRENT_TEMPERATURE,
|
||||
climate.ATTR_FAN_MODE,
|
||||
climate.ATTR_FAN_MODES,
|
||||
climate.ATTR_HUMIDITY,
|
||||
climate.ATTR_HVAC_ACTION,
|
||||
climate.ATTR_HVAC_MODES,
|
||||
climate.ATTR_MAX_HUMIDITY,
|
||||
climate.ATTR_MAX_TEMP,
|
||||
climate.ATTR_MIN_HUMIDITY,
|
||||
climate.ATTR_MIN_TEMP,
|
||||
climate.ATTR_PRESET_MODE,
|
||||
climate.ATTR_PRESET_MODES,
|
||||
climate.ATTR_SWING_MODE,
|
||||
climate.ATTR_SWING_MODES,
|
||||
climate.ATTR_TARGET_TEMP_HIGH,
|
||||
climate.ATTR_TARGET_TEMP_LOW,
|
||||
climate.ATTR_TARGET_TEMP_STEP,
|
||||
climate.ATTR_TEMPERATURE,
|
||||
}
|
||||
)
|
||||
|
||||
VALUE_TEMPLATE_KEYS = (
|
||||
CONF_AUX_STATE_TEMPLATE,
|
||||
CONF_AWAY_MODE_STATE_TEMPLATE,
|
||||
|
@ -276,6 +301,8 @@ async def _async_setup_entity(
|
|||
class MqttClimate(MqttEntity, ClimateEntity):
|
||||
"""Representation of an MQTT climate device."""
|
||||
|
||||
_attributes_extra_blocked = MQTT_CLIMATE_ATTRIBUTES_BLOCKED
|
||||
|
||||
def __init__(self, hass, config, config_entry, discovery_data):
|
||||
"""Initialize the climate device."""
|
||||
self._action = None
|
||||
|
|
|
@ -23,6 +23,7 @@ from homeassistant.components.climate.const import (
|
|||
SUPPORT_TARGET_TEMPERATURE,
|
||||
SUPPORT_TARGET_TEMPERATURE_RANGE,
|
||||
)
|
||||
from homeassistant.components.mqtt.climate import MQTT_CLIMATE_ATTRIBUTES_BLOCKED
|
||||
from homeassistant.const import STATE_OFF
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
@ -45,6 +46,7 @@ from .test_common import (
|
|||
help_test_entity_id_update_subscriptions,
|
||||
help_test_setting_attribute_via_mqtt_json_message,
|
||||
help_test_setting_attribute_with_template,
|
||||
help_test_setting_blocked_attribute_via_mqtt_json_message,
|
||||
help_test_unique_id,
|
||||
help_test_update_with_json_attrs_bad_JSON,
|
||||
help_test_update_with_json_attrs_not_dict,
|
||||
|
@ -923,6 +925,13 @@ async def test_setting_attribute_via_mqtt_json_message(hass, mqtt_mock):
|
|||
)
|
||||
|
||||
|
||||
async def test_setting_blocked_attribute_via_mqtt_json_message(hass, mqtt_mock):
|
||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||
hass, mqtt_mock, CLIMATE_DOMAIN, DEFAULT_CONFIG, MQTT_CLIMATE_ATTRIBUTES_BLOCKED
|
||||
)
|
||||
|
||||
|
||||
async def test_setting_attribute_with_template(hass, mqtt_mock):
|
||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||
await help_test_setting_attribute_with_template(
|
||||
|
|
Loading…
Add table
Reference in a new issue