Preamble: Since the original topic with @cuboy29 's great port was closed, the polling has broken with the latest Pi-Hole updates, and a bunch of modifications have happened since then, I'm re-starting a thread for this great Pi-Hole integration for others to contribute to and discuss.
PI-HOLE ON/OFF TOGGLE DRIVER
What is this?
A custom Driver for HE that allows you to quickly disable pi-hole ad blocking from the HE dashboard, other devices, or you can even use RM to setup rules of when to enable/disable ads/porn blocking.
Features
Polls the Pi-Hole status every 15 minutes
Allows you to define in minutes how long the Pi-Hole blocking stays off including setting to indefinite.
Instead of Pi-Hole, I use the pfSense add-in pfBlockerNG. Is there any chance this could be expanded to also control pfBlockerNG? Or might there already exist a separate integration that talks to pfBlockerNG?
I just did a quick search and it doesn't look like pfBlockerNG exposes any API calls to quickly enable/disable. If you find out it does, it would be easy to repurpose this to do the same.
yes, the turning on does nothing as well. i did manually turn off in pi-hole and it did reflect as off in HE
[dev:1329](http://{HE IP}/logs#dev1329)2023-01-11 11:46:07.792 am [error](http://{HE IP}/device/edit/1329)java.lang.NullPointerException: Cannot get property 'FTLnotrunning' on null object on line 109 (method parse)
[dev:1329](http://{HE IP}/logs#dev1329)2023-01-11 11:46:07.787 am [debug](http://{HE IP}/device/edit/1329)Received 'null'
[dev:1329](http://{HE IP}/logs#dev1329)2023-01-11 11:46:07.782 am [debug](http://{HE IP}/device/edit/1329)Parsing 'hubitat.device.HubResponse@1335f09'
[dev:1329](http://{HE IP}/logs#dev1329)2023-01-11 11:45:56.854 am [error](http://{HE IP}/device/edit/1329)java.lang.NullPointerException: Cannot get property 'FTLnotrunning' on null object on line 109 (method parse)
[dev:1329](http://{HE IP}/logs#dev1329)2023-01-11 11:45:56.849 am [debug](http://{HE IP}/device/edit/1329)Received 'null'
[dev:1329](http://{HE IP}/logs#dev1329)2023-01-11 11:45:56.843 am [debug](http://{HE IP}/device/edit/1329)Parsing 'hubitat.device.HubResponse@1ec0cc1'
I do have my firewall set up for access from my HE to Pi-Hole. I do see the "combined" details on HE with my Queries, Blocked, and Clients, so not sure why it's not properly pulling the status. I'll have to take a look more when I get out of work
Super weird, as a refresh is the exact thing as a "poll". The code literately calls poll.
That sounds to me like a rights issue. Are you sure you don't need an Auth Key? Or if not, can you check that you removed the auth key item from line 149 def path = getApiPath() + "?" + toggle + "&auth=" + apiToken
that was it! i removed "+ apiToken" from lines 88 and 149 and it can now control it. i wonder what apiToken was providing since I had it blank.
to make this work for me, the updates i did:
33: input name: "apiToken", type: "text", title: "API token", required: false
88: def path = getApiPath() + "?summaryRaw" + "&auth="
149: def path = getApiPath() + "?" + toggle + "&auth="
EDIT:
just updated the code to see what apiToken was giving and it is "null". i wonder if having an if statement in the script to say "if apiToken = null THEN apiToken = "" " would suffice
EDIT 2:
played with it a bit more, made the following changes and it still works: