Hello,
I started to use Home Assistant some time ago and I use a MQTT broker with OwnTracks to do somes device tracking. It’s good for IOS and Android plateform, but sometime we need to track something else. I may forget my phone, but not my car if i’m away from home.
I didn’t find article about using OwnTracks and Home-Assistant to manually update physical device tracking, so I created a very small PHP script to update position. This script use Mosquitto\Client() from PECL to publish an owntracks location update. I use a custom script to parse car tracking website app to extract the position of my car ($last variable). Dont ask me the source code, I don’t want to publish it (« unofficial reverse api from the mobile app »).
The result is not so bad
Here the source code :
$client = new \Mosquitto\Client(); $client->setCredentials("login", "password"); $client->connect("mqtt.iot.local", 1883, 5); $json = array( "_type" => "location", "acc" => 25, "alt" => $last->position->altitude, "batt" => 100, "cog" => $last->position->heading, "desc" => "", "event" => "", "lat" => $last->position->latitude, "lon" => $last->position->longitude, "rad" => 0, "t" => "a", "tid" => "RO", "tst" => $last->dateTime, "vac" => 0, "vel" => $last->speed ); $output = json_encode($json); $client->loop(); $mid = $client->publish('owntracks/francois/rogue', $output); $client->loop(); $client->disconnect(); unset($client);