/config`.
You can use the command line tool `mosquitto_pub` shipped with `mosquitto` or the `mosquitto-clients` package to send MQTT messages.
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"}'
```
To set the state of the device tracker to "home":
```bash
mosquitto_pub -h 127.0.0.1 -t 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'
```
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`
- Example attributes payload:
Example message to be received at topic `a4567d663eaf/attributes`:
```json
{
"latitude": 32.87336,
"longitude": -117.22743,
"gps_accuracy": 1.2
}
```
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"}'
```
Using `state_topic` is optional when using `json_attributes_topic` to determine the state of the device tracker.
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}'
```
### YAML configuration
The following example shows how to configure the same device tracker through configuration.yaml
{% raw %}
```yaml
# Example configuration.yaml entry
mqtt:
- device_tracker:
name: "My Tracker"
state_topic: "a4567d663eaf/state"
payload_home: "home"
payload_not_home: "not_home"
```
{% endraw %}