Pi-Hole (ad blocking DNS server) Controller
Re: Pi-Hole (ad blocking DNS server) Controller
Same here, but I read the release not of PiHole and I saw they changed same thing APIs related; I have to have a better look at
-
sumocomputers
- Posts: 268
- Joined: Mon Jun 23, 2008 10:46 pm
-
madscientist
- Posts: 122
- Joined: Fri Jan 05, 2007 10:13 pm
- Location: Ontario, Canada
Re: Pi-Hole (ad blocking DNS server) Controller
I am also getting this error with the current Pi-Hole controller release:
Has a solution to this problem been identified yet?
The plug-in still works though. I can turn the ad blocker on and off from Indigo. But my Indigo logs are getting inundated with these error messages.Pi Hole DNS Controller Error Error in plugin execution runConcurrentThread:
File "plugin.py", line 164, in runConcurrentThread
File "plugin.py", line 141, in udpateStatus
type: local variable 'response' referenced before assignment
Pi Hole DNS Controller Error plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)
Has a solution to this problem been identified yet?
-
sumocomputers
- Posts: 268
- Joined: Mon Jun 23, 2008 10:46 pm
Python Scripts to Disable or Enable PiHole 6 Blocking
Since PiHole 6 updates, the Indigo PiHole plugin no longer works. For me there were 2 issues:
1. PiHole now requires getting an Authentication "sid" before making changes
2. When upgrading PiHole from 5 to 6, the port changed from 80 to 8080
I came up with 2 Python scripts (one to disable blocking and one to enable), which I then use with a Virtual ON/OFF device and Action Groups. I then publish the Virtual device with HomeKitLink Siri so I can just command PiHole on or off as needed with a voice command.
I know the scripts are a little hacky, but they work. Note that I have not turned on https, 2FA, or app password.
First there were 2 things I needed to do in the PiHole config:
1. Change the webserver.port value (see screenshot)
Settings > All Settings > Toggle Expert in upper right > Webserver and API > webserver.port > change from 8080 to 80
2. Change the timeout for webserver.api.max_sessions (see screenshot)
Settings > All Settings > Toggle Expert in upper right > Webserver and API > webserver.api.max_sessions > change from 16 a higher number (I used 1024)
I know there is also the ability to disable PiHole for a period of time rather than indefinitely as I did, and tons of other things you can control. Here is some API documentation:
https://docs.pi-hole.net/api/
http://pi.hole/api/docs/
Base Script Example for Disabling Blocking
1. PiHole now requires getting an Authentication "sid" before making changes
2. When upgrading PiHole from 5 to 6, the port changed from 80 to 8080
I came up with 2 Python scripts (one to disable blocking and one to enable), which I then use with a Virtual ON/OFF device and Action Groups. I then publish the Virtual device with HomeKitLink Siri so I can just command PiHole on or off as needed with a voice command.
I know the scripts are a little hacky, but they work. Note that I have not turned on https, 2FA, or app password.
First there were 2 things I needed to do in the PiHole config:
1. Change the webserver.port value (see screenshot)
Settings > All Settings > Toggle Expert in upper right > Webserver and API > webserver.port > change from 8080 to 80
2. Change the timeout for webserver.api.max_sessions (see screenshot)
Settings > All Settings > Toggle Expert in upper right > Webserver and API > webserver.api.max_sessions > change from 16 a higher number (I used 1024)
I know there is also the ability to disable PiHole for a period of time rather than indefinitely as I did, and tons of other things you can control. Here is some API documentation:
https://docs.pi-hole.net/api/
http://pi.hole/api/docs/
Base Script Example for Disabling Blocking
Code: Select all
import requests
# URL for the Authorization POST request (using local IP in this example)
url = "https://192.168.2.15/api/auth"
# Data to be sent in the POST request ()
data = {"password": "YourActualPassword"}
# Send the POST request
response = requests.post(url, json=data, verify=False)
# Assuming the response is in JSON format and sid is a key in the response
response_data = response.json() # Convert the response to JSON
# Retrieve the value for 'sid' from the response
sid = response_data['session']['sid'] # Get the value of 'sid' from the JSON response
# URL for the Blocking POST request (using local IP + sid in this example)
url = "https://192.168.2.15/api/dns/blocking?sid="+sid
# Data to be sent in the POST request (using False to turn off Blocking in this example)
data = {"blocking": False}
# Send the POST request
response = requests.post(url, json=data, verify=False)