Page 1 of 1

Python Plugin: PiHole Control

Posted: Tuesday 18 November 2025 2:08
by voyo
hi
I've created new version of Pi-hole plugin for PiHole v6 API, based on Xorfor's original idea. ( viewtopic.php?t=20834 )

**Features:**
- Monitor Pi-hole statistics in real-time
- Control block lists as switches in Domoticz
- Auto-sync with Pi-hole (detects added/removed lists)
- Works with Pi-hole groups for ie. parental controls

**My use case:** Schedule kids' block lists - enable YouTube blocking during homework time, disable in the evening.

**Repo:** https://github.com/voyo/Domoticz_PiHole-Control

Works with Pi-hole v6.x. Tested on v6.1.2 + Domoticz 2024.7.

Re: Python Plugin: PiHole Control

Posted: Wednesday 19 November 2025 13:45
by sloeber70
Hi,

Nice work!!

Re: Python Plugin: PiHole Control

Posted: Wednesday 19 November 2025 15:26
by WouterO
Impressive, especially the blocklist control via timed switches adds functionality to Pihole via Domoticz, originally not available in Pihole itself. I like that!

Re: Python Plugin: PiHole Control

Posted: Wednesday 19 November 2025 21:32
by mark.sellwood
Great work, I have added the plugin & configured, now in Domoticz I get switches for each of Lists & I can Enable / Disable

Is it possible to control the Groups listed on PiHole under Group Management?

Thanks

Re: Python Plugin: PiHole Control

Posted: Thursday 20 November 2025 20:26
by voyo
mark.sellwood wrote: Wednesday 19 November 2025 21:32 Great work, I have added the plugin & configured, now in Domoticz I get switches for each of Lists & I can Enable / Disable

Is it possible to control the Groups listed on PiHole under Group Management?

Thanks
maybe ? what functionality you'd like to achieve with groups , please elaborate ?

Re: Python Plugin: PiHole Control

Posted: Thursday 20 November 2025 21:23
by mark.sellwood
Hi, I'm just looking to control the Groups in the same way as Lists Enable / Disable

Re: Python Plugin: PiHole Control

Posted: Saturday 22 November 2025 0:10
by voyo
Ok, I added group functionality (same as with Lists). TBH Im not sure whether I see this useful for my usecase, not sure if I will be using it.
Beside of this - I found and fixed problem with clearing metadata (comments) when Lists status was changed, and fixed it.
Please test.

Re: Python Plugin: PiHole Control

Posted: Saturday 22 November 2025 21:06
by mark.sellwood
Many thanks for making the change.
I have tested today, the groups show up correctly & the status reflects PiHole & changes when I change a Group in PiHole.

The control from Domoticz does not work, if I issue a switch command I see the below in the log but the status does not change in PiHole.
2025-11-22 20:04:29.181 PiHole: Successfully set group 82 ('Phone') to enabled
2025-11-22 20:04:29.184 PiHole: Group ID 82 ('Group: Phone') set to enabled
Thanks

Re: Python Plugin: PiHole Control

Posted: Sunday 23 November 2025 2:00
by voyo
Wasted 2 hours debugging why group control wasn't working - turns out Pi-hole's API uses group NAME in the URL not ID (like /api/groups/TV instead of /api/groups/3), even though it returns success either way. Classic API inconsistency.

Had to open browser devtools and watch what the actual UI sends because the docs don't mention this anywhere. Fixed in latest commit , thanks God for Claude and LLMs :D
PLease check

Re: Python Plugin: PiHole Control

Posted: Sunday 23 November 2025 9:22
by mark.sellwood
Thanks or the update.
Using the ID would be the best way as I have found an issue using a Groups name

If the Group Name has a space in it switching fails One of my Groups is named "Black List"
2025-11-23 08:21:53.057 Error: PiHole: Error setting group state: URL can't contain control characters. '/api/groups/"Black List"' (found at least ' ')
2025-11-23 08:21:53.057 Error: PiHole: Failed to change state of group ID 74

Re: Python Plugin: PiHole Control

Posted: Monday 24 November 2025 3:04
by voyo
Im afraid this is Pihole fault. It is just not supporting groups with multiple words in name.
Check it yourself - try to add such group using PiHole interface directly.

This is my try (I especially upgraded to latest-greatest pihole version)
Bez tytułu.png
Bez tytułu.png (71.9 KiB) Viewed 184 times

Re: Python Plugin: PiHole Control

Posted: Monday 24 November 2025 3:37
by voyo
Ok, I played some more. It helped when I added group with ' " ' ("test group") .
New fixed code is available, please check :)

Re: Python Plugin: PiHole Control

Posted: Monday 24 November 2025 22:42
by mark.sellwood
Many thanks for the great work, works fine.

Re: Python Plugin: PiHole Control

Posted: Saturday 03 January 2026 21:39
by JayDotR
Big like for your work and time invested to make an old version of the plugin working again (also for me). I permitted myself to make a branch of your code is working when the PiHole is not using http, but https :)

https://github.com/janreimen/Domoticz-PiHole-Control

Re: Python Plugin: PiHole Control

Posted: Saturday 03 January 2026 23:48
by waltervl
JayDotR wrote: Saturday 03 January 2026 21:39 Big like for your work and time invested to make an old version of the plugin working again (also for me). I permitted myself to make a branch of your code is working when the PiHole is not using http, but https :)

https://github.com/janreimen/Domoticz-PiHole-Control
It would be more helpful to the community that you made a PR on the original plugin as then there is just one plugin to look at.

Re: Python Plugin: PiHole Control

Posted: Wednesday 21 January 2026 1:49
by voyo
JayDotR wrote: Saturday 03 January 2026 21:39 Big like for your work and time invested to make an old version of the plugin working again (also for me). I permitted myself to make a branch of your code is working when the PiHole is not using http, but https :)

https://github.com/janreimen/Domoticz-PiHole-Control
This is a bad approach. The plugin shouldn’t add an option to patch chain.pem just to support self-signed certs or your own CA - that’s a hack and will create maintenance problems down the line. If you really want to experiment, you could modify the plugin to ignore self-signed cert issues, but that’s a workaround at best. The proper way is to add the cert system-wide so all applications trust it, keeping things stable and maintainable.
But now its your branch , enjoy ;)
(but please only correct credits, its 'Voyo' not 'YoYo' )

Re: Python Plugin: PiHole Control

Posted: Friday 23 January 2026 20:50
by JayDotR
I will fix your credits, thanks for making me aware of the Typo.

For the http/https point, ignoring the checks on ssl is from the "Secure by design" Scheme a no-go (I am working in IT, so I am perhaps "work-damaged" over the years). My certs and RootCA/SubCA were known systemwide, and as the Raspberry is part of an IT Network, it has to follow the standards of the infra ;)