diff --git a/homeassistant/components/mqtt/camera.py b/homeassistant/components/mqtt/camera.py index 1db9faf9058..adcb9ca623a 100644 --- a/homeassistant/components/mqtt/camera.py +++ b/homeassistant/components/mqtt/camera.py @@ -19,6 +19,15 @@ from .mixins import MQTT_ENTITY_COMMON_SCHEMA, MqttEntity, async_setup_entry_hel CONF_TOPIC = "topic" DEFAULT_NAME = "MQTT Camera" +MQTT_CAMERA_ATTRIBUTES_BLOCKED = frozenset( + { + "access_token", + "brand", + "model_name", + "motion_detection", + } +) + PLATFORM_SCHEMA = mqtt.MQTT_BASE_PLATFORM_SCHEMA.extend( { vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, @@ -53,6 +62,8 @@ async def _async_setup_entity( class MqttCamera(MqttEntity, Camera): """representation of a MQTT camera.""" + _attributes_extra_blocked = MQTT_CAMERA_ATTRIBUTES_BLOCKED + def __init__(self, hass, config, config_entry, discovery_data): """Initialize the MQTT Camera.""" self._last_image = None diff --git a/tests/components/mqtt/test_camera.py b/tests/components/mqtt/test_camera.py index 13c15796cfd..a73a63d3439 100644 --- a/tests/components/mqtt/test_camera.py +++ b/tests/components/mqtt/test_camera.py @@ -5,6 +5,7 @@ from unittest.mock import patch import pytest from homeassistant.components import camera +from homeassistant.components.mqtt.camera import MQTT_CAMERA_ATTRIBUTES_BLOCKED from homeassistant.setup import async_setup_component from .test_common import ( @@ -26,6 +27,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, @@ -94,6 +96,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, camera.DOMAIN, DEFAULT_CONFIG, MQTT_CAMERA_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(