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