PiHole V6 disable blocking

In PiHole V6 the api is changed to a REST api so the examples that can be found on the forum to use the api from V5 are not working anymore with NR.

I made a small example how to use the new api from within NR. For me sometimes you need to disable the PiHole blocking because you want to see some advertisements. That's what this example is about. You can disable blocking for an x amount of time.
With the second half of the example you can read back the blocking status.

Don't forget to change the password in the 2 inject nodes.
In Pihole V6 you can find or create the password under Settings, Webinterface /api. Then press the green basic button in the top right corner to switch to expert.
Press configure app password to create a password.

With this example it should not be difficult to use other api functions that require authentication and uses get or post.

[{"id":"5a7c93e546f768ac","type":"http request","z":"e05bef77a0d32682","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://pi.hole/api/dns/blocking","tls":"e6a0747206f52725","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"sid","valueType":"msg","valueValue":"responseCookies.sid.value"}],"x":910,"y":460,"wires":[["21739583887237d4"]]},{"id":"de1762d74105c86e","type":"function","z":"e05bef77a0d32682","name":"JSON for blocking","func":"\nmsg.payload = {\n    \"blocking\": false,\n    \"timer\":msg.disabletime\n}\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":710,"y":460,"wires":[["5a7c93e546f768ac"]]},{"id":"fd9e6054cf2231da","type":"http request","z":"e05bef77a0d32682","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://pi.hole/api/auth","tls":"e6a0747206f52725","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":490,"y":540,"wires":[["74ddfd8f4b28667d"]]},{"id":"90df7b4d23651043","type":"inject","z":"e05bef77a0d32682","name":"BlockingStatus","props":[{"p":"password","v":"ki53ZSGPpsKlUudCeb8niAVLJYjxaYVr5URUQd8vgvU=","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":120,"y":540,"wires":[["63a5bca3bd866727"]]},{"id":"7bc23abd4b396ec7","type":"debug","z":"e05bef77a0d32682","name":"debug 8","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1240,"y":460,"wires":[]},{"id":"21739583887237d4","type":"json","z":"e05bef77a0d32682","name":"","property":"payload","action":"","pretty":false,"x":1070,"y":460,"wires":[["7bc23abd4b396ec7"]]},{"id":"74ddfd8f4b28667d","type":"http request","z":"e05bef77a0d32682","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://pi.hole/api/dns/blocking","tls":"e6a0747206f52725","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"sid","valueType":"msg","valueValue":"responseCookies.sid.value"}],"x":910,"y":540,"wires":[["94dff76db9688ff9"]]},{"id":"1e19542b8c586c30","type":"debug","z":"e05bef77a0d32682","name":"debug 15","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1240,"y":540,"wires":[]},{"id":"a82dfb57d600b23e","type":"http request","z":"e05bef77a0d32682","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://pi.hole/api/auth","tls":"e6a0747206f52725","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":490,"y":460,"wires":[["de1762d74105c86e"]]},{"id":"94dff76db9688ff9","type":"json","z":"e05bef77a0d32682","name":"","property":"payload","action":"","pretty":false,"x":1070,"y":540,"wires":[["1e19542b8c586c30"]]},{"id":"5ece500cd619236f","type":"function","z":"e05bef77a0d32682","name":"Authn","func":"msg.payload = {\n    \"password\": msg.password\n}\n\nreturn msg;\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":460,"wires":[["a82dfb57d600b23e"]]},{"id":"918f606c918d441f","type":"inject","z":"e05bef77a0d32682","name":"Disable","props":[{"p":"disabletime","v":"900","vt":"num"},{"p":"password","v":"ki53ZSGPpsKlUudCeb8niAVLJYjxaYVr5URUQd8vgvU=","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":150,"y":460,"wires":[["5ece500cd619236f"]]},{"id":"63a5bca3bd866727","type":"function","z":"e05bef77a0d32682","name":"Authn","func":"msg.payload = {\n    \"password\": msg.password\n}\n\nreturn msg;\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":540,"wires":[["fd9e6054cf2231da"]]},{"id":"e6a0747206f52725","type":"tls-config","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":false,"alpnprotocol":""}]
1 Like

That is a link to your pihole, not global docs.

Thanks for pointing me to the error.

1 Like