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 (ECMAScript 5.1 Nashorn)
A version for OH 4.0 for the JavaScript Scripting Add-on (ECMAScript 2022+ ES6) is available here.
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.model.script.mherwege.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 1.11
- Update secret key
Version 1.10
- Added “kerstboom” matching
Version 1.9
- Added “snoeihout” and “grofvuil” matching
Version 1.8
- Added “restafval” matching
- Fixed ZonedDateTime.now() call
Version 1.7
- Added “omb” and “organiques” for French language matching
Version 1.6
- Updated api url
Version 1.5
- Updated access token
Version 1.4
- Fix glass fraction quotes
Version 1.3
- Add glass fraction
- Improved match strings for Herenthout
Version 1.2
- Make rule work for streetnames with spaces
Version 1.1
- Fix exception day collections
Version 1.0
- implemented retry functionality when http request fails
Version 0.4
- changed capitalization of header field, should not matter but seems to make a difference in stability
Version 0.3
- added bulky waste
- add alternative GFT detection string
Version 0.2
- filtered non collection events
- captured different collection name for residual waste (huisvuil)
Version 0.1
- initial release
Resources
See the original forum discussion with reference to the work of @BeanzBE.