Send location to Home Assistant from Macrodroid

I had problem with the liability of Owntracks for reporting the location into Home Assistant,
plus I wanted to replace my current Android Automation App (Llama) to a supported one.

In order to replace Llama, I found Macrodroid which satisfy my need.
But I needed to make it work with HA.

I first searched how to use JSON MQTT Device Tracker withtout being successful.
Then I came across an article on Reddit about Tasker (
and I wondered how can I do the same with Macrodroid.

  1. You’ll need to have a MQTT Broker already configured with Owntracks configuration, get the « state_topic ». You can look at HA documentation and HA examples for more informations.
  2. You’ll need to have Macrodroid App
  3. You’ll need to have a Tasker MQTT browser, I selected MQTT Client

First Go into MQTT Client and configure the access to your MQTT server, then go into Macrodroid.

Go to add a new macro, Set « Regular interval » as the trigger with the interval you want (think about battery drain), Go into actions and select « Application », « Local/Tasker Plugin », « Publish to MQTT Message », here select the state_topic you filled in your Home Assistant configuration and use the following message:

{"_type": "location","acc": [last_loc_accuracy],"batt": [battery],"lat": [last_loc_lat],"lon": [last_loc_long],"t": "a","tid": "me","tst": [system_time]}

Validate your action, you can check if it work by clicking on « Test action ». With this you should be able to see the message in the MQTT topic similar to:

{"_type": "location","acc": 40,"batt": 82,"lat": 42.836495,"lon": 2.5897,"t": "a","tid": "lince","tst": 1540032120}

Add contraints, « Mobile data: on » and « Wifi connected », and save the configuration.
You’ll then be able to send periodically your location to your Home Assistant.