This is my Pi-hole with an ePaper display. There are many like it, but this one is mine.
This script will trigger a periodic refresh of your Inky pHAT display to show some Pi-hole stats. You'll see your device's host name and IP (in case you haven't set a static IP address or need to manually adjust the DNS settings for some of your devices), the last time at which the display was refreshed, as well as some basic Pi-hole info:
- Status: connected or not
- How many clients are currently connected
- Queries in past 24 hours
- How many queries (count and percentage) have been blocked
-
Set up your Pi-hole, I followed adafruit's instructions here.
!! If you're working on a Windows machine, make sure you've set Unix style line endings when creating yourwpa_supplicant.conf
andssh
files !! -
Set up your Inky pHAT, I followed Pimoroni's instructions here.
I found that after following the installation instructions, I was unable to run any of the included examples, nor was I able to run any of my own code due to a numpy dependency error. The solution was found on numpy's troubleshooting page, run:
sudo apt-get install libatlas-base-dev
-
Clone this repo.
-
Create a
.env
file in the root directory of the project and set the following variables:API_TOKEN=<api token from pihole settings> HOSTNAME=<hostname of your pihole raspberrypi> IP_ADDR=<ip address of your pihole>
-
Edit your crontab file to set recurring screen refresh:
sudo crontab -e
add this line:
*/15 6-23 * * * python3 <path to pihole_status_display.py>
which will trigger the script every 15 minutes on the quarter hour between the hours of 6am and 11pm.
- Get and format the update time - date and time at which the script was called.
- Pull some board info - the hostname and IP address of your pi.
- Pull some stats from your Pi-hole API in a struct (dict).
- If your Pi-hole is up and your pi is able to query the API within 5 seconds, return status = "Connected", as well as the number of connected clients, DNS queries made today, total ads blocked today, and percentage of queries blocked.
- If your pi is unable to query the API, return status = "DOWN", and set all the pihole_stats fields to "-----".
- Draw the results on the Inky pHAT screen.