okay thank for the clarification @Confused
i found this “tutorial” on github and got this so far:
but i needed to make some little adjustments in the rule - i changed:
(new DecimalType(acc)) to (acc)
(new PercentType(batt)) to (batt)
my rule now:
import org.openhab.core.library.types.*
rule "Mqtt Postion Parse Philipp"
when
Item mqttPositionPhilippRaw received update
then
val String json = (mqttPositionPhilippRaw.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)
mqttPhilippLatitude.postUpdate(lat)
mqttPhilippLongitude.postUpdate(lon)
locationPhilipp.postUpdate(new PointType(lat + "," + lon))
mqttPhilippAccuracy.postUpdate(acc)
mqttPhilippBattery.postUpdate(batt)
logInfo("ownTRACKS=", +mqttPositionPhilippRaw.state)
}
end
on github patrik had this changes:
mqttPatikAccuracy.postUpdate(new DecimalType(acc))
mqttBattery.postUpdate(new PercentType(batt))
and i get this in the log:
[INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'owntracks.rules'
==> /var/log/openhab2/events.log <==
2017-11-28 21:15:30.027 [ItemStateChangedEvent ] - mqttPositionPhilippRaw changed from {"batt":58,"lon":XX.XXXXXXXXXX,"acc":165,"vac":10,"lat":XX.XXXXXXXXXX,"t":"u","_cp":1,"conn":"w","tst":1511900024,"alt":366,"_type":"location","tid":"PL"} to
2017-11-28 21:15:30.870 [ItemStateChangedEvent ] - mqttPhilippLatitude changed from XX.XXXXXXXXXX to XX.XXXXXXXXXX
2017-11-28 21:15:30.874 [ItemStateChangedEvent ] - mqttPhilippLongitude changed from XX.XXXXXXXXXX to XX.XXXXXXXXXX
2017-11-28 21:15:30.892 [ItemStateChangedEvent ] - locationPhilipp changed from XX.XXXXXXXXXX,XX.XXXXXXXXXX to XX.XXXXXXXXXX,XX.XXXXXXXXXX
2017-11-28 21:15:30.895 [ItemStateChangedEvent ] - mqttPhilippAccuracy changed from 165 to 10
==> /var/log/openhab2/openhab.log <==
2017-11-28 21:15:30.900 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'Mqtt Postion Parse Philipp': An error occurred during the script execution: index=1, size=1