Home Assistant Community Add-on: Pi-hole

Hi!
Having a problem here accessing the API. I have an app with hardcoded URL http://[IP]/admin/api.php. But in my installation the API is available at http://[IP]/api.php.
There is no admin-login at all? When opening the webUI from outside homeassistant the URL shown has no path /admin as well although I’m logged in with user homeassistant.

Config:

update_lists_on_start: false
ssl: false
certfile: fullchain.pem
keyfile: privkey.pem
interface: ''
ipv6: true
ipv4_address: ''
ipv6_address: ''
hosts: []

Network

Container	Host	  Description
4865/tcp	4865      API endpoint (For HA integration)
53/udp	    53        DNS server port
80/tcp	    80        Web interface (Not required for Ingress)

Regards,
petjek

Hi,

I keep getting this error in my system log:

20-03-09 00:59:22 WARNING (MainThread) [hassio.updater] Can’t fetch versions from https://version.home-assistant.io/stable.json: Cannot connect to host version.home-assistant.io:443 ssl:None [Try again]

Reading through some forums posts I found that this setting would solve my issue:
image

But when I try to save this I get following error:

Failed CORS: xxxxx.hopto.me vs 192.168.0.101, , a0d7b954-pi-hole, pi.hole, localhost, hassio, hassio.local

This is my Pi-hole settings:

update_lists_on_start: false
ssl: false
certfile: fullchain.pem
keyfile: privkey.pem
interface: ''
ipv6: true
ipv4_address: ''
ipv6_address: ''
hosts: []
virtual_host: xxxxx.hopto.me

Any suggestions on what this can be?

I did uninstall the pi-hole addon and now I get the updates for Home Assistant as usally.

Hi, in order to make a pihole switch I need the API KEY, but if I go
webui— settings—api — show api token .— yes show api token

I receive a web page with NO PASSWORD SET, and no api token is visible ??

@Klagio If you configure your Pi-Hole integration and switch using “localhost:4865”, then access from your Home Assistant instance should just work.

At least, once I read the docs (including the parts I missed the first time), made the changes, and rebooted Home Assistant (full restart), it’s working for me.

My integration is bog standard, but here’s what I’m using for my switch:

# "Simple" method for disabling Pi-Hole on both instances
# This method requires hard-coded strings for the commands, no secrets
switch:
  - platform: command_line
    scan_interval: 10
    switches:
      pihole_switch_hassio:
        friendly_name: "Ad Blocking (HA)"
        command_on: "curl -X GET 'http://localhost:4865/admin/api.php?enable&auth='"
        command_off: "curl -X GET 'http://localhost:4865/admin/api.php?disable=60&auth='"
        command_state: "curl -X GET 'http://localhost:4865/admin/api.php?status'"
        value_template: "{{ value_json.status == 'enabled' }}"

As you can see, just using the empty API key auth= (along with localhost) is the trick.

mmhhh I have two instances of HASSIO, on my main I use Adguard, on my second I use pi-hole. And then I use as DNS address 1 the address of HASSIO main, and DNS address 2, the address of HASSIO second

SO from HASSIO main, I guess I can’t access the HASSIo/PI-HOLE on the second? Because I wish to have the 2 switches (to turn on/off Adguard and turn on/off pihole), only in HASSIO main

Of course I will not use localhost, but just the IP address 192.168.1.x

Hello,
is there a way to start pihole addon not from Supervisor ?
I use portainer and everytime i try to start pihole addon from portainer, pihole starts and then stop it.
This is useful in case of docker upgrade, since pihole will not restart by itself and will not turn it on automatically.
Or maybe i’m blind, if there is a way let me know, thanks.

p.s. nodered addon has the same issue.

I have a script for all HA add-ons I use under exactly that circumstance. None of them stay started with Portainer.

Can you please post it?
The issue is not only portainer, if i docker start addon_a0d7b954_pi-hole it won’t stay on anyway :thinking:

adguard addon has not that issue.

startalladdons:
  alias: Start all Hass.io addons
  sequence:
  - data: {"addon": "7be23ff5_dropbox_sync"}
    service: hassio.addon_start
  - data: {"addon": "a0d7b954_appdaemon"}
    service: hassio.addon_start
  - data: {"addon": "a0d7b954_glances"}
    service: hassio.addon_start
  - data: {"addon": "a0d7b954_jupyterlablite"}
    service: hassio.addon_start
  - data: {"addon": "a0d7b954_logviewer"}
    service: hassio.addon_start
  - data: {"addon": "a0d7b954_sonweb"}
    service: hassio.addon_start
  - data: {"addon": "a0d7b954_ssh"}
    service: hassio.addon_start
  - data: {"addon": "a0d7b954_vscode"}
    service: hassio.addon_start
  - data: {"addon": "a0d7b954_zerotier"}
    service: hassio.addon_start
  - data: {"addon": "core_configurator"}
    service: hassio.addon_start
  - data: {"addon": "core_mosquitto"}
    service: hassio.addon_start
  - data: {"addon": "core_samba"}
    service: hassio.addon_start
  - data: {"addon": "fe41fc28_caddy"}
    service: hassio.addon_start

And I use a button-card to execute it. Docker start would have the same problem as Portainer.

ah, an HA script, i thought it was a bash script :man_facepalming:
Thanks for that, will do some tests.
It’s really strange why some docker containers can’t start by itself via cli or gui while other containers can :man_shrugging:
I’m not really a fan of “let low level tasks be done via HA” and hope it could be fixed a day.

None of the HA containers will stay running if started via Portainer. Non ha ones will.

mmm, not really true, i can stop and start for example: portainer, esphome, mosquitto.
Am i missing something? :thinking:

No idea but for HA containers I have to use that script.

No idea what problem I´m facing? Opening the UI from supervisor does not require a login. When using http://homeassistant:80 I can login with my user credentials but behavior is same.
See my last post here:
Home Assistant Community Add-on: Pi-hole

I’ve been using pihole regularly without Hassio, but no matter what settings I use I can’t make it work with hassio.

I have an ASUS router, if I add the local hassio ip there it doesn’t work.

I would appreciate any help to set it up, or an example please.

pihole is really a crazy thing.
Tried to use that service call and pihole is not starting, while other addons do…and i don’t have any error in log.

'1584345413987':
  alias: Reboot_Addons
  sequence:
  - data:
      addon: a0d7b954_nodered
    service: hassio.addon_restart
  - data:
      addon: core_configurator
    service: hassio.addon_restart
  - data:
      addon: a0d7b954_pi_hole
    service: hassio.addon_restart

no error, but only pihole is not restarting.
i’m starting to really hate pihole :triumph:

EDIT: seems not working via script or automation, but works with nodered.
Just make an http request node to fire when any pihole sensor became “unavailable” ( events state node ).
The http node needs to send a POST to:

http://IP:8123/api/hassio/addons/a0d7b954_pi-hole/restart

Authtentication Type bearer and insert a long live token ( generate one from HA ).
As soon as nodered read the unavailable state for the sensor, pihole is restarted.
A bit tricky but this one works.

Confirmed that this change worked for me. Many thanks.

1 Like

Ok, i found something strange: if i start hassio.addon_restart with a0d7b954_pi-hole i have this error messagge:

If i launch the script with a0d7b954_pi_hole it starts but it does nothing.
Maybe the problem is that _ instead of - ?
:thinking:

Really not sure why but I cannot get my Pi Hole stats to display in my Lovelace cards - it just says everything is unavailable. It used to work but stopped last year and now I cannot work out why. Pi Hole itself works fine.

I’ve Googled it and tried every suggestion I could see - every host variation with / without port, putting verify_ssl = true, etc. Does anyone have anything else I could try?

pi_hole:
  host: 'localhost:4865'
  ssl: true
  verify_ssl: false
  api_key: ""
update_lists_on_start: false
ssl: true
certfile: fullchain.pem
keyfile: privkey.pem
interface: ''
ipv6: true
ipv4_address: ''
ipv6_address: ''
hosts: []
virtual_host: <my DuckDNS address>

In the log I just get this:

2020-03-23 20:05:56 ERROR (MainThread) [homeassistant.components.pi_hole] Unable to fetch data from Pi-hole
2020-03-23 20:11:06 ERROR (MainThread) [hole] Can not load data from *hole: localhost:4865
1 Like