Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.mqtt.device_trigger Namespace Reference

Classes

class  MqttDeviceTrigger
 
class  Trigger
 
class  TriggerInstance
 

Functions

CALLBACK_TYPE async_attach_trigger (HomeAssistant hass, ConfigType config, TriggerActionType action, TriggerInfo trigger_info)
 
list[dict[str, str]] async_get_triggers (HomeAssistant hass, str device_id)
 
None async_removed_from_device (HomeAssistant hass, str device_id)
 
None async_setup_trigger (HomeAssistant hass, ConfigType config, ConfigEntry config_entry, DiscoveryInfoType discovery_data)
 

Variables

 _LOGGER = logging.getLogger(__name__)
 
string CONF_AUTOMATION_TYPE = "automation_type"
 
string CONF_DISCOVERY_ID = "discovery_id"
 
string CONF_SUBTYPE = "subtype"
 
string DEFAULT_ENCODING = "utf-8"
 
string DEVICE = "device"
 
string LOG_NAME = "Device trigger"
 
dictionary MQTT_TRIGGER_BASE
 
 TRIGGER_DISCOVERY_SCHEMA
 
 TRIGGER_SCHEMA
 

Detailed Description

Provides device automations for MQTT.

Function Documentation

◆ async_attach_trigger()

CALLBACK_TYPE homeassistant.components.mqtt.device_trigger.async_attach_trigger ( HomeAssistant  hass,
ConfigType  config,
TriggerActionType  action,
TriggerInfo  trigger_info 
)
Attach a trigger.

Definition at line 368 of file device_trigger.py.

◆ async_get_triggers()

list[dict[str, str]] homeassistant.components.mqtt.device_trigger.async_get_triggers ( HomeAssistant  hass,
str   device_id 
)
List device triggers for MQTT devices.

Definition at line 347 of file device_trigger.py.

◆ async_removed_from_device()

None homeassistant.components.mqtt.device_trigger.async_removed_from_device ( HomeAssistant  hass,
str  device_id 
)
Handle Mqtt removed from a device.

Definition at line 331 of file device_trigger.py.

◆ async_setup_trigger()

None homeassistant.components.mqtt.device_trigger.async_setup_trigger ( HomeAssistant  hass,
ConfigType  config,
ConfigEntry  config_entry,
DiscoveryInfoType  discovery_data 
)
Set up the MQTT device trigger.

Definition at line 289 of file device_trigger.py.

Variable Documentation

◆ _LOGGER

homeassistant.components.mqtt.device_trigger._LOGGER = logging.getLogger(__name__)
private

Definition at line 43 of file device_trigger.py.

◆ CONF_AUTOMATION_TYPE

string homeassistant.components.mqtt.device_trigger.CONF_AUTOMATION_TYPE = "automation_type"

Definition at line 45 of file device_trigger.py.

◆ CONF_DISCOVERY_ID

string homeassistant.components.mqtt.device_trigger.CONF_DISCOVERY_ID = "discovery_id"

Definition at line 46 of file device_trigger.py.

◆ CONF_SUBTYPE

string homeassistant.components.mqtt.device_trigger.CONF_SUBTYPE = "subtype"

Definition at line 47 of file device_trigger.py.

◆ DEFAULT_ENCODING

string homeassistant.components.mqtt.device_trigger.DEFAULT_ENCODING = "utf-8"

Definition at line 48 of file device_trigger.py.

◆ DEVICE

string homeassistant.components.mqtt.device_trigger.DEVICE = "device"

Definition at line 49 of file device_trigger.py.

◆ LOG_NAME

string homeassistant.components.mqtt.device_trigger.LOG_NAME = "Device trigger"

Definition at line 84 of file device_trigger.py.

◆ MQTT_TRIGGER_BASE

dictionary homeassistant.components.mqtt.device_trigger.MQTT_TRIGGER_BASE
Initial value:
1 = {
2  # Trigger when MQTT message is received
3  CONF_PLATFORM: DEVICE,
4  CONF_DOMAIN: DOMAIN,
5 }

Definition at line 51 of file device_trigger.py.

◆ TRIGGER_DISCOVERY_SCHEMA

homeassistant.components.mqtt.device_trigger.TRIGGER_DISCOVERY_SCHEMA
Initial value:
1 = MQTT_BASE_SCHEMA.extend(
2  {
3  vol.Required(CONF_AUTOMATION_TYPE): str,
4  vol.Required(CONF_DEVICE): MQTT_ENTITY_DEVICE_INFO_SCHEMA,
5  vol.Optional(CONF_PAYLOAD, default=None): vol.Any(None, cv.string),
6  vol.Required(CONF_SUBTYPE): cv.string,
7  vol.Required(CONF_TOPIC): cv.string,
8  vol.Required(CONF_TYPE): cv.string,
9  vol.Optional(CONF_VALUE_TEMPLATE, default=None): vol.Any(None, cv.string),
10  },
11  extra=vol.REMOVE_EXTRA,
12 )

Definition at line 71 of file device_trigger.py.

◆ TRIGGER_SCHEMA

homeassistant.components.mqtt.device_trigger.TRIGGER_SCHEMA
Initial value:
1 = DEVICE_TRIGGER_BASE_SCHEMA.extend(
2  {
3  vol.Required(CONF_PLATFORM): DEVICE,
4  vol.Required(CONF_DOMAIN): DOMAIN,
5  vol.Required(CONF_DEVICE_ID): str,
6  # The use of CONF_DISCOVERY_ID was deprecated in HA Core 2024.2.
7  # By default, a MQTT device trigger now will be referenced by
8  # device_id, type and subtype instead.
9  vol.Optional(CONF_DISCOVERY_ID): str,
10  vol.Required(CONF_TYPE): cv.string,
11  vol.Required(CONF_SUBTYPE): cv.string,
12  },
13 )

Definition at line 57 of file device_trigger.py.