I’m running HA on an Intel NUC in Docker. I’m trying to use one or more Raspberry Pi’s as “remote device trackers”, sending status to my main HA instance over MQTT. I figure this should be pretty straightforward (and probably a popular use case) but I just can’t figure it out.
So the “remote” HA instances will run Hass.io on a RPi3. I want to place one or more of these in the house to detect Bluetooth (and maybe BLE) devices with Device Tracker. I have all this set up and running now. My main HA instance is up and running fine too.
I guess I’m just not getting my head around MQTT. How do I tell the Hass.io instance to send device tracker messages to the main HA instance? I can run Mosquitto or the embedded MQTT broker. I don’t care. But I don’t know how to get it to work.
What do I add to the config to “subscribe” to messages? What do I add to “publish”?
Thanks so much! I feel like such an idiot for not being able to figure this out!
Next, I had some success replicating @Vasiley’s persistence.yaml work - this really helped me figure out how to do some cool stuff with MQTT. His persistence_publish code inspired me to put together a functional mqtt.publish for device tracking:
Using state_changed as a trigger is a great idea! I’m checking to make sure it’s a device_tracker event then sending it to my MQTT server using a custom topic prefix (fsp1/btdt/). So a device entry appears like “fsp1/btdt/device_tracker/stephen_macbook” in MQTT.
This is going to a Mosquitto instance running in a container on my main HA server.
Then I have the main server importing these using the device_tracker.mqtt platform. This is really not ideal since it’s hard coded per device. I would love to do something like Vasiley’s import stuff but I just couldn’t get it working. I would appreciate suggestions!
In the mean time, here’s my simple code from configuration.yaml: