2018-09-14 09:57:31 +00:00
|
|
|
"""Constants used by multiple MQTT modules."""
|
2024-01-16 13:02:34 +00:00
|
|
|
|
2024-02-13 09:59:55 +00:00
|
|
|
import jinja2
|
|
|
|
|
2022-05-31 07:32:44 +00:00
|
|
|
from homeassistant.const import CONF_PAYLOAD, Platform
|
2024-02-13 09:59:55 +00:00
|
|
|
from homeassistant.exceptions import TemplateError
|
2020-07-15 18:16:03 +00:00
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
ATTR_DISCOVERY_HASH = "discovery_hash"
|
2020-04-01 17:00:40 +00:00
|
|
|
ATTR_DISCOVERY_PAYLOAD = "discovery_payload"
|
2020-02-25 04:46:02 +00:00
|
|
|
ATTR_DISCOVERY_TOPIC = "discovery_topic"
|
2020-06-23 00:49:01 +00:00
|
|
|
ATTR_PAYLOAD = "payload"
|
|
|
|
ATTR_QOS = "qos"
|
|
|
|
ATTR_RETAIN = "retain"
|
2024-01-16 13:02:34 +00:00
|
|
|
ATTR_SERIAL_NUMBER = "serial_number"
|
2020-06-23 00:49:01 +00:00
|
|
|
ATTR_TOPIC = "topic"
|
|
|
|
|
2021-10-11 21:37:31 +00:00
|
|
|
CONF_AVAILABILITY = "availability"
|
2020-06-23 00:49:01 +00:00
|
|
|
CONF_BROKER = "broker"
|
|
|
|
CONF_BIRTH_MESSAGE = "birth_message"
|
2022-03-22 11:51:24 +00:00
|
|
|
CONF_COMMAND_TEMPLATE = "command_template"
|
|
|
|
CONF_COMMAND_TOPIC = "command_topic"
|
2022-05-31 07:32:44 +00:00
|
|
|
CONF_DISCOVERY_PREFIX = "discovery_prefix"
|
2022-03-22 11:51:24 +00:00
|
|
|
CONF_ENCODING = "encoding"
|
2022-05-31 07:32:44 +00:00
|
|
|
CONF_KEEPALIVE = "keepalive"
|
2023-08-24 07:50:39 +00:00
|
|
|
CONF_ORIGIN = "origin"
|
2022-03-22 11:51:24 +00:00
|
|
|
CONF_QOS = ATTR_QOS
|
|
|
|
CONF_RETAIN = ATTR_RETAIN
|
2022-10-29 08:22:59 +00:00
|
|
|
CONF_SCHEMA = "schema"
|
2019-07-31 19:25:30 +00:00
|
|
|
CONF_STATE_TOPIC = "state_topic"
|
2022-02-10 08:18:35 +00:00
|
|
|
CONF_STATE_VALUE_TEMPLATE = "state_value_template"
|
2021-10-11 21:37:31 +00:00
|
|
|
CONF_TOPIC = "topic"
|
2022-11-23 14:03:31 +00:00
|
|
|
CONF_TRANSPORT = "transport"
|
|
|
|
CONF_WS_PATH = "ws_path"
|
|
|
|
CONF_WS_HEADERS = "ws_headers"
|
2020-06-23 00:49:01 +00:00
|
|
|
CONF_WILL_MESSAGE = "will_message"
|
2022-12-20 16:38:40 +00:00
|
|
|
CONF_PAYLOAD_RESET = "payload_reset"
|
Add option to disable MQTT Alarm Control Panel supported features (#98363)
* Make MQTT Alarm Control Panel features conditional
The MQTT Alarm Control Panel currently enables all features (arm home,
arm away, arm night, arm vacation, arm custom bypass) unconditionally.
This clutters the interface and can even be potentially dangerous, by
enabling modes that the remote alarm may not support.
Make all the features conditional, by adding a new "supported_features"
configuration option, comprising a list of the supported features as
options. Feature enablement seems inconsistent across the MQTT
component; this implementation is most alike to the Humidifier modes
option, but using a generic "supported_features" name that other
implementations may reuse in the future.
The default value of this new setting remains to be all features, which
while it may be overly expansive, is necessary to maintain backwards
compatibility.
* Apply suggestions from code review
* Use vol.Optional() instead of vol.Required() for "supported_features".
* Move the initialization of _attr_supported_features to _setup_from_config.
Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
* Apply suggestions from emontnemery's code review
* Use vol.In() instead of cv.multi_seelct()
* Remove superfluous _attr_supported_features initializers, already
present in the base class.
Co-authored-by: Erik Montnemery <erik@montnemery.com>
* Add invalid config tests for the MQTT Alarm Control Panel
* Set expected_features to None in the invalid MQTT Alarm Control Panel tests
* Add another expected_features=None in the invalid tests
Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
---------
Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-08-18 06:23:48 +00:00
|
|
|
CONF_SUPPORTED_FEATURES = "supported_features"
|
2020-06-23 00:49:01 +00:00
|
|
|
|
2023-06-28 12:21:15 +00:00
|
|
|
CONF_ACTION_TEMPLATE = "action_template"
|
|
|
|
CONF_ACTION_TOPIC = "action_topic"
|
2023-06-21 17:19:26 +00:00
|
|
|
CONF_CURRENT_HUMIDITY_TEMPLATE = "current_humidity_template"
|
|
|
|
CONF_CURRENT_HUMIDITY_TOPIC = "current_humidity_topic"
|
2023-06-08 15:38:30 +00:00
|
|
|
CONF_CURRENT_TEMP_TEMPLATE = "current_temperature_template"
|
|
|
|
CONF_CURRENT_TEMP_TOPIC = "current_temperature_topic"
|
|
|
|
CONF_MODE_COMMAND_TEMPLATE = "mode_command_template"
|
|
|
|
CONF_MODE_COMMAND_TOPIC = "mode_command_topic"
|
|
|
|
CONF_MODE_LIST = "modes"
|
|
|
|
CONF_MODE_STATE_TEMPLATE = "mode_state_template"
|
|
|
|
CONF_MODE_STATE_TOPIC = "mode_state_topic"
|
2023-12-20 06:49:49 +00:00
|
|
|
CONF_PAYLOAD_CLOSE = "payload_close"
|
|
|
|
CONF_PAYLOAD_OPEN = "payload_open"
|
|
|
|
CONF_PAYLOAD_STOP = "payload_stop"
|
|
|
|
CONF_POSITION_CLOSED = "position_closed"
|
|
|
|
CONF_POSITION_OPEN = "position_open"
|
2023-07-25 11:33:02 +00:00
|
|
|
CONF_POWER_COMMAND_TOPIC = "power_command_topic"
|
|
|
|
CONF_POWER_COMMAND_TEMPLATE = "power_command_template"
|
2023-06-08 15:38:30 +00:00
|
|
|
CONF_PRECISION = "precision"
|
2023-12-20 06:49:49 +00:00
|
|
|
CONF_STATE_CLOSED = "state_closed"
|
|
|
|
CONF_STATE_CLOSING = "state_closing"
|
|
|
|
CONF_STATE_OPEN = "state_open"
|
|
|
|
CONF_STATE_OPENING = "state_opening"
|
2023-06-08 15:38:30 +00:00
|
|
|
CONF_TEMP_COMMAND_TEMPLATE = "temperature_command_template"
|
|
|
|
CONF_TEMP_COMMAND_TOPIC = "temperature_command_topic"
|
|
|
|
CONF_TEMP_STATE_TEMPLATE = "temperature_state_template"
|
|
|
|
CONF_TEMP_STATE_TOPIC = "temperature_state_topic"
|
|
|
|
CONF_TEMP_INITIAL = "initial"
|
|
|
|
CONF_TEMP_MAX = "max_temp"
|
|
|
|
CONF_TEMP_MIN = "min_temp"
|
|
|
|
|
2022-03-03 20:40:15 +00:00
|
|
|
CONF_CERTIFICATE = "certificate"
|
|
|
|
CONF_CLIENT_KEY = "client_key"
|
|
|
|
CONF_CLIENT_CERT = "client_cert"
|
|
|
|
CONF_TLS_INSECURE = "tls_insecure"
|
|
|
|
|
2023-08-24 07:50:39 +00:00
|
|
|
# Device and integration info options
|
|
|
|
CONF_IDENTIFIERS = "identifiers"
|
|
|
|
CONF_CONNECTIONS = "connections"
|
|
|
|
CONF_MANUFACTURER = "manufacturer"
|
|
|
|
CONF_HW_VERSION = "hw_version"
|
|
|
|
CONF_SW_VERSION = "sw_version"
|
2024-01-16 13:02:34 +00:00
|
|
|
CONF_SERIAL_NUMBER = "serial_number"
|
2023-08-24 07:50:39 +00:00
|
|
|
CONF_VIA_DEVICE = "via_device"
|
|
|
|
CONF_DEPRECATED_VIA_HUB = "via_hub"
|
|
|
|
CONF_SUGGESTED_AREA = "suggested_area"
|
|
|
|
CONF_CONFIGURATION_URL = "configuration_url"
|
|
|
|
CONF_OBJECT_ID = "object_id"
|
|
|
|
CONF_SUPPORT_URL = "support_url"
|
|
|
|
|
2022-05-31 07:32:44 +00:00
|
|
|
DATA_MQTT = "mqtt"
|
2023-04-20 06:07:35 +00:00
|
|
|
DATA_MQTT_AVAILABLE = "mqtt_client_available"
|
2020-09-19 20:10:01 +00:00
|
|
|
|
2020-07-15 18:16:03 +00:00
|
|
|
DEFAULT_PREFIX = "homeassistant"
|
|
|
|
DEFAULT_BIRTH_WILL_TOPIC = DEFAULT_PREFIX + "/status"
|
2020-10-07 12:51:06 +00:00
|
|
|
DEFAULT_DISCOVERY = True
|
2021-11-30 13:04:24 +00:00
|
|
|
DEFAULT_ENCODING = "utf-8"
|
2023-01-02 10:39:42 +00:00
|
|
|
DEFAULT_OPTIMISTIC = False
|
2019-10-18 00:04:27 +00:00
|
|
|
DEFAULT_QOS = 0
|
2020-07-15 18:16:03 +00:00
|
|
|
DEFAULT_PAYLOAD_AVAILABLE = "online"
|
2023-12-20 06:49:49 +00:00
|
|
|
DEFAULT_PAYLOAD_CLOSE = "CLOSE"
|
2020-07-15 18:16:03 +00:00
|
|
|
DEFAULT_PAYLOAD_NOT_AVAILABLE = "offline"
|
2023-12-20 06:49:49 +00:00
|
|
|
DEFAULT_PAYLOAD_OPEN = "OPEN"
|
2022-10-07 08:12:19 +00:00
|
|
|
DEFAULT_PORT = 1883
|
2020-06-23 00:49:01 +00:00
|
|
|
DEFAULT_RETAIN = False
|
2023-04-11 15:41:38 +00:00
|
|
|
DEFAULT_WS_HEADERS: dict[str, str] = {}
|
2022-11-23 14:03:31 +00:00
|
|
|
DEFAULT_WS_PATH = "/"
|
2023-12-20 06:49:49 +00:00
|
|
|
DEFAULT_POSITION_CLOSED = 0
|
|
|
|
DEFAULT_POSITION_OPEN = 100
|
|
|
|
DEFAULT_RETAIN = False
|
2020-06-07 07:21:16 +00:00
|
|
|
|
2022-10-24 07:58:23 +00:00
|
|
|
PROTOCOL_31 = "3.1"
|
|
|
|
PROTOCOL_311 = "3.1.1"
|
2022-11-17 20:12:27 +00:00
|
|
|
PROTOCOL_5 = "5"
|
|
|
|
SUPPORTED_PROTOCOLS = [PROTOCOL_31, PROTOCOL_311, PROTOCOL_5]
|
2022-10-24 07:58:23 +00:00
|
|
|
|
2022-11-23 14:03:31 +00:00
|
|
|
TRANSPORT_TCP = "tcp"
|
|
|
|
TRANSPORT_WEBSOCKETS = "websockets"
|
|
|
|
|
2022-10-24 07:58:23 +00:00
|
|
|
DEFAULT_PORT = 1883
|
|
|
|
DEFAULT_KEEPALIVE = 60
|
|
|
|
DEFAULT_PROTOCOL = PROTOCOL_311
|
2022-11-23 14:03:31 +00:00
|
|
|
DEFAULT_TRANSPORT = TRANSPORT_TCP
|
2022-10-24 07:58:23 +00:00
|
|
|
|
2020-07-15 18:16:03 +00:00
|
|
|
DEFAULT_BIRTH = {
|
|
|
|
ATTR_TOPIC: DEFAULT_BIRTH_WILL_TOPIC,
|
|
|
|
CONF_PAYLOAD: DEFAULT_PAYLOAD_AVAILABLE,
|
|
|
|
ATTR_QOS: DEFAULT_QOS,
|
|
|
|
ATTR_RETAIN: DEFAULT_RETAIN,
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFAULT_WILL = {
|
|
|
|
ATTR_TOPIC: DEFAULT_BIRTH_WILL_TOPIC,
|
|
|
|
CONF_PAYLOAD: DEFAULT_PAYLOAD_NOT_AVAILABLE,
|
|
|
|
ATTR_QOS: DEFAULT_QOS,
|
|
|
|
ATTR_RETAIN: DEFAULT_RETAIN,
|
|
|
|
}
|
|
|
|
|
2020-10-07 16:30:51 +00:00
|
|
|
DOMAIN = "mqtt"
|
|
|
|
|
2020-06-07 07:21:16 +00:00
|
|
|
MQTT_CONNECTED = "mqtt_connected"
|
|
|
|
MQTT_DISCONNECTED = "mqtt_disconnected"
|
2020-06-23 00:49:01 +00:00
|
|
|
|
2022-01-31 09:31:57 +00:00
|
|
|
PAYLOAD_EMPTY_JSON = "{}"
|
|
|
|
PAYLOAD_NONE = "None"
|
|
|
|
|
2022-06-20 08:26:50 +00:00
|
|
|
RELOADABLE_PLATFORMS = [
|
|
|
|
Platform.ALARM_CONTROL_PANEL,
|
|
|
|
Platform.BINARY_SENSOR,
|
|
|
|
Platform.BUTTON,
|
|
|
|
Platform.CAMERA,
|
|
|
|
Platform.CLIMATE,
|
|
|
|
Platform.COVER,
|
2023-04-01 19:17:53 +00:00
|
|
|
Platform.DEVICE_TRACKER,
|
2023-07-23 12:42:14 +00:00
|
|
|
Platform.EVENT,
|
2022-06-20 08:26:50 +00:00
|
|
|
Platform.FAN,
|
|
|
|
Platform.HUMIDIFIER,
|
2023-06-26 12:42:24 +00:00
|
|
|
Platform.IMAGE,
|
2022-06-20 08:26:50 +00:00
|
|
|
Platform.LIGHT,
|
2023-08-25 15:56:22 +00:00
|
|
|
Platform.LAWN_MOWER,
|
2022-06-20 08:26:50 +00:00
|
|
|
Platform.LOCK,
|
|
|
|
Platform.NUMBER,
|
|
|
|
Platform.SCENE,
|
2022-06-30 17:15:25 +00:00
|
|
|
Platform.SELECT,
|
2022-06-20 08:26:50 +00:00
|
|
|
Platform.SENSOR,
|
|
|
|
Platform.SIREN,
|
|
|
|
Platform.SWITCH,
|
2022-11-29 19:31:05 +00:00
|
|
|
Platform.TEXT,
|
2022-10-24 09:47:45 +00:00
|
|
|
Platform.UPDATE,
|
2022-06-20 08:26:50 +00:00
|
|
|
Platform.VACUUM,
|
2023-12-20 06:49:49 +00:00
|
|
|
Platform.VALVE,
|
2023-06-08 15:38:30 +00:00
|
|
|
Platform.WATER_HEATER,
|
2022-06-20 08:26:50 +00:00
|
|
|
]
|
2024-02-13 09:59:55 +00:00
|
|
|
|
|
|
|
TEMPLATE_ERRORS = (jinja2.TemplateError, TemplateError, TypeError, ValueError)
|