Dutch garbage pick-up (AVRI)

Tags: #<Tag:0x00007fc2023e11a8> #<Tag:0x00007fc2023e10b8>

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