Temporarily disable PiHole blocking with Apple shortcut
You may want to disable your PiHole ad blocking momentarily to open a link. Wouldn't it be great to disable ad blocking from your Apple Watch or iPhone?
The Problem:
Its a typical situation where you may want to disable your PiHole ad blocking momentarily to open a link. To increase the wife appreciation factor, this needs to be a task that can be accomplished as easily as possible. Don't get me wrong, the PiHole UI is great and this task can be accomplished there pretty easily, but wouldn't it be great to trigger this action from my Apple Watch or iPhone?
The Solution:
Build an Apple shortcut that has options to disable ad blocking for 10 seconds, 30 seconds and 5 minutes that can be ran on an Apple Watch, iPad, iPhone, etc.
Assumptions:
This solution is intended to be used with PiHole >= 6. IT IS NOT compatible with PiHole 5.
- You have an
app password
which is used as yourAPI KEY
Tbe app password
can be created a the following route: /admin/settings/api
The Shortcut
Global Variables:
We need to set some variables for our shortcut to use
Select Disable Time:
Allow the user to select how long to disable ad blocking
Authenticate:
Authenticate and get a session ID (sid) to be used with our API requests
Store Authentication Session ID:
By clicking the Set variable
we need to specify the key that contains our session ID. in this case we set the Get Value for Key
to session.id
Disable Ad Blocking:
Make the POST
request to the API to disable ad blocking
Delete Authentication Session:
We need to clean up after ourselves each time because by default PiHole is set up to allow 10 sessions. You could increase this number but it seems more responsible to delete our session ID when we are done.