Pi-Hole switch

Cool. Thanks! Just one thing: the one doesn’t get the status for free… only the switch.

Hi,

meanwhile according to official integration documentation a service for disabling Pi-Hole for a specified time is implemented:

Can someone guide me how to implement it using the “input_select” from Pi-Hole switch ?

I have:

  1. the “input_select” helper in configuration.yaml
  2. the following automation:
- id: '1605967593588'
  alias: Pi-Hole_disable temporary
  trigger:
  - platform: state
    entity_id: input_select.pihole_time
  action:
  - service: pi_hole.disable
    data:
      duration: states.input_select.pihole_time.state
#      duration: 30

The automation gets triggered when selecting an item from the input_selection BUT Pi-Hole won´t be disabled at all. Where´s the error?

Update: I managed to get it work by NOT using the service “pi_hole.disable” but instead using the “shell_command”.

What is the correct syntax for replacing “yourauth” by the “pi_hole_api_key” stored in secrets.yaml?

  pihole_enable: curl -X GET 'http://yourpiholeip/admin/api.php?enable&auth=yourauth'

Using

http://yourpiholeip/admin/api.php?enable&auth={!secret pi_hole_api_key}'

doesn´t work unfortunately :frowning:

Suddenly the sensor stopped working while the sensor configuration has not been touched:

sensor:
  platform: command_line
  name: PiHole Status
  command: curl -X GET 'http://yourpiholeip/admin/api.php?status'
  value_template: >
    {{ value_json.status }}

Error: “entity not available: sensor.pi_hole_status”

I only changed other sections below that sensor definition in the configuration.yaml.

Any ideas how to fix this?

@e-raser I am confused as to why you don’t just use the built in integration? The native integration offers a ton of sensors…

And yes these numbers are all accurate for one day in my network…

I do BUT the official integration unfortunately lacks two things:

  1. The switch does not accurately represent the actual Pi-hole status: when Pi-hole is being disabled (e. g. using the Pi.hole site itself) the switch does not reflect that or at least not in a proper time. For this the additional sensor is great.
  2. Very important to me: it does not provide an option to disable Pi-hole for a specified range of time (e. g. 1/5/15 minutes etc.).

Both requirements are (were) satisfied by adding parts of the manual integration.

Update: found the error, will fix it in the evening and I‘m pretty sure that sensor will be back and working.

But as we’re talking: would there be the possibility to have my two pain points/missing features being integrated in the official Pi-Hole integration? Who to talk to, where to send my feature requests?

I’d prefer that as all that additional manual stuff has the potential to break (as I can see now already).

You can solve this with an automation and an input_number. Use the input number to set how long you want it to be turned off and then in your automation turn the seitch off, add a delay taking the value from the input_number and then turn it on again after this delay.

I’m not sure what you want here. I click the toggle for the switch and it goes off as fast as a light would. In my setup I see virtually no lag. I am running Pi-Hole in its own VM on a separate system and using the built in integration with a manual config to add the API token.

1 Like

That’s basically what I did with the input_select from Pi-Hole switch.

Oh it works great when you ONLY use Home Assistant to disable/enable Pi-Hole. What happens with your switch when you disable Pi-Hole using the Pi.hole web interface? There we go.

I see what you mean. To frame this a little differently… Are you saying the Integration acts like its One way from Home Assistant -> Pi-hole for the switch in Home Assistant, This functions pretty well and with a uniform outcome. However the switch in Home assistant doesn’t update correctly when a change is made in the Pi-hole instance to enable or disable leaving Home Assistant switch in a false state?

If this is the case I wonder how we are collecting the enabled/disable state of the pi-hole and if this is actually broken or not completely deployed. I know last year there was a lot of hype for AdGuard and pi-hole was being less thought of…

Hello, not sure if this is related to what @e-raser reports, but the switch remain “Off” for a much longer period than the set timer.
When button is pressed, it disables PiHole for the set duration, and enables it correctly, however the switch remains in “Off” state when PiHole is enabled, eventually it goes back to on, it takes around 5min for the switch to go back to “On”.
I also tried to disable blocking on PiHole web interface, and after around 5min the button in HA changed to “Off”, so it is working for me, but very slow.

type: button
name: PiHole Blocking is
show_state: true
entity: switch.pi_hole
icon_height: 50px
tap_action:
  action: call-service
  service: pi_hole.disable
  service_data:
    entity_id: all
    duration: '00:00:10'

Guessing it has to do with the pulling time HA has on the PiHole integration?

That’s right. Maybe the seitch/sensor scan time is too huge or something like that.

Copy that. That’s maybe the root issue.

By the way this is what It looks like for me, see second entity line to cross-check the switch state from first line. There‘s a huge delay for the switch to update as already mentioned.

I see lots of people switching to AdGuard because it’s beautifully/fully integrated into Home Assistant. And indeed, the Pi-Hole integration in comparison lacks a lot of features… :frowning:

Nothing seems to be working and I do not see any pihole sensors. This is what I have added. My pihole is installed on another server not same with Ha.

# Pi-Hole component
sensor:
  - platform: pi_hole
    host: 192.168.1.10

I do not see any sensors like in this image below.

The shell_commands does not seem to work, but it does work when I test paste in a url bar to enable/disable pihole.

shell_commands:

  pi_hole_status: !secret pi_hole_status
  pihole_enable: !secret pi_hole_enable
  pihole_disable: !secret pi_hole_disable
  pihole_disable_time: !secret pi_hole_disable_time

secret:

pi_hole_status: curl -X GET 'http://192.168.1.10/admin/api.php?status'
pi_hole_enable: curl -X GET 'http://192.168.1.10/admin/api.php?enable&auth=TOKEN'
pi_hole_disable: curl -X GET 'http://192.168.1.10/admin/api.php?disable&auth=TOKEN'
pi_hole_disable_time: curl -X GET 'http://192.168.1.10/admin/api.php?disable={{ states.input_select.pihole_time.state }}&auth=TOKEN'

Are my quotes correct?

Update: So strange. I even tried adding this to config as per the Pi-hole Integration and no sensors after a restart of HA.

pi_hole:
  host: '192.168.1.10'
  ssl: false
  verify_ssl: false
  api_key: !secret pi_hole_key

Is it possible to create a switch that Enable’s or Disable’s an Adlists under Group Management?

This is awesome! just set it up and works fantastic

Quick question, how can I add Pi-Hole to the sidebar of home assistant? Thanks!

1 Like