Dutch garbage pick-up (AVRI)

For the dutch people, living in the area where AVRI comes to get the garbage, I’ve create a simple rule to show when to get the garbage outside.
It’s done with Ephemeris action.
The XML file is based on my location:

<?xml version="1.0" encoding="UTF-8"?>
<tns:Configuration hierarchy="nl" description="Afval kalender" xmlns:tns="http://www.example.org/Holiday" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/Holiday /Holiday.xsd">
  <tns:Holidays>
    <tns:FixedWeekday which="SECOND" weekday="TUESDAY" month="JANUARY" descriptionPropertiesKey="PLASTIC"/>
    <tns:FixedWeekday which="LAST" weekday="TUESDAY" month="JANUARY" descriptionPropertiesKey="PLASTIC"/>
    <tns:FixedWeekday which="THIRD" weekday="TUESDAY" month="FEBRUARY" descriptionPropertiesKey="PLASTIC"/>
    <tns:FixedWeekday which="SECOND" weekday="TUESDAY" month="MARCH" descriptionPropertiesKey="PLASTIC"/>
    <tns:FixedWeekday which="FIRST" weekday="TUESDAY" month="APRIL" descriptionPropertiesKey="PLASTIC"/>
    <tns:FixedWeekday which="FOURTH" weekday="TUESDAY" month="APRIL" descriptionPropertiesKey="PLASTIC"/>
    <tns:FixedWeekday which="THIRD" weekday="TUESDAY" month="MAY" descriptionPropertiesKey="PLASTIC"/>
    <tns:FixedWeekday which="FIRST" weekday="TUESDAY" month="JUNE" descriptionPropertiesKey="PLASTIC"/>
    <tns:FixedWeekday which="FOURTH" weekday="TUESDAY" month="JUNE" descriptionPropertiesKey="PLASTIC"/>
    <tns:FixedWeekday which="THIRD" weekday="TUESDAY" month="JULY" descriptionPropertiesKey="PLASTIC"/>
    <tns:FixedWeekday which="FIRST" weekday="TUESDAY" month="AUGUST" descriptionPropertiesKey="PLASTIC"/>
    <tns:FixedWeekday which="FOURTH" weekday="TUESDAY" month="AUGUST" descriptionPropertiesKey="PLASTIC"/>
    <tns:FixedWeekday which="THIRD" weekday="TUESDAY" month="SEPTEMBER" descriptionPropertiesKey="PLASTIC"/>
    <tns:FixedWeekday which="SECOND" weekday="TUESDAY" month="OCTOBER" descriptionPropertiesKey="PLASTIC"/>
    <tns:FixedWeekday which="LAST" weekday="TUESDAY" month="OCTOBER" descriptionPropertiesKey="PLASTIC"/>
    <tns:FixedWeekday which="THIRD" weekday="TUESDAY" month="NOVEMBER" descriptionPropertiesKey="PLASTIC"/>
    <tns:FixedWeekday which="SECOND" weekday="TUESDAY" month="DECEMBER" descriptionPropertiesKey="PLASTIC"/>
    <tns:FixedWeekday which="LAST" weekday="TUESDAY" month="DECEMBER" descriptionPropertiesKey="PLASTIC"/>
    <tns:FixedWeekday which="SECOND" weekday="THURSDAY" month="JANUARY" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="FOURTH" weekday="THURSDAY" month="JANUARY" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="FIRST" weekday="THURSDAY" month="FEBRUARY" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="THIRD" weekday="THURSDAY" month="FEBRUARY" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="FIRST" weekday="THURSDAY" month="MARCH" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="THIRD" weekday="THURSDAY" month="MARCH" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="FIRST" weekday="THURSDAY" month="APRIL" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="THIRD" weekday="THURSDAY" month="APRIL" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="FIRST" weekday="THURSDAY" month="MAY" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="THIRD" weekday="THURSDAY" month="MAY" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="LAST" weekday="THURSDAY" month="MAY" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="SECOND" weekday="THURSDAY" month="JUNE" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="FOURTH" weekday="THURSDAY" month="JUNE" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="SECOND" weekday="THURSDAY" month="JULY" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="FOURTH" weekday="THURSDAY" month="JULY" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="FIRST" weekday="THURSDAY" month="AUGUST" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="THIRD" weekday="THURSDAY" month="AUGUST" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="FIRST" weekday="THURSDAY" month="SEPTEMBER" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="THIRD" weekday="THURSDAY" month="SEPTEMBER" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="FIRST" weekday="THURSDAY" month="OCTOBER" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="THIRD" weekday="THURSDAY" month="OCTOBER" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="LAST" weekday="THURSDAY" month="OCTOBER" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="SECOND" weekday="THURSDAY" month="NOVEMBER" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="FOURTH" weekday="THURSDAY" month="NOVEMBER" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="SECOND" weekday="THURSDAY" month="DECEMBER" descriptionPropertiesKey="GFT"/>
    <tns:FixedWeekday which="THIRD" weekday="SATURDAY" month="DECEMBER" descriptionPropertiesKey="GFT"/>
  </tns:Holidays>
</tns:Configuration>

Items:

String		GFT			"Wanneer moet GFT aan de weg? [%s]"			<calendar> (Home, RestoreOnStartup)
String		PLASTIC		"Wanneer moet Plastic aan de weg? [%s]"		<calendar> (Home, RestoreOnStartup)

Rule:

rule "Afval aan de weg"
when
	System started
	or
	Time is midnight
then
	val Gdays = Ephemeris.getDaysUntil("GFT","/etc/openhab2/services/garbage.xml")
	val Pdays = Ephemeris.getDaysUntil("Plastic","/etc/openhab2/services/garbage.xml")
	val Gstring = 
		if (Gdays >1){
			"Over "+Gdays+" dagen"
		}else{
			if (Gdays == 1){
				"Morgen"
			}else {
				"Vandaag"
			}
		}
	val Pstring = 
		if (Pdays >1){
			"Over "+Gdays+" dagen"
		}else{
			if (Pdays == 1){
				"Morgen"
			}else {
				"Vandaag"
			}
		}
	PLASTIC.postUpdate(Pstring)
	GFT.postUpdate(Gstring)
end

You’ve to change the XML file according to your schedule. Use mine as an example. The location of the file is $OHCONFIG/services. You’ve to change it in the rule, based on your system (linux, windows, etc).

1 Like

There is an alternative for getting the info for the garbage pickup. Instead of manual create a schedule, it can be retrieved dynamically from an unofficial API.
With HA there is a a new platform for it:

I would like to help the community to create this function for OH, but I don’t know which approach to use.
Shall I create a binding (never done it before) of shall I use the http-binding and use regex or some kind of CSV transformer to fill a item with the right information.
Or is there another way?

The data I can get looks like this:

GFT;19-12-2020;11-12-2020;27-11-2020;13-11-2020;30-10-2020;16-10-2020;02-10-2020;18-09-2020;04-09-2020;21-08-2020;07-08-2020;24-07-2020;10-07-2020;26-06-2020;12-06-2020;29-05-2020;15-05-2020;01-05-2020;17-04-2020;03-04-2020;20-03-2020;06-03-2020;21-02-2020;07-02-2020;24-01-2020;10-01-2020;
PLASTIC;30-12-2020;09-12-2020;18-11-2020;28-10-2020;07-10-2020;16-09-2020;26-08-2020;05-08-2020;15-07-2020;24-06-2020;03-06-2020;13-05-2020;22-04-2020;01-04-2020;11-03-2020;19-02-2020;29-01-2020;08-01-2020;

What are your suggestions?

1 Like