Filter MQTT alarm JSON attributes (#52278)
parent
dee3e14df2
commit
91b4f7d1d5
|
@ -55,6 +55,14 @@ CONF_PAYLOAD_ARM_NIGHT = "payload_arm_night"
|
|||
CONF_PAYLOAD_ARM_CUSTOM_BYPASS = "payload_arm_custom_bypass"
|
||||
CONF_COMMAND_TEMPLATE = "command_template"
|
||||
|
||||
MQTT_ALARM_ATTRIBUTES_BLOCKED = frozenset(
|
||||
{
|
||||
alarm.ATTR_CHANGED_BY,
|
||||
alarm.ATTR_CODE_ARM_REQUIRED,
|
||||
alarm.ATTR_CODE_FORMAT,
|
||||
}
|
||||
)
|
||||
|
||||
DEFAULT_COMMAND_TEMPLATE = "{{action}}"
|
||||
DEFAULT_ARM_NIGHT = "ARM_NIGHT"
|
||||
DEFAULT_ARM_AWAY = "ARM_AWAY"
|
||||
|
@ -112,6 +120,8 @@ async def _async_setup_entity(
|
|||
class MqttAlarm(MqttEntity, alarm.AlarmControlPanelEntity):
|
||||
"""Representation of a MQTT alarm status."""
|
||||
|
||||
_attributes_extra_blocked = MQTT_ALARM_ATTRIBUTES_BLOCKED
|
||||
|
||||
def __init__(self, hass, config, config_entry, discovery_data):
|
||||
"""Init the MQTT Alarm Control Panel."""
|
||||
self._state = None
|
||||
|
|
|
@ -6,6 +6,9 @@ from unittest.mock import patch
|
|||
import pytest
|
||||
|
||||
from homeassistant.components import alarm_control_panel
|
||||
from homeassistant.components.mqtt.alarm_control_panel import (
|
||||
MQTT_ALARM_ATTRIBUTES_BLOCKED,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
STATE_ALARM_ARMED_AWAY,
|
||||
STATE_ALARM_ARMED_CUSTOM_BYPASS,
|
||||
|
@ -39,6 +42,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,
|
||||
|
@ -544,6 +548,17 @@ 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,
|
||||
alarm_control_panel.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
MQTT_ALARM_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…
Reference in New Issue