I just can’t seem to get the distanceFrom function working
Here’s the rule file:
// 1. Home
val PointType HomeLoc = new PointType(‘12.3456,56.4321’)
// 2. Office
val PointType OfficeLoc = new PointType(‘65.4321,1.234’)
rule "updt geoposition"
Item mqttMyPosition received update
val PointType myPos = new PointType(mqttMyPosition.state.toString)
val officeDistance = OfficeLoc.distanceFrom(myPos)
And the error: 2016-11-06 10:15:14.768 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'updt geoposition': The name '<XFeatureCallImplCustom>.distanceFrom(<XFeatureCallImplCustom>)' cannot be resolved to an item or type.
Can you tell:
… does it really grab the lon lat out of the raw string?
Is the mqttMyPosition a mqttitude or mqtt source?
E.g. mqttitude allows only to resolve to a switch item, while mqtt provides the full string published by OwnTracks.
My advice would be to use the MQTT binding with OwnTracks, since you get more flexibility. A PointType can take a string in the form lat,long[,elevation] (meaning elevation is optional). I think the topic below has more about it:
Hello, I am also getting this error when trying to call the DistanceFrom method: An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.core.library.items.LocationItem.distanceFrom(org.eclipse.smarthome.core.library.items.LocationItem) on instance: locationMarkus (Type=LocationItem, … > using one of the latest snapshot version of openhab2 > any idea?