[SOLVED] OH3, i need help with gps logger rule

Hi,
Old system: OH 2.5 win10
New system: openhabian 3
*the rule works on the old system no problems at all.

The rule is location via APP gps logger on Android, I see on the map in OH that the phone moves but ITEM does not change from ON to OFF and stays stuck on ON, I checked via Fake GPS and through this the ITEM does change to OFF when I choose a fake location.

val Number DistanceArrived = 150
val Number DistanceLeft = 150
val Number AccuracyThreshold = 200

/* sapir at home */
rule "sapir at home"
when
Item distanceHomesapir received update
then
	var Number distance = (distanceHomesapir.state as QuantityType<Number>).doubleValue
	var Number accuracy = (accuracysapir.state as QuantityType<Number>).doubleValue
	
if (accuracy < AccuracyThreshold) { // do only something if the accuracy is high enough
	if ((distance < DistanceArrived) && (sapirAtHome.state == OFF)) {
		sendCommand(sapirAtHome,ON)
	}
	else if ((sapirAtHome.state == ON) && (distance > DistanceLeft)) {
		sendCommand(sapirAtHome,OFF)

	}
}
end

I guess you’ll need to log some values out, to understand what is happening.

I solved this, the item distanceHomesapir
Report in km and not in meters
So I added [% d m] to item via Edit Item Metadata: stateDescription Pattern:

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.