I think the first php script I provided should work as it works for me. I first use
<?php
include("class.sosumi.php");
$iTunesUsername = "uuuuuuu";
$iTunesPassword = "ppppppppppp";
$ssm = new Sosumi($iTunesUsername, $iTunesPassword);
print_r($ssm->devices); // Uncomment this line to view all your device id's
and then I get the device id I want to put into owntrack. I then copy that id to this script.
<?php
date_default_timezone_set('America/Los_Angeles');
include("class.sosumi.php");
require("phpMQTT.php");
$iTunesUsername = "[email protected]";
$iTunesPassword = "mypassword";
$deviceID = "ylCHk8qadfgfdgdfgfgarbagedYVNSUzmWV"; //iphone 8
$playSound = true;
$ssm = new Sosumi($iTunesUsername, $iTunesPassword);
$loc = $ssm->locate($deviceID);
$lat = $loc["latitude"];
$long = $loc["longitude"];
$bat = ceil($loc["batteryLevel"]*100);
$acc = $loc["accuracy"];
$tst = strtotime($loc["timestamp"]);
$tid = $loc["name"];
$tst2 = date("D M j g:i a" );
$host = "192.168.2.150";
$port = 1883;
$clientid = "userid";
$username = "hass";
$password = "hass";
$message = "{\"t\":\"u\",\"tst\":$tst,\"acc\":$acc,\"alt\":50,\"lon\":$long,\"_type\":\"location\",\"lat\":$lat,\"tid\":\"pp\",\"batt\":$bat}";
$mqtt = new phpMQTT($host, $port, $clientid);
if ($mqtt->connect(true,NULL,$username,$password)) {
$mqtt->publish("owntracks/person/ifind",$message, 0);
$mqtt->close();
}else{
echo "Fail or time out<br />";
}
which simply take the log and lat info and puts it into mqtt. Make sure you have the phpMQTT.php in the same directory
Also, make sure you put owntrack into configuration.yaml
device_tracker:
- platform: owntracks