I'm having a problem with JavaScript throwing a NULL pointer error.
It was occurring in
Openhab 1.4 and I've just upgraded to Openhab 1.5 and it's still occurring.
I'm trying to transform the output of an MQTT binding to display a googlemap link. Although at the moment I'd be happy with it displaying anything.
Here is the sitemap section to display the link and attached is the sitemap screenshot
Frame {
Text item=gps_string
Text item=Map_Luke_Phone
}
As you can see the gps_string
displays however the other doesn't.
This is the error it throws from the debug console
21:36:33.684 INFO runtime.busevents[:26] - gps_string state updated to {"_type": "location", "lat": "-42.8533391", "lon": "147.2942751", "tst": "1402918551", "acc": "30.0", "batt": "77"}
21:36:33.684 DEBUG o.o.c.t.i.s.JavaScriptTransformationService[:61] - about to transform '{"_type": "location", "lat": "-42.8533391", "lon": "147.2942751", "tst": "1402918551", "acc": "30.0", "batt": "77"}' by the Java Script 'owntrack_maps.js'
21:36:33.687 ERROR o.o.b.m.i.MqttMessageSubscriber[:138] - Error processing MQTT message.
java.lang.NullPointerException: null
at org.openhab.core.transform.internal.service.JavaScriptTransformationService.transform(JavaScriptTransformationService.java:77)
at org.openhab.binding.mqtt.internal.MqttMessageSubscriber.processMessage(MqttMessageSubscriber.java:121)
at org.openhab.io.transport.mqtt.internal.MqttBrokerConnection.messageArrived(MqttBrokerConnection.java:566)
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:336)
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:148)
at java.lang.Thread.run(Thread.java:744)
And here is the section from the item and transform files.
/* GeoLocation */
Group Location (All)
String gps_string "prior [%s]" <wind> (Location) { mqtt="<[mosquitto:owntracks/luke/#:state:default]" }
String Map_Luke_Phone "after [%s]" (Location) { mqtt="<[mosquitto:owntracks/luke/#:state:JS(owntrack_maps.js)]" }
server transform # pwd
/opt/openhab-1.5/configurations/transform
server transform # ls -l owntrack_maps.js
-rwxr-xr-x 1 root root 145 Jun 16 21:23 owntrack_maps.js
server transform # cat owntrack_maps.js
//var location = eval('{' + input + '}');
//result = "http://maps.google.com/maps?z=12&t=m&q=loc:" + location.lat + "+" + location.lon;
//"http://maps.google.com/maps?z=12&t=m&q=loc:" + location.lat + "+" + location.lon;
BLAHBLAH
As you can see I've tried the JS file just about all different ways and all throw NULL pointer errors.
I'm pretty confident the Mosquitto MQTT broker side is OK because I'm running a mosquitto_sub on the same topic and it's fine, pluis the gps_string item shows the correct pre-transform data as well.
I'm sure it's something stupid I've done in the item binding however I don’t know what or wher eto look next.
Thanks,
Luke
var location = eval('(' + input + ')');
result = "http://maps.google.com/maps?z=12&t=m&q=loc:" + location.lat + "+" + location.lon;
result = "http://maps.google.com/maps?z=12&t=m&q=loc:0+0";
--
You received this message because you are subscribed to the Google Groups "openhab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
For more options, visit https://groups.google.com/d/optout.
result = "http://maps.google.com/maps?z=12&t=m&q=loc:0+0";