I struggled a bit to get a correct Pi-Hole switch in Home Assistant. I finally found something that worked. It is not completely what I wanted, but at least it is working AND I can explain to my wife how it works.
I used the command_line platform to create a switch that is based on the output of a couple of commands:
In secrets.yaml I entered:
The reason I use secrets.yaml so I can push my current configuration to Github, so you can profit from it.