Waste collections Belgium

Hi @BeanzBE

I get the following error now:

2021-03-01 21:39:05.852 [INFO ] [um.internal.RecycleappBelgiumHandler] - Start fetching next waste collection...

2021-03-01 21:39:06.354 [INFO ] [um.internal.RecycleappBelgiumHandler] - java.lang.NullPointerException

2021-03-01 21:39:06.356 [INFO ] [um.internal.RecycleappBelgiumHandler] - Empty token

My thing config is:


Thing recycleappbelgium:Collection:Home "Waste@Home" [Zip="2950", Street="xxxx", HouseNumber="xx", refreshInterval=2, Language="nl", daysToCheck=13]

I tried with and without the daysToCheck but the same result

It seems like they have changed the token, again.
Next step is to add the token as a parameter so we can easily copy/paste it.

EDIT: token is added as a parameter and working for me.

Question: I would like to show the status in the item if there is no waste collection found.
Would that be OK?
Something like No token found, empty token, Nothing found, …

Yes, adding a message would be good idea

Compiled it for OH2.5 and OH3.1 and pushed it all to Github. Please check the README for the changes. I played around with the number of days and changing the token, it worked for me. But perhaps I missed some scenario’s.

Current token fetched from the website via developer tools is Crgja3EGWe8jdapyr4EEoMBgZACYYjRRcRpaMQrLDW9HJBvmgkfGQyYqLgeXPavAGvnJqkV87PBB2b8zx43q46sUgzqio4yRZbABhtKeagkVKypTEDjKfPgGycjLyJTtLHYpzwJgp4YmmCuJZN9ZmJY8CGEoFs8MKfdJpU9RjkEVfngmmk2LYD4QzFegLNKUbcCeAdEW

Let see how long it will last :sunglasses:

Thanks, it works now.
Can you please explain how did you get the token?

Yes. Here you go:

  • Open developer tools in your browser, shortkey is F12 in FireFox and Chrome
  • Select the tab Network
  • Refresh the page
  • Look for the file/page with the name access-token and select that line
  • Look for the request headers
  • Look for the header x-secret
  • Copy that value
4 Likes

I found out that the x-secret is stored in the main.js file.

Line 5405.

var n=“Crgja3EGWe8jdapyr4EEoMBgZACYYjRRcRpaMQrLDW9HJBvmgkfGQyYqLgeXPavAGvn
JqkV87PBB2b8zx43q46sUgzqio4yRZbABhtKeagkVKypTEDjKfPgGycjLyJTtLHYpzwJgp4YmmCuJZN9ZmJY8CGEoFs8MKfdJpU9RjkEVfngmmk2LYD4QzFegLNKUbcCeAdEW”

This is the url to find the key.
https://www.recycleapp.be/static/js/main.8bdb8d89.chunk.js

Hi @BeanzBE,

Just found your API and works perfect! Many thanks!
Some suggestions i would make:

  • Can you retract the nearest Recycle park, address, and opening hours?
  • Why not returning the data into a JSON schema? it’s standardized, easier to get the needed info out of it,…

kind regards

Great to hear it helps others :slight_smile:
Regarding your suggestions:

  • I need to check the API
  • It was built for personal use and I just want to show it as a text item. First feedback was to change format a bit. I will see if I can put it in a JSON and put it in another channel.

Hi Lennert,

Thanks to your binding i was able to handle the requests with some http requests and put everything into Rule DSL where I can handle the returned JSON data.

Many thanks

First at all, thank you for the effort!
I’ve just gave it a try. And for the moment, I’m just getting:

2022-02-03 19:20:41.255 [INFO ] [um.internal.RecycleappBelgiumHandler] - Start fetching next waste collection...

Will wait a few days if something new comes in?
Tomorrow is the pickup day over here.

I’ve also noticed that the token will expire right away? Not sure if this is important for the future?

{
  "expiresAt": "2022-02-03T19:25:47.535Z",
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2NDM5MTI4MDcsImV4cCI6MTY0MzkxNjQwNywiYXVkIjoicmVjeWNsZWFwcC5iZSJ9.OmzGVKFpYTM_i6svXvOEb7TroWu-SG5IbAzjUE4P_ao"
  }




Maybe an addon? Today I’m using an own google Calendar where I copy this kind of data in. The end result is an image on my dashboard. I’ve created icons for most possible pickups. It’s done by a rule now, but maybe it can be added as an item state? Would be much easier. :wink:

afval_Re

afval_RePmPa

The job runs every 12 hours by default, just to avoid being flagged as scraper. You can decrease it to 2 hours.
Mine is still showing data so it seems to be working. But if I remember correctly, the very first time nothing is shown. Then you have to wait 12 hours (or less).

I have never played around with images as an item state. It has been over 6 months since I touched this binding. No promises but if I’m getting bored I might play with this.
Just in case, do you mind sharing your icons/images?

For the moment, no updates from the binding.
I’ll try to play later on with postal code. When I enter it on the site, I’m getting a dropdown since several choices for our postal. Maybe it’s not enough for just a postal code?



Here is my latest set of waste icons.
For my garbage pickup calendar, I really only use the ‘rest’ and the ‘all’. In our street, one week is ‘Rest’, and the other week it’s ‘rest-pmd-paper’. The other icons are because I want to start to keep track on all our waste. So I’m building a scale to weight the waste , and inserts these values automaticlly.

afvalAL afvalRE afvalGL afvalPM
afvalGF afvalGR afvalKL afvalPK

Where I live, we have 3 cities for 1 postal code. So that should cover it.
You can always send me your address privately so I can test it. Perhaps there’s still a bug in my binding.

The token is still the same as last year, you can find it higher in this thread. The one you show is the access token the site will give the app to do the communication. We need to save the one marked as x-secret

Nice set of icons. Need to see if I can include that, no promises :wink:

A bit of patience, and the values roll in. :wink:

log/events.log.12:2022-02-04 17:14:38.581 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'afvalOphaling' changed from NULL to Nothing to show...
log/events.log.13:2022-02-05 01:16:43.281 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'afvalOphaling' changed from Nothing to show... to (2022-02-11)Restafval***PMD***Papier-karton

So your binding is working perfectly!




I’ve moved from my current situation, to your binding.
I’ve inserted the 2 main values into an seperate item. So they can be used in fe widgets. This is my end result (so far):

afval

items:

String 		afvalOphaling 		"Volgend ophaling" 			<calendar> 		{channel="recycleappbelgium:Collection:home:NextCollection"}
String 		afvalOphalingImg
DateTime	afvalOphalingDate	"[%1$tA %1$td %1$tB]"

rule:

rule "Converteer afvalophaling"
    when
        Item afvalOphaling changed
    then
        val strAfvalVolgend = afvalOphaling.state.toString.split('\\(2').get(1)
        val strAfvalDatum ="2" + strAfvalVolgend.split('\\)').get(0)
        val afvalType =strAfvalVolgend.split('\\)').get(1)
        afvalOphalingDate.postUpdate(strAfvalDatum)
        if (afvalType == "Restafval") afvalOphalingImg.postUpdate("/static/afvalRE.png")
        if (afvalType == "PMD") afvalOphalingImg.postUpdate("/static/afvalPM.png")
        if (afvalType == "Papier-karton") afvalOphalingImg.postUpdate("/static/afvalPK.png")
        if (afvalType == "Restafval***PMD***Papier-karton") afvalOphalingImg.postUpdate("/static/afvalAL.png")
end

Widget image card:

component: oh-image-card
config:
  item: afvalOphalingImg
  title: = items.afvalOphalingDate.displayState
  action: url
  actionUrl: https://www.recycleapp.be/home

Hi ,

I receive :Could not fetch token from website.
Is their a new token?
Could not find it with the developer tools on the website.
Thanks
Patrick

Hi Pat, I’m not aware that there is a new token. Mine is still working fine.
Token starts with Crgja3EGWe in my configuration. I can send you the token via PM, if you want.

Hi BeanzeBE,

I am also using the same token as in jelmer1 post from march 21 higher up.
The RecycleappBelgium Binding Thing is online, but the channel give me the same error:


I use openHAB 3.3.0 in a docker container on a synology NAS.
I do not see strange loggings execpt one line when restarting the OH3 container
[INFO ] [um.internal.RecycleappBelgiumHandler] - Start fetching next waste collection…

Any idea why i cannot get the data.

Thanks

Patrick

Looking into the code. Could you set debuglevel to debug?
Then some more info is saved. But I also see that I can improve logging on debug level.
Perhaps time to upgrade to OH3.3 and add some extra logging. MIght take some time though…

Hi BeanzBE,

I removed your binding and used the Waste Collection Belgium from the OH 3.3 rule template.
It works fine for the moment.

Thanks

Patrick