Siri Shortcut to Disable Pi-hole

3 minute read

Pi-hole is great at blocking ads and protecting you on the internet. However, you occasionally may need to disable it for a few minutes so you can click on that sketchy link at the top of your Google search. In this quick post, I will walk you through how to set up a Siri Shortcut button on your iPhone to temporarily disable PiHole.

First of all, we will need to snag an API key from our Pi-hole instance. To generate an API key you will need to have a password set up on your Pi-hole instance. If you have not done this yet, or you forgot your password, you can reset it with the following console command: pihole -a -p. To generate the API key, log in to the admin page http://pi.hole/admin and navigate to the Settings menu on the left-hand side. Here, go to the API/Web interface tab and then click on the Show API token button in the bottom-left of the pane. Confirm a security prompt and then you will be shown your API token. Save this off somewhere or keep it open as you will need to input this on your phone shortly.

profiles-json

Next, let’s switch over to our iPhone and open up the Shortcuts app. Tap the blue + icon in the top right-hand corner. This will bring you to the New Shortcut screen, here, tap on the Add Action button.

profiles-json

In the search bar at the top of the screen type ‘url’ and then select the URL action from the list below.

profiles-json

Tap on the blue + icon just below the URL action to add another action.

profiles-json

Type ‘Get contents’ in the search bar at the top and then select the Get Contents of URL action to add it to your shortcut.

profiles-json

Use the + icon to add one more action. This time type ‘Notification’ in the search bar at the top and then select the Show Notification action to add it to your shortcut.

profiles-json

Tap on the URL action and enter the following: http://PIHOLE_URL_HERE/admin/api.php?disable=300&auth=API_KEY_HERE. You will need to adjust this to match the URL for your Pi-hole instance and then add your API key at the end. The number following the disable= key is the number of seconds that your Pi-hole will be turned off for. For example: http://192.168.1.42:80/admin/api.php?disable=300&auth=3A43A66AF8685D3B155886994875C.

profiles-json

Next, tap the Notifications action and replace the default “Hello World” text with the Contents of URL variable.

profiles-json

Tap on the Contents of URL variable you just added and tap where it says as File >. Scroll down and choose Text as the type instead and then verify there is a checkmark next to the default of Text as the return.

profiles-json

Once you have finished the above steps, your shortcut should look similar to the screen shot below.

profiles-json

At this point feel free to tap on the button in the top right-hand corner to enter the Details screen. Here you can rename your shortcut and change the icon that will be displayed for it.

profiles-json

Now that our shortcut is complete, let’s test it out! You can use your shortcut from the Shortcuts app or the widget on your home screen if you have enabled it.

profiles-json

If it was successful, you should see {"status":"disabled"} returned in a notification.

profiles-json

If you wanted to play around with the shortcut further, you could add options for different lengths of time to disable your Pi-hole.

Leave a comment