Skip to content

Instantly share code, notes, and snippets.

@remotephone
Created April 26, 2020 04:34
Show Gist options
  • Save remotephone/0aa5d6bf6caf84a6ae7b1a8e1db04a10 to your computer and use it in GitHub Desktop.
Save remotephone/0aa5d6bf6caf84a6ae7b1a8e1db04a10 to your computer and use it in GitHub Desktop.
Now, when i push the 4th button on my pifacedigital2, it sends a web request that disables ad blocking for 5 minutes.
# idea from here https://www.reddit.com/r/pihole/comments/81z8jp/temporarily_disable_pihole_using_a_bookmarked_url/
import requests
import pifacedigitalio as p
import time
pd = p.PiFaceDigital()
def main():
auth = 'PWHASH'
while True:
if pd.switches[3].value == 1:
r = requests.get('http://pihole/admin/api.php?disable=300&auth={}'.format(auth)).json()
try:
if r['status'] == 'disabled':
r = list(range(0, 8))
for x in r:
pd.leds[x].turn_on()
time.sleep(0.1)
pd.leds[x].turn_off()
except:
pd.leds[1].turn_on()
pd.leds[1].turn_off()
pd.leds[2].turn_on()
pd.leds[2].turn_off()
pd.leds[3].turn_on()
pd.leds[3].turn_off()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment