Junker waste collection for Italy [4.0.0.0;4.9.9.9]

This template allows the user to create rules to update the state of specific items with the date of the next scheduled collection of several waste categories, related to the collection performed in Italy.

A user could also check a complete calendar (and perhaps show that embedded in a dashboard) from the webpage

https://differenziata.junkerapp.it/ MUNICIPALITY_NAME/AREA_CODE/calendario

NOTE: To use the above URL and also to use this template, you must know what is your area code and your municipality name’s string on the Junker platform: to get those two values, I suggest to follow those steps:

  • with a browser, go to the Junker Municipality Locator;
  • enter your city’s name inside the text box and select an option from the drop-down menu;
  • select the street and address you want to track with this rule;
  • finally, check out the URL in the address bar of your browser: after the domain (differenziata.junkerapp.it) you will be able to read and take note of the municipality name string and the area code, separated by forward slashes characters (/).

Language: ECMA Script 11

Dependencies:

  • JavaScript Scripting add-on

Configuration

Arguments used inside the template

  • Refresh time: when to schedule the daily run for the rule to check and update the item’s state if necessary
  • Municipality name: string representing the name of the municipality; must be valid on the Junker platform
  • Area code: number representing the area; must be valid on the Junker platform

Selected items are updated by the rule for the following categories of waste:

  • organic
  • paper
  • light
  • general
  • bulky
  • plastic
  • glass
  • napkins
  • grass clippings

NOTE: The categories listed above must all be “linked” to a valid Item which can hold a DateTime value

Changelog

Version 0.2

  • detect and update collection dates for grass clippings
  • larger lookup window to account for bi-weekly collections
  • do not block the rule engine thread while fetching for the calendar update
  • tested on openHAB 4.3.4

Version 0.1

  • initial release
  • hosted the template on GitHub
  • tested on openHAB 4.3.4

Resources

https://raw.githubusercontent.com/Procsiab/openhab-custom/refs/tags/0.2/junkerWaste/junkerWaste.yaml

1 Like

I will add context to how I am developing this: perhaps this can be useful to anyone who wants to contribute or suggest some better styling or logic in the code:

I posted this rule template after reading rlkoshak’s tutorial on the argument, and afterwards digging inside a conceptually similar template that was already developed (Waste Collection Belgium).

To develop the code I reversed the logic of this Home Assistant component, for which I will thank the GitHub user 5ila5, who contributed by adding support for Junker and doing the work of reversing their web app.

I will also add that the component I am referring to implements the logic to scrape the garbage collection schedule for many more countries than Italy.