- Platform information:
- Hardware: rPi 4
- OS: rPi
- openHAB version: OH3
I would like to change a state of an item based on the location of the user (iPhone) from home.
I setup the rule first in the GUI rule: when item location change
then I try to create a script from one of the users here in the community. But it doesn’t work and I am not sure which of the 3 script type that should be (python I guess not) but javascript or rule?
THE SCRIPT
rule “iPhone Home”
when
Item iPhone12Pro_Location changed
then
val PointType home_location = new PointType(new DecimalType(xx.948837), new DecimalType(xx.959258))
val PointType phone_location = iPhone12Pro_Location.state as PointType
val int distance = phone_location.distanceFrom(home_location).intValue()
// home radius geofence to determine home/away (in meters)
if ( distance < 500)
{
logInfo(logName, “I am at home.”)
}
else
{
logInfo(logName, “I am away.”)
}
end
THE ERROR
- The method or field rule is undefined; line 1, column 0, length 4
- The method or field when is undefined; line 2, column 19, length 4
- The method or field changed is undefined; line 3, column 62, length 7
- The method or field then is undefined; line 4, column 70, length 4
- The method or field logName is undefined; line 13, column 472, length 7
- The method or field logName is undefined; line 17, column 519, length 7
- The method or field end is undefined; line 19, column 544, length 3
- This expression is not allowed in this context, since it doesn’t cause any side effects.; line 1, column 5, length 13
- This expression is not allowed in this context, since it doesn’t cause any side effects.; line 3, column 28, length 4
- This expression is not allowed in this context, since it doesn’t cause any side effects.; line 3, column 33, length 28