BlackBin is a script that automates the process of checking the next Black Bin collection day on the Belfast City Hall for a specific address and adds it to your Outlook Calendar. This helps you stay organized and reminds you when to put out your bin for collection.
- Docker
- Docker Compose
- Clone this repository:
git clone https://github.com/loglux/BlackBinCollection.git
- Navigate to the project directory:
cd BlackBinCollection
- Configure environment variables:
- Create a
.env
file in the root of the project directory. - Add the following variables to the
.env
file, replacing placeholder values with your actual details:For example:CLIENT_ID=your_client_id CLIENT_SECRET=your_client_secret HOUSE_ADDRESS=House_Number Street Name, Belfast, POST_CODE CALENDAR_NAME=your_calendar_name
CLIENT_ID=12345678-abcd-1234-ef00-123456789abc CLIENT_SECRET=abcd1234Efgh5678Ijkl HOUSE_ADDRESS=3 Anna Street, Belfast, BT1 1AA CALENDAR_NAME=MyCalendar
- Ensure your
.env
file is correctly formatted and saved.
- Create a
- Install dependencies:
pip install -r requirements.txt
- Run the script:
python blackbin.py
If you prefer to set up the Docker containers manually, follow these steps:
- Build the Selenium server container:
- Open a terminal and navigate to the project directory.
- Run the following command:
docker run -d --name selenium-server -p 4444:4444 selenium/standalone-chrome
- Build the BlackBin container:
- Run the following command:
docker build -t blackbin .
- Run the following command:
- Run the BlackBin container:
- Run the following command:
docker run -d --name blackbin --network selenium-network blackbin
- Run the following command:
- Adjust the cron task in the 'Dockerfile' to specify your desired schedule. The default cron task runs the script at 7:30 PM on Mondays, Fridays, and Saturdays.
To automate the Docker container setup process, you can use the docker_start.sh
file included in the project. Follow these steps:
- Open a terminal and navigate to the project directory.
- Update the shebang in the docker_start.sh script:
- Open the docker_start.sh file.
- Update the shebang (#!/opt/bin/sh) at the beginning of the script if necessary, depending on your system (#!/opt/bin/sh is desinged for ASUStor NAS).
- Save the changes.
- Run the following command:
sudo chmod +x docker_start.sh
(only needed for the first time). - Execute the
docker_start.sh
script:- Run the following command:
sudo ./docker_start.sh
- Run the following command:
The script will create a network called selenium-network
and start the Selenium server container (selenium-server
) and the BlackBin container (blackbin
).
The script will prompt you to enter your address in the format: House_Number Street Name (e.g., 123 Main St), Belfast, POST_CODE
. It will then retrieve the next Black Bin collection day for that address from the Belfast City Hall website (https://online.belfastcity.gov.uk/find-bin-collection-day/Default.aspx) and add it to your Outlook Calendar.
Once the setup is complete, the Black Bin collection day reminder will be automatically scheduled to run according to the specified cron task. It will check the next collection day for your address in Belfast and add it to your Outlook Calendar.
You can view the added event in your Outlook Calendar to stay informed about the upcoming Black Bin collection day.
- Open a terminal and navigate to the project directory.
- Run the script inside the BlackBin container:
- Run the following command:
sudo docker exec -it blackbin bash -c "python blackbin.py"
- Run the following command:
Please note that the script uses the Selenium library to scrape information from the Belfast City Hall website, so make sure you have a stable internet connection during the script's execution.
If you encounter any issues or have any questions, please feel free to open an issue in this repository.
Happy bin collection day reminders!
To use the BlackBin script with your Microsoft 365 account, you need to obtain an access token. Follow these steps to generate the token file:
- Go to the Microsoft 365 App Registration Portal and sign in with your Microsoft 365 account.
- Register a new application and note down the client ID and client secret.
- Grant the necessary API permissions to the application:
User.Read
: Read user profileoffline_access
: Access user data even when the user is not present
- Save the changes and generate a new access token using the client ID an