I’m doing this based on some example I saw somewhere on Google+ but I think my issue is when I try and use a transformation JS script. I’ve not created a JS transformation script before so hopefully it’s an easy fix for someone who knows what they are doing.
This is all I found on Google+ and they said it should go on the JS script file…
The OpenHAB error log has stuff like this in it now…
2016-06-11 16:10:37.053 [ERROR] [.service.AbstractActiveService] - Error while executing background thread HTTP Refresh Service
java.util.UnknownFormatConversionException: Conversion = 'R’
at java.util.Formatter$FormatSpecifier.conversion(Unknown Source) ~[na:1.8.0_60]
at java.util.Formatter$FormatSpecifier.(Unknown Source) ~[na:1.8.0_60]
at java.util.Formatter.parse(Unknown Source) ~[na:1.8.0_60]
at java.util.Formatter.format(Unknown Source) ~[na:1.8.0_60]
at java.util.Formatter.format(Unknown Source) ~[na:1.8.0_60]
at java.lang.String.format(Unknown Source) ~[na:1.8.0_60]
at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:136) ~[na:na]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) ~[na:na]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) ~[na:na]
I am guessing that OriginAddressHere, DesintationAddressHere or GoogleAPIKeyHere contain a % or a $ followed shortly thereafter with the letter R. If so, try to change them so there is no % or $ in the URL (possibly meaning to generate a new Google API key).
That @watou, that seems to be the cause… It seems to the the spaces in my address which are causing the issue. Spaces in the URL are represented as %20
Have you tried replacing the URL-escaped spaces %20 with regular spaces? It might make sense to add an option to the HTTP binding to disable the string formatting around the line in your stacktrace, so this situation can be resolved without having to change the URL, but in the meantime, will regular spaces work?
Hi Tommy, please create a new issue, referencing the collision between URLs that have URL escapes, and this line of code (and possibly others) that assumes that the URL does not accidentally contain formatter marks. A simple solution in code might be to just catch and ignore the java.util.UnknownFormatConversionException (but maybe add a DEBUG log entry in case the user means to do replacements but got the format wrong).
Hi again, I’ve made a test JAR to replace your HTTP binding. To use it, add format=false to http.cfg, or http:format=false to openhab.cfg. This will cause the binding to skip its attempt at replacing into the URL the current time or state string, and thereby ought to solve what you encountered.
I had considered just silently ignoring the exception you encountered, but that doesn’t help the situation where your URL accidentally contains a valid format string, resulting in its being successfully substituted, but that’s not what the user wants.
Would you give it a try and report back, @TommySharp?
Maybe I’m doing something wring but this is what I’m getting in the logs now…
2016-06-16 12:33:35.644 [ERROR] [.service.AbstractActiveService] - Error while executing background thread HTTP Refresh Service
java.util.UnknownFormatConversionException: Conversion = 'R’
at java.util.Formatter$FormatSpecifier.conversion(Unknown Source) ~[na:1.8.0_60]
at java.util.Formatter$FormatSpecifier.(Unknown Source) ~[na:1.8.0_60]
at java.util.Formatter.parse(Unknown Source) ~[na:1.8.0_60]
at java.util.Formatter.format(Unknown Source) ~[na:1.8.0_60]
at java.util.Formatter.format(Unknown Source) ~[na:1.8.0_60]
at java.lang.String.format(Unknown Source) ~[na:1.8.0_60]
at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:136) ~[na:na]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) ~[na:na]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) ~[na:na]
2016-06-16 12:33:35.675 [INFO ] [.myopenhab.internal.MyOHClient] - Connected to my.openHAB service (UUID = xxxxxxxxxxxxxxxxxxxxxxxxxx, base URL = http://localhost:8080)
2016-06-16 12:33:36.373 [WARN ] [i.internal.GenericItemProvider] - Attempted to register a second BindingConfigReader of type ‘http’. The primaraly reader will remain active!
2016-06-16 12:33:36.386 [INFO ] [.service.AbstractActiveService] - HTTP Refresh Service has been started
2016-06-16 12:33:36.395 [ERROR] [.service.AbstractActiveService] - Error while executing background thread HTTP Refresh Service
java.lang.ClassCastException: org.openhab.binding.http.internal.HttpGenericBindingProvider cannot be cast to org.openhab.binding.http.HttpBindingProvider
at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:145) ~[na:na]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) ~[na:na]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) ~[na:na]
I left my item using the GPS location in the HTTP url, so no spaces and also removed the setting you wanted me to add to the config file.
So all I have now is your new JAR file and I still get an error message.
2016-06-16 13:29:04.876 [ERROR] [.service.AbstractActiveService] - Error while executing background thread HTTP Refresh Service
java.lang.ClassCastException: org.openhab.binding.http.internal.HttpGenericBindingProvider cannot be cast to org.openhab.binding.http.HttpBindingProvider
at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:145) ~[na:na]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) ~[na:na]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) ~[na:na]
So I’m going to revert back for now as it’s working okay with the GPS locations.
The openHAB server could be confused at that point after both JARs were present and might need to be stopped and restarted (mixing old and new classes maybe). Had you started the server with only the new JAR in place and the old one removed from addons?
Hi @TommySharp, could you try this again? The test JAR is here, and if you remove your HTTP binding JAR from addons and put this one in its place, and make sure your active openhab.cfg has the line
http:format=false
Your URLs that contain character substrings like %20R should be ignored. I would like to verify this PR is good, so your help is much appreciated!