home-assistant.io/source/_integrations/device_tracker.mqtt.markdown

1.9 KiB

title description ha_category ha_iot_class ha_release ha_domain
MQTT Device Tracker Instructions on how to use MQTT to track devices in Home Assistant.
Presence Detection
Configurable 0.7.3 mqtt

The mqtt device tracker platform allows you to detect presence by monitoring an MQTT topic for new locations. To use this platform, you specify a unique topic for each device.

Configuration

To use this device tracker in your installation, add the following to your configuration.yaml file:

# Example configuration.yaml entry
device_tracker:
  - platform: mqtt
    devices:
      paulus_oneplus: 'location/paulus'
      annetherese_n4: 'location/annetherese'

{% configuration %} devices: description: List of devices with their topic. required: true type: list qos: description: The QoS level of the topic. required: false type: integer payload_home: description: The payload value that represents the 'home' state for the device. required: false type: string default: 'home' payload_not_home: description: The payload value that represents the 'not_home' state for the device. required: false type: string default: 'not_home' source_type: description: Attribute of a device tracker that affects state when being used to track a person. Valid options are gps, router, bluetooth, or bluetooth_le. required: false type: string {% endconfiguration %}

Complete example configuration

# Complete configuration.yaml entry
device_tracker:
  - platform: mqtt
    devices:
      paulus_oneplus: 'location/paulus'
      annetherese_n4: 'location/annetherese'
    qos: 1
    payload_home: 'present'
    payload_not_home: 'not present'
    source_type: bluetooth

Usage

Example JSON you can publish to the topic (e.g., via mqtt.publish service):

{
  "topic": "location/paulus",
  "payload": "home"
}