This is an enhanced version of the Pi-hole Virtual Switch for Hubitat, originally created by Nick Veenstra, with contributions from cuboy29, harriscd, and Jed Brown. This driver allows you to control your Pi-hole instance from Hubitat, enabling on/off toggling, status checks, and automation integration.
Features
Enable or disable Pi-hole via a virtual switch in Hubitat.
Improved code structure, better logging, and added authentication handling.
Why This Version?
With the release of Pi-hole v6, the API structure changed, requiring updates to the original driver. This version ensures compatibility with the latest Pi-hole release while improving maintainability, security, and performance.
Installation
Hubitat Package Manager (Recommended)
Open Hubitat Package Manager in your Hubitat interface.
Choose Install → Search by Keywords.
Search for Pi-hole Virtual Switch.
Click Install and follow the on-screen instructions.
Issue 1: Couldn't get this from HPM. I assume that it just needs time to show up on the search. That turns out to be a good thing, because I needed to modify the code to get it to work for my environment...
Issue 2: This doesn't seem to support alternative ports. My Pi-Holes run on a non-standard port, but port 80 is hard-coded into the driver.
I just submitted a PR on GitHub to create a user-selectable "devicePort" with a default value of 80.
Thanks for the feedback, @Alan_F . I merged your code and also updated credits to include your contribution
I also am having difficulty getting HPM to install the driver...I do see a Unable to Refresh null when I try to match up driver code so will have to trouble shoot with HPM. The local install method with HPM went smoothly so I'm not sure where the hiccup is...will investigate and fix asap.
Thanks again for the quick feedback! Keep em coming !
WoA
I wasn’t able to get it working. Running pihole 6 and since the update I can’t get to pihole on port 80, only 8080, so maybe that’s why. I’m running pihole on a desktop Ubuntu install.
@walksonair - Thanks for updating and posting this. I didn't know the old version existed, but this will be really useful for me going forward. I run dual PiHoles, so I put a switch on my Node Red dashboard (that I use as a LAN home page) that toggles both switches at once. This is something my wife can find and use much more easily when she needs it compared to logging into the PiHoles and disabling them through their UI.
I'm curious how many people are running two PiHoles vs a single one. I may try to modify this to accept two IPs and two ports if I can do that without messing up the interface for people who only use one. Maybe with comma-separated IPs and ports, it could handle N instances and just loop through the list, but not need any new input when entering a single IP and port. EDIT: After looking through the code, I think it's going to be much easier to just use Rule Machine to create another virtual switch that toggles all PiHole switches on and off.
Your welcome. I only have the one Pi-hole and I have it linked to my HomeKit so my family uses their iOS devices to temp disable whenever they need it.
I would create two virtual devices with different IPs and different names and that way you can get them into a Rule Machine algo to keep them synced...just like you said
Not yet. I’m unfortunately at work right now, but I really appreciate you offering this driver. My wife is not a tech person and I haven’t coded anything since grade school. I have a spare Hue dimmer that is set to turn on her PC with button 1, and plan to make button 4 turn off pihole. I had it working in Homebridge until the update killed it.
Yeah the latest API change drove me to update this asap...couldve merged it with the original code but wanted some slight changes so made it as a new repo with HPM support. Still debugging the HPM stuff so manual install is the only way for now...
The only thing on it is pihole, homebridge, home assistant, echo speaks, and an ntp server. I only get by on Linux by googling, but it happened as soon as I updated. My shortcut stopped working and I had to add an extra 80.
I just upgraded my Pi-hole from v5 to v6 and I noticed this in the announcement on the pi-hole project website:
During the upgrade operation, you will be presented with a dialog box asking if you wish to disable lighttpd . Doing so is probably appropriate for most users – unless you are using it to host web pages other than Pi-hole’s, in which case you may choose to keep it enabled. With lighttpd disabled, pihole-FTL will attempt to bind to ports 80 for HTTP and 443 for HTTPS. If there is any conflict on these ports, then it will revert to port 8080 for HTTP.
Could the lighttpd daemon (no longer needed) still be running on port 80 of your Pi?
I installed this because I use pihole. Awesome, thank you!
I am just trying to understand why I would want to turn all of pihole off. My wife was blocked from googleads links last week and complained to me. Before I could implement this switch, she found out that disconnecting from WiFi “fixed” it for her. Then I thought to myself, why turn off all of pihole, even temporarily, for all devices. For her to shop, i would be allowing all that other blocked traffic from 60+ devices.
Is it possible to have a switch disable a rule? Or a group? She wants to shop -> turn on a switch -> only her phone (only device in its own group) is allowed googleads -> switch turns off automatically after 30 minutes.