mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Filter MQTT cover JSON attributes (#52282)
This commit is contained in:
parent
30a9198d97
commit
39a064683a
@ -101,6 +101,13 @@ TILT_FEATURES = (
|
|||||||
| SUPPORT_SET_TILT_POSITION
|
| SUPPORT_SET_TILT_POSITION
|
||||||
)
|
)
|
||||||
|
|
||||||
|
MQTT_COVER_ATTRIBUTES_BLOCKED = frozenset(
|
||||||
|
{
|
||||||
|
cover.ATTR_CURRENT_POSITION,
|
||||||
|
cover.ATTR_CURRENT_TILT_POSITION,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def validate_options(value):
|
def validate_options(value):
|
||||||
"""Validate options.
|
"""Validate options.
|
||||||
@ -219,6 +226,8 @@ async def _async_setup_entity(
|
|||||||
class MqttCover(MqttEntity, CoverEntity):
|
class MqttCover(MqttEntity, CoverEntity):
|
||||||
"""Representation of a cover that can be controlled using MQTT."""
|
"""Representation of a cover that can be controlled using MQTT."""
|
||||||
|
|
||||||
|
_attributes_extra_blocked = MQTT_COVER_ATTRIBUTES_BLOCKED
|
||||||
|
|
||||||
def __init__(self, hass, config, config_entry, discovery_data):
|
def __init__(self, hass, config, config_entry, discovery_data):
|
||||||
"""Initialize the cover."""
|
"""Initialize the cover."""
|
||||||
self._position = None
|
self._position = None
|
||||||
|
@ -20,6 +20,7 @@ from homeassistant.components.mqtt.cover import (
|
|||||||
CONF_TILT_COMMAND_TOPIC,
|
CONF_TILT_COMMAND_TOPIC,
|
||||||
CONF_TILT_STATUS_TEMPLATE,
|
CONF_TILT_STATUS_TEMPLATE,
|
||||||
CONF_TILT_STATUS_TOPIC,
|
CONF_TILT_STATUS_TOPIC,
|
||||||
|
MQTT_COVER_ATTRIBUTES_BLOCKED,
|
||||||
MqttCover,
|
MqttCover,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -62,6 +63,7 @@ from .test_common import (
|
|||||||
help_test_entity_id_update_subscriptions,
|
help_test_entity_id_update_subscriptions,
|
||||||
help_test_setting_attribute_via_mqtt_json_message,
|
help_test_setting_attribute_via_mqtt_json_message,
|
||||||
help_test_setting_attribute_with_template,
|
help_test_setting_attribute_with_template,
|
||||||
|
help_test_setting_blocked_attribute_via_mqtt_json_message,
|
||||||
help_test_unique_id,
|
help_test_unique_id,
|
||||||
help_test_update_with_json_attrs_bad_JSON,
|
help_test_update_with_json_attrs_bad_JSON,
|
||||||
help_test_update_with_json_attrs_not_dict,
|
help_test_update_with_json_attrs_not_dict,
|
||||||
@ -2307,6 +2309,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, cover.DOMAIN, DEFAULT_CONFIG, MQTT_COVER_ATTRIBUTES_BLOCKED
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_attribute_with_template(hass, mqtt_mock):
|
async def test_setting_attribute_with_template(hass, mqtt_mock):
|
||||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||||
await help_test_setting_attribute_with_template(
|
await help_test_setting_attribute_with_template(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user