Skip to content

Commit

Permalink
Add missing discovery prefix on device tracker's MQTT topics (home-as…
Browse files Browse the repository at this point in the history
  • Loading branch information
Passific authored Dec 6, 2024
1 parent f1c6590 commit b8f4353
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions source/_integrations/device_tracker.mqtt.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -205,27 +205,27 @@ You can use the command line tool `mosquitto_pub` shipped with `mosquitto` or th
To create the device_tracker:

```bash
mosquitto_pub -h 127.0.0.1 -t homeassistant/device_tracker/a4567d663eaf/config -m '{"state_topic": "a4567d663eaf/state", "name": "My Tracker", "payload_home": "home", "payload_not_home": "not_home"}'
mosquitto_pub -h 127.0.0.1 -t homeassistant/device_tracker/a4567d663eaf/config -m '{"state_topic": "homeassistant/device_tracker/a4567d663eaf/state", "name": "My Tracker", "payload_home": "home", "payload_not_home": "not_home"}'
```

To set the state of the device tracker to "home":

```bash
mosquitto_pub -h 127.0.0.1 -t a4567d663eaf/state -m 'home'
mosquitto_pub -h 127.0.0.1 -t homeassistant/device_tracker/a4567d663eaf/state -m 'home'
```

To set the state of the device tracker to a named location:

```bash
mosquitto_pub -h 127.0.0.1 -t a4567d663eaf/state -m 'location_name'
mosquitto_pub -h 127.0.0.1 -t homeassistant/device_tracker/a4567d663eaf/state -m 'location_name'
```

If the device supports GPS coordinates then they can be sent to Home Assistant by specifying an attributes topic (i.e. "json_attributes_topic") in the configuration payload:

- Attributes topic: `a4567d663eaf/attributes`
- Attributes topic: `homeassistant/device_tracker/a4567d663eaf/attributes`
- Example attributes payload:

Example message to be received at topic `a4567d663eaf/attributes`:
Example message to be received at topic `homeassistant/device_tracker/a4567d663eaf/attributes`:

```json
{
Expand All @@ -238,7 +238,7 @@ Example message to be received at topic `a4567d663eaf/attributes`:
To create the device_tracker with GPS coordinates support:

```bash
mosquitto_pub -h 127.0.0.1 -t homeassistant/device_tracker/a4567d663eaf/config -m '{"json_attributes_topic": "a4567d663eaf/attributes", "name": "My Tracker"}'
mosquitto_pub -h 127.0.0.1 -t homeassistant/device_tracker/a4567d663eaf/config -m '{"json_attributes_topic": "homeassistant/device_tracker/a4567d663eaf/attributes", "name": "My Tracker"}'
```

{% note %}
Expand All @@ -250,7 +250,7 @@ Using `state_topic` is optional when using `json_attributes_topic` to determine
To set the state of the device tracker to specific coordinates:

```bash
mosquitto_pub -h 127.0.0.1 -t a4567d663eaf/attributes -m '{"latitude": 32.87336, "longitude": -117.22743, "gps_accuracy": 1.2}'
mosquitto_pub -h 127.0.0.1 -t homeassistant/device_tracker/a4567d663eaf/attributes -m '{"latitude": 32.87336, "longitude": -117.22743, "gps_accuracy": 1.2}'
```


Expand Down

0 comments on commit b8f4353

Please sign in to comment.