Skip to content

bartdorlandt/afvalwijzer

Repository files navigation

Afvalwijzer library

PyPi Status Build Status Coverage Status Wheel Status Python versions

This library is meant to interface with mijnafvalwijzer.

It is meant as a workaround for the afvalwijzer app (used in the Netherlands) to be notified when to place the bin at the road. Since this app delivers a poor functionality for notifications, and I needed a small project, I created this.

Installation

pip install afvalwijzer

Uninstallation

pip uninstall afvalwijzer

Usage

>>> from Afvalwijzer import Afvalwijzer
>>> zipcode = '3564KV'
>>> number = '13'
>>> garbage = Afvalwijzer(zipcode, number)

>>> garbage.pickupdate
'Vandaag'

>>> garbage.wastetype
'Groente-, Fruit- en Tuinafval'

>>> garbage.garbage
('Vandaag', 'Groente-, Fruit- en Tuinafval')

>>> garbage.pickupdates
['dinsdag 02 januari', 'dinsdag 02 januari']

>>> garbage.wastetypes
['Groente-, Fruit- en Tuinafval', 'Kerstbomen']

The following function only returns true if the pickup date is the same as today.

>>> garbage.notify
True

Below is shown how I use it to get notified using pushbullet.

from Afvalwijzer import Afvalwijzer
from pushbullet import Pushbullet


def notification(device=None):
    pb = Pushbullet(pushbulletapi)
    try:
        mydevice = pb.get_device(device)
    except:
        mydevice = None
    push = pb.push_note(
        "Container: {}".format(wastetype),
        "Container: {}\nDate: {}".format(wastetype, pickupdate),
        device=mydevice)


zipcode = '3564KV'
number = 13
pushbulletapi = 'pushbullet_api_key'
pushbulletdevice = 'LGE Nexus 5X'

garbage = Afvalwijzer(zipcode, number)
pickupdate, wastetype = garbage.garbage
notify = garbage.notify
if notify and pushbulletapi:
    notification(pushbulletdevice)

Cron job

This script can now be set up as a cronjob on your server or alike.

0 6 * * * cd /path/to/script/notify_garbage.py > /dev/null 2>&1

Caveat

  • Output is provided in Dutch due to the main website. There is a button for English, but I haven't got it working (yet).

Contributors are most welcome

  • I'm still learning how to work with it all. Therefore feedback, advice, pull request etc. are most welcome.