Waste Collection Belgium [3.3.0;3.4.9)

@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).

@Mherwege It works perfectly now. Big thank you for the prompt support and update.

I’m trying to use this rule but stumble upon two errors. The first one is easily fixed, the second, I can’t find a solution.

13:47:23.953 [ERROR] [.internal.handler.ScriptActionHandler] - Script execution of rule with UID '0d8aea4804' failed: <eval>:27:90 Missing close quote
  GLASS:           { "item": ",           "fraction": [ "glass"                       ] },
                                                                                          ^ in <eval> at line number 27 at column number 90
13:47:31.762 [TRACE] [ab.model.script.mherwege.wasteBelgium] - Attempt 3 of 10
13:47:31.766 [TRACE] [ab.model.script.mherwege.wasteBelgium] - URL: https://recycleapp.be/api/app/v1/access-token
13:47:31.805 [ERROR] [penhab.core.model.script.actions.HTTP] - Fatal transport error: java.util.concurrent.ExecutionException: org.eclipse.jetty.client.HttpResponseException: HTTP protocol violation: Authentication challenge without WWW-Authenticate header
13:47:31.806 [DEBUG] [ab.model.script.mherwege.wasteBelgium] - JSON Token: null
13:47:31.807 [DEBUG] [ab.model.script.mherwege.wasteBelgium] - Request failed, attempt 3 of 10
13:47:31.809 [DEBUG] [ab.model.script.mherwege.wasteBelgium] - Next attempt in 120s

I fixed the first issue in the template.

What version of OH are you using? I have not seen the second issue yet.

I’m using 3.3.0.

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?

Thanks @Novanoid. Changed the token and it works flawlessly.
Will keep your solution in mind.

The template has been updated with the new access token.

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.

@BeanzBE I modified the template to use the new url. The street address GET also needs to be replaced by a POST command.

Many thanks for this script.
For the Wallonia, could you add “omb” in the residual_waste list and “organiques” in the GFT.

Thanks again.

Done

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… :wink:



Any plans to make it available for OH4? Seems it spits out an error as we speak :cry:

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.

1 Like

I’m running openHAB 4.0.0.M1 with the ‘JavaScript Scripting (Nashorn)’ installed.
But getting the error, not sure if I need something else?

Just had a quick look, and I can’t find graalVM.

You shouldn’t need anything else. Did you try with the adjusted version I loaded 1h ago? I made a slight change that could have an impact.

I need to copy/paste from 2 installation since I can’t find the rule template in OH4. But if I did it correct, I’m getting now following error:

Script execution of rule with UID '07f5211181' failed: java.lang.NullPointerException: Cannot invoke "java.time.temporal.TemporalUnit.addTo(java.time.temporal.Temporal, long)" because "unit" is null

I just tried with an OH4 snapshot and Nashorn js installed. It runs fine.
Check out line 66 in the script. That’s where I have made the change. It should be:

timer = ScriptExecution.createTimerWithArgument(now.plus(delayInSeconds, ChronoUnit.SECONDS), func, function() {

That’s correct, I’ve got the latest version. But still having:

2023-04-26 19:38:46.775 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID '07f5211181' failed: java.lang.NullPointerException: Cannot invoke "java.time.temporal.TemporalUnit.addTo(java.time.temporal.Temporal, long)" because "unit" is null

Will have some other tests tomorrow.

Guess something is wrong in my system, but not sure where. Everything else seems to be working fine. Can I add extra debugs to the logs?

Just did an upgrade towards 4.0.0.M2, but no luck :cry:

When I check the installed bundles, I see I have 2 JavaScript Scripting? Not sure why. But no difference with 1 installed, the other or both. Always the same error.

openhab> bundle:list | grep ava
 37 │ Active   │  80 │ 30.1.0.jre             │ Guava: Google Core Libraries for Java
 38 │ Active   │  80 │ 1.0.1                  │ Guava InternalFutureFailureAccess and InternalFutures
 54 │ Active   │  80 │ 1.2                    │ javax.annotation API
 88 │ Active   │  80 │ 1.0.0.2                │ Apache ServiceMix :: Bundles :: javax.inject
234 │ Active   │  80 │ 2.1.0                  │ Units of Measurement Common Library for Java
240 │ Active   │  80 │ 1.6.2                  │ JavaMail API
253 │ Active   │  80 │ 2.2.19                 │ rxjava
256 │ Active   │  80 │ 20180813.0.0           │ JSON in Java
257 │ Active   │  80 │ 0.3.0.v20220506-1020   │ EdDSA-Java
258 │ Active   │  80 │ 5.2.1.OH1              │ nrjavaserial
266 │ Active   │  80 │ 2.1.2                  │ Java Concurrency Tools Core Library
268 │ Active   │  80 │ 4.0.0.M2               │ openHAB Add-ons :: Bundles :: Automation :: JavaScript Scripting (Nashorn)
323 │ Active   │  80 │ 4.0.0.M2               │ openHAB Add-ons :: Bundles :: Automation :: JavaScript Scripting