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:
switch:
- platform: command_line
switches:
pihole_switch:
command_on: !secret pihole_command_on
command_off: !secret pihole_command_off
command_state: !secret pihole_command_state
value_template: "{{ value_json.status == 'enabled' }}"
In secrets.yaml I entered:
pihole_command_on: "curl -X GET 'http://[IP address]/admin/api.php?enable&auth=[token]'"
The reason I use secrets.yaml so I can push my current configuration to Github, so you can profit from it.