Thanks for this nice rule.
Unfortunattely I get an error due to our street name consists of 2 words with a space in between. This results in following error (I replaced my street name by “NAME NAME” and postal code by “9999”). When I use a streetname in 1 word, the error doe not appear.
Any hints to solve this ?
java.lang.IllegalArgumentException: Illegal character in query at index 46: https://recycleapp.be/api/app/v1/streets?q=NAME NAME&zipcodes=9999-13012
at java.net.URI.create(URI.java:883) ~[?:?]
at org.eclipse.jetty.client.HttpClient.newRequest(HttpClient.java:453) ~[bundleFile:9.4.43.v20210629]
at org.openhab.core.io.net.http.HttpUtil.executeUrlAndGetReponse(HttpUtil.java:212) ~[?:?]
at org.openhab.core.io.net.http.HttpUtil.executeUrl(HttpUtil.java:155) ~[?:?]
at org.openhab.core.io.net.http.HttpUtil.executeUrl(HttpUtil.java:130) ~[?:?]
at org.openhab.core.model.script.actions.HTTP.sendHttpGetRequest(HTTP.java:79) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$409$6047$\^eval\_.getStreetId(<eval>:134) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$399$8158A$\^eval\_.updateWasteCalendar(<eval>:182) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$398$3841A$\^eval\_.updateWithRetry#timer(<eval>:66) ~[?:?]
at jdk.nashorn.javaadapters.org_eclipse_xtext_xbase_lib_Procedures$Procedure1.apply(Unknown Source) ~[?:?]
at org.openhab.core.model.script.actions.ScriptExecution.lambda$1(ScriptExecution.java:100) ~[?:?]
at org.openhab.core.internal.scheduler.SchedulerImpl.lambda$12(SchedulerImpl.java:184) ~[?:?]
at org.openhab.core.internal.scheduler.SchedulerImpl.lambda$1(SchedulerImpl.java:87) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:829) [?:?]
Caused by: java.net.URISyntaxException: Illegal character in query at index 46: https://recycleapp.be/api/app/v1/streets?q=NAME NAME&zipcodes=9999-13012
at java.net.URI$Parser.fail(URI.java:2913) ~[?:?]
at java.net.URI$Parser.checkChars(URI.java:3084) ~[?:?]
at java.net.URI$Parser.parseHierarchical(URI.java:3172) ~[?:?]
at java.net.URI$Parser.parse(URI.java:3114) ~[?:?]
at java.net.URI.<init>(URI.java:600) ~[?:?]
at java.net.URI.create(URI.java:881) ~[?:?]
... 18 more
Besides this error, I also get an error related to the scheduler :
@Beec If you switch on TRACE logging for the rule, you will get all details, with the strings to match. The lines from the screenshot need to becextended with the appropriate match strings. You can also send me your address by private message, and I will check it out and extend the rule.
@Beec Download and configure the template again. I think it should work now. Note I couldn’t find a textile fraction in the API response for Herenthout (but I did see a glass fraction, which I added).
Had the same problem.
The secret token has changed.
Go to the code tab of the rule and find and replace the line with “var X_SECRET=” to:
var X_SECRET = "8eTFgy3AQH0mzAcj3xMwaKnNyNnijEFIEegjgNpBHifqtQ4IEyWqmJGFz3ggKQ7B4vwUYS8xz8KwACZihCmboGb6brtVB3rpne2Ww5uUM2n3i4SKNUg6Vp7lhAS8INDUNH8Ll7WPhWRsQOXBCjVz5H8fr0q6fqZCosXdndbNeiNy73FqJBn794qKuUAPTFj8CuAbwI6Wom98g72Px1MPRYHwyrlHUbCijmDmA2zoWikn34LNTUZPd7kS0uuFkibkLxCc1PeOVYVHeh1xVxxwGBsMINWJEUiIBqZt9VybcHpUJTYzureqfund1aeJvmsUjwyOMhLSxj9MLQ07iTbvzQa6vbJdC0hTsqTlndccBRm9lkxzNpzJBPw8VpYSyS3AhaR2U1n4COZaJyFfUQ3LUBzdj5gV8QGVGCHMlvGJM0ThnRKENSWZLVZoHHeCBOkfgzp0xl0qnDtR8eJF0vLkFiKwjX7DImGoA8IjqOYygV3W9i9rIOfK";
here is some more info how to find the new secret if it should change:
Works for me. I hope it also does work for you.
@Mherwege maybe you can update the template with this new secret?
When checking the new token, I also noticed they use a new/other URL.
Old one is still working but it might fail in the future. current URL used by binding/script : https://recycleapp.be/api/app/v1 new URL used by the website : https://api.fostplus.be
One is a redirection to the other I think. Something to take into account. When having time, I need to update my binding as well.
Seems that we (East-Flandres?) need “restafval” in the residual_waste list to have it working. Bit weird that they have so many terms for it. Seems to be a garbage bin of garbages…
Any plans to make it available for OH4? Seems it spits out an error as we speak
2023-04-26 12:50:52.189 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID '07f5211181' failed: org.graalvm.polyglot.PolyglotException: TypeError: invokeMember (now) on java.time.ZonedDateTime failed due to: Unknown identifier: now
I added “restafval” in the template. I also live in East-Flanders, and there is no issue for me. I believe it depends on the “intercommunale”. As soon as there is a slight difference from the standard in the definition of the allowed content of the fraction, the “intercommunale” creates a new name for the fraction.
The template still works in OH4 if you install the Nashorn extension. It may work with OH4 javascript (without Nashorn, but with graalVM) after the fix I just applied, but I did not test. I am still running 3.4 in my main instance, so did not switch yet. I intend to do so closer to the OH4 release date when I make the switch myself.