Waste Collection Belgium [4.0.0.0;4.9.9.9]

recycelapp

A rule created by this rule template will query the recycleapp.be website once per day for the waste collection calendar on a specific address in Belgium. It will then update a number of items by fraction for the next collection date of that specific fraction.

The rule template combines well with the Garbage Collection UI widget by @DrRSatzteil.

Language: javascript

Dependencies

  • JavaScript Scripting Add-on installed.

Configuration

The rule has a number of parameters:

  • Time: time of day to trigger the rule, defaults to midnight
  • Street: street name for collection
  • Street number: street number for collection
  • Zip code: zip code for collection
  • Days: number of days to look ahead, optional parameter, default 60

The rule will update one or more DateTime items with the next collection date for the specific fraction. These items are optional. You only need to create items for, and configure the ones, you are interested in.

  • Residual Waste Item
  • PMD Item
  • GFT Item
  • Paper and Cardboard Item
  • Textile Item
  • Pruning Wood Item
  • Glass Item
  • Bulky Waste Item

Note that the above 8 fractions are the ones configured in the rule. The collection of fractions may vary by region. E.g. pruning wood would return the deadline for a pruning woord collection appointment in some places. Not all fractions are collected in all regions.
Also, the strings used in the API response to describe certain (the same) fractions vary by region. Therefore, if one of your fractions is not recognized, it may require adding alternative detection strings to the rule. If you notice this, let me know and the template rule will be completed.
If you have other fractions, you can manually add them to the created rule. If you communicate back, the template will be adjusted.

The rule template will by default log success and failure. The logging level can be increased to DEBUG or TRACE for more detailed information. Use following command in the openHAB console for DEBUG level:
log:set DEBUG org.openhab.automation.openhab-js.wastebelgium

Suggestions

For a nice representation of the next waste collection, combine this rule template with the Garbage Collection UI widget by @DrRSatzteil.

If you use sitemaps, you can easily render a line in the UI when the collection is in the next days. Here is an example of such a configuration:

		Text item=ResidualWaste label="Residual waste [%1$tA]" icon="error" visibility=[ResidualWaste > -172800]
		Text item=PMD label="PMD [%1$tA]" icon="error" visibility=[PMD > -172800]
		Text item=Paper label="Paper and cardboard [%1$tA]" icon="error" visibility=[Paper > -172800]

A line will only render for a collection within the next 48 hours.

Changelog

This rule template is heavily inspired by the work of @BeanzBE, who developed a binding for the same purpose, not currently part of the openHAB distribution. Many thanks for that. Rather than using the binding as a dependency, I opted to do the required http GET calls directly from the rule.

Version 2.4

  • Adjust to breaking change in JavaScript Scripting Add-on
  • Change URL to current URL used on website

Version 2.3

  • Update secret key

Version 2.2

  • Added “kerstboom” matching

Version 2.1

  • Added “snoeihout” and “grofvuil” matching

Version 2.0

  • Adapted older version of rule template (developed for ECMAScript 5.1) to ECMAScript 2022+ (ES6), for use with JavaScript Scripting Add-on and OH4.0.

Version 1.x

  • Version developed for ECMAScript 5.1 (Nashorn), available here.

Resources

See the original forum discussion with reference to the work of @BeanzBE.

https://raw.githubusercontent.com/mherwege/openhab-rule-templates/main/wasteBelgium/wasteBelgium-ES6.yaml

2 Likes

Hello,

thanks for the nice script. Is there a way you could add to the script the “Next date of Waste Collection” and the “next type of Waste Collection”? We can use this then easily in Items and Rules …

Many thanks!

Joris De Waele

I’m not really sure what to do with the .yaml file found under “Resources”. If I put it in my conf\rules folder, the rule doesn’t show up under rules in the MainUI.

It’s not a widget either, because the semicolon in the uid isn’t allowed for widgets…

Thanks in advance for your guidance! :slight_smile:

In your OH installation, go to the add-on store, under automations. You will find it is one of the rule templates there. Once installed, you an create a new rule drom the rules menu, using this template. When creating the rule, it will ask for the necessary parameters. That’s it.

I see! Thanks :slight_smile:

I noticed today (too late unfortunately), that “Kerstboom” is also an entry in Pulle (2243, deelgemeente van Zandhoven). Is that something that is extractable from the API as well?

I’ve tried looking around for this API, but this is out of my league…

It should be, but is currently not matched. Rather than create a separate category for it, is it OK to make it show up as a ‘snoeihout’ entry?

I don’t think you need anything extra to do that. Here is an example of a Blockly rule I use:

Notice I defined a group Afval, type DateTime with aggregation function Earliest. That will give you the next date for collection.

I suppose that’s a solution. :slight_smile:

Did the api key changes again ? i am getting strange errors after the rules fired

[ERROR] [enhab.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

Yes, it has.

The templates have been updates. You can update the X_SECRET in an existing rule, replacing it with:

var X_SECRET = "Op2tDi2pBmh1wzeC5TaN2U3knZan7ATcfOQgxh4vqC0mDKmnPP2qzoQusmInpglfIkxx8SZrasBqi5zgMSvyHggK9j6xCQNQ8xwPFY2o03GCcQfcXVOyKsvGWLze7iwcfcgk2Ujpl0dmrt3hSJMCDqzAlvTrsvAEiaSzC9hKRwhijQAFHuFIhJssnHtDSB76vnFQeTCCvwVB27DjSVpDmq8fWQKEmjEncdLqIsRnfxLcOjGIVwX5V0LBntVbeiBvcjyKF2nQ08rIxqHHGXNJ6SbnAmTgsPTg7k6Ejqa7dVfTmGtEPdftezDbuEc8DdK66KDecqnxwOOPSJIN0zaJ6k2Ye2tgMSxxf16gxAmaOUqHS0i7dtG5PgPSINti3qlDdw6DTKEPni7X0rxM";
2 Likes