PiHole Switch

Ok, I figured out the missing API key entry in the config flow, for whatever reason my brain glossed over the ‘statistics only’ checkbox. Once I uncheck that, a second screen follows with an API key prompt (duh).

I still don’t get timely refreshes. Looking in the code I see
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=5)

Can we consider adding this to the config flow and making it a parameter?

1 Like

Same problem here. The Pi-Hole switch used to work perfectly, where the status instantly updated even if the Pi-hole was disabled through the web interface. Not working anymore. I can disable the Pi-hole with the switch, however the switch goes back to on almost instantly despite the Pi-hole being disabled. This way it is really unusable.

1 Like

Having this problem as well. A fix would be wonderful.

Also having this problem. Anyone raised an actual issue for it?

There is now.

You can create a command line switch. Here is a switch that turns off Pi-Hole for an hour. Work’s fine.

You must search and changeWEBPASSWORD and known Pi-Hole IP.

# For find WEBPASSWORD execute 'cat /etc/pihole/setupVars.conf' in your Pi-hole Server.
switch:
  - platform: command_line
    switches:
      pihole:
        command_on: "curl -ks 'http://X.X.X.X/admin/api.php?enable&auth=WEBPASSWORD'"
        command_off: "curl -ks 'http://X.X.X.X/admin/api.php?disable=3600&auth=WEBPASSWORD'"
        command_state: "curl -ks GET 'http://X.X.X.X/admin/api.php'"
        value_template: "{{ value_json.status == 'enabled' }}"
        friendly_name: Pi-Hole

How can you amend the command line to use the !secret facility so as to not have the password within the main configuration.yaml?

Try the following, but I don’t think it will work.

command_on: !secret <command_on_line_name>

I’ve added the Pi-Hole integration to my HA instance and used your command_line switch successfully to enable/disable DNS filtering. For automation purposes, could I use similar syntax to send the Pi a sudo shutdown now command?