host: Change it to the IP address of your Pi-hole.
ssl/verify_ssl: If you run your Pi-hole with ssl, you can enable it here.
api_key: The API key from Pi-hole. Found on your Pi-hole dashboard under Settings -> API/Web interface -> Show API token. Best is to keep secrets and keys into a separate secrets.yaml file.
Pi-hole sensor
The current Pi-hole integration does not reflect wether the Pi-hole is enabled or not. Weāll make a command line sensor that will reflect the status of the Pi-hole. Put this block in the sensor part of your configuration as shown:
friendly_name: The name that will show up in the frontend.
value_template: Retrieves the the state of the sensor as enabled/disabled value of the switch. Note that the name from our sensor Pi-hole is translated in the backend to pihole.
turn_on: the service pi_hole.enable will be used to enable the Pi-hole when turning on the switch
turn_off: the service pi_hole.disable will be used to disable the Pi-hole when turning off the switch. In duration you can set how long the Pi-hole needs to remain disabled. Currently itās set to 12h.
Front-end setup
Use any card that has switch support to reflect the switch in your frontend. With above settings your switch is known as entity switch.pi_hole_switch.
There is an icon available as mdi:pi-hole.
Remark: Depending on your sensor scan_interval it is possible that your switch will flick back after changing. Just let it be, after the max period of scan_interval, the switch will set itself to the real value.
Ehmā¦ not working for meā¦ ? Did exactly what you wroteā¦ I can also see the status of my pihole with the http command (enabled/disbled) but nothing happens on the button and the piā¦
Which translates to name pihole. Home Assistant removes capitalization and dashes I assume.
I noted the following, but maybe I should make it more prominent:
value_template: Retrieves the the state of the sensor as enabled/disabled value of the switch. Note that the name from our sensor Pi-hole is translated in the backend to pihole .
In your case:
Try changing the value template in the switch from sensor.pihole to sensor.pihole_100 or sensor.pihole_101. To verify the correct name, you can check your entities in āDeveloper Toolsā ā āStatesā.
Also check if you have the service pi_hole available.
You can use the one from the comment I put just below the post
Itās not a button but a switch. Maybe there are some custom cards that can help you out to combine an entity card and button card.
Given the addonās use of ingress, I canāt figure out what URL to give it. Iāve tried variations on the theme below, though nothingās worked yet:
The problem of template is an error in this line:
value_template: ā{{ is_state(āsensor.piholeā, āenabledā) }}ā
you need change for this:
value_template: ā{{ is_state(āsensor.pi_holeā, āenabledā) }}ā
I donāt think that will workā¦ The sensor is clearly listed as sensor.pihole in the entities tab (and it works likewise on my setup). But of course I might have overlooked something (home assistant changes all the time) so please elaborate why to use the underscore
Is it possible to have something that can be used in an automation to switch between pi_hole.enable and pi_hole.disable?
I want to use a flic button to switch Pi-Hole on/off and I want to use only eg. short press for on and then short press for off.
If I am using eg. a device light bulb I can choose the action switch between on/off (I donāt know the english wording, in German it is āSchalte ā¦ umā). But there is no device Pi-Hole.
Maybe not the correct topic,
But i was not able to disable pi-hole from home assistant out.
Turns out the API key was missing, (but re-configuring the integration does not ask for a API key)
Removed the integration, restarted Home assistant, then re-added the integration, now it asked for a API key in the second page/tab.
So now i can disable pi-hole from home assistant out.
Great integration! Solves a key need to make it easy to disable/enable a pi-hole (or multiple, even better).
I got it working by adding the provided snippet to my configuration.yaml, but only after trying the web GUI integration add screen; this doesnāt seem to have a space for the API token?
Is this still being worked on?
Also, it doesnāt seem to refresh the status of the pi-hole. If I call pi_hole.disable with a time of 00:03 (for 3 minutes) the pi-hole behaves correctly - it disables, then 3 minutes later it enables. The switch state in HA initially updates to āoffā, but doesnāt refresh back to āonā in a timely fashion (takes a few minutes after that at least). Is there any way to improve the polling?