This is great and I have been using it for some time so thank you.
I am however trying to make a minor improvement as I don’t always get the Event messages.
Looking at what owntracks sends
mqttPositionJonathanRaw changed from {"_type":"lwt","tst":1565864196} to {"_type":"location","acc":15,"alt":0,"batt":91,"conn":"w","inregions":["Home"],"lat":50.181328,"lon":-0.2540099,"tid":"1","tst":1565864416,"vac":0,"vel":0}
You have the inregions which would solve the issue if the event notification didn’t make it to the server.
so My though was modify the rules:
rule "MqttPostionParseJonathan"
when
Item mqttPositionJonathanRaw changed
then
val String json = (mqttPositionJonathanRaw.state as StringType).toString
val String type = transform("JSONPATH", "$._type", json)
if (type == "location") {
val String lat = transform("JSONPATH", "$.lat", json)
val String lon = transform("JSONPATH", "$.lon", json)
val String acc = transform("JSONPATH", "$.acc", json)
val String batt = transform("JSONPATH", "$.batt", json)
val String inregions = transform("JSONPATH", "$.events", json)
and the item:
//MQTT Binding
String mqttPositionJonathanRaw "Jonathan's Raw Data [%s]" { mqtt="<[mosquitto:owntracks/openhabian/Jb:state:default]" }
DateTime mqttJonathanLastUpdated "Jonathan's last update [%1$tm/%1$td/%1$tY %1$tH:%1$tM:%1$tS]" <clock> { mqtt="<[ mosquitto:owntracks/openhabian/Jb:state:JS(mqttitude-tstamp.js)]" }
Location locationJonathan
String mqttJonathanLatitude
String mqttJonathanLongitude
String mqttJonathanEvents
String mqttJonathanAccuracy "Jonathan's Accuracy [%s]"
String mqttJonathanBattery "Jonathan's Android Battery [%s%%]" <battery> (Phone,MQTT)
Switch jonathan_moving "Notify on motion" <siren>
Number jonathanDistanceFromHome "Miles from home [%.1f]"
However I am having little luck. Would someone be able to point me in the right direction?