/addon-pi-hole

Pi-hole - Community Hass.io Add-on for Home Assistant

Primary LanguageShellMIT LicenseMIT

Community Hass.io Add-ons: Pi-hole

GitHub Release Project Stage License

GitLab CI Project Maintenance GitHub Activity

Bountysource Discord Community Forum

Buy me a coffee

Network-wide ad blocking using your Hass.io instance

About

Pi-hole is an advertising-aware DNS- and web server, meant to be run on a dedicated Raspberry Pi connected to your home network. Pi-hole lets you block advertisements for every device that connects to your network without the need for any client-side software.

This add-on is a port of Pi-hole to be able to run on Hass.io and is based on Alpine Linux and is using Docker.

Installation

The installation of this add-on is pretty straightforward and not different in comparison to installing any other Hass.io add-on.

NOTE: Your Hass.io machine MUST HAVE a static IP for this add-on to function properly/fully.

  1. Add our Hass.io add-ons repository to your Hass.io instance.
  2. Install the "Pi-hole" add-on
  3. Start the "Pi-hole" add-on
  4. Check the logs of the "Pi-hole" add-on to see it in action.

NOTE: Do not add this repository to Hass.io, please use: https://github.com/hassio-addons/repository.

Docker status

Docker Architecture Docker Version Docker Layers Docker Pulls Anchore Image Overview

Docker Architecture Docker Version Docker Layers Docker Pulls Anchore Image Overview

Docker Architecture Docker Version Docker Layers Docker Pulls Anchore Image Overview

Docker Architecture Docker Version Docker Layers Docker Pulls Anchore Image Overview

Configuration

Note: Remember to restart the add-on when the configuration is changed.

Example add-on configuration:

{
  "log_level": "info",
  "password": "changeme",
  "update_lists_on_start": true,
  "http_port": 80,
  "https_port": 443,
  "dns_port": 53,
  "ssl": false,
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "interface": "eth0",
  "ipv6": true,
  "ipv4_address": "",
  "ipv6_address": "",
  "virtual_host": "homeassistant.example.com",
  "hosts": [
    {
      "name": "printer.local",
      "ip": "192.168.1.5"
    },
    {
      "name": "router.local",
      "ip": "192.168.1.1"
    },
    {
      "name": "router.local",
      "ip": "FE80:0000:0000:0000:0202:B3FF:FE1E:8329"
    }
  ]
}

Note: This is just an example, don't copy and past it! Create your own!

Option: log_level

The log_level option controls the level of log output by the addon and can be changed to be more or less verbose, which might be useful when you are dealing with an unknown issue. Possible values are:

  • trace: Show every detail, like all called internal functions.
  • debug: Shows detailed debug information.
  • info: Normal (usually) interesting events.
  • warning: Exceptional occurrences that are not errors.
  • error: Runtime errors that do not require immediate action.
  • fatal: Something went terribly wrong. Add-on becomes unusable.

Please note that each level automatically includes log messages from a more severe level, e.g., debug also shows info messages. By default, the log_level is set to info, which is the recommended setting unless you are troubleshooting.

Using trace or debug log levels puts the dnsmasq daemon into debug mode, allowing you to see all DNS requests in the add-on log.

Option: password

Sets the password to authenticate with the Pi-hole web interface. Leaving it empty disables the possibility to authenticate completely.

Note: Be aware! Even when you have set a password, some statistics are still visible / available.

Option: update_lists_on_start

Download and process all configured ad block lists on add-on startup by setting this option to true. This will add startup time to your add-on but will give you the most recent versions of the ad block lists on start.

When this option is set to false you will still get updated lists once in a while. A scheduled task will take care of that.

Note: When starting the add-on for the very first time, the lists will be updated, regardless of the value of this option.

Option: http_port

Changes the port on which the Pi-hole web interface and the blocked page will be served from.

Note: Port 80 is highly recommended because if you have another service using port 80, then the ads may not transform into blank ads correctly.

Option: https_port

Changes the port on which the Pi-hole web interface and the blocked page will be served from (SSL/HTTPS).

Note: HTTPS is additional, in cause you'd like to expose the interface to the outside world, but still want to service the blocked page on HTTP.

Option: dns_port

Allows you to change the DNS port. 53 is the default port for DNS. Unless you have a good reason to change it, leave it to 53.

Option: ssl

Enables/Disables SSL (HTTPS) on the web interface of Pi-hole. Set it true to enable it, false otherwise.

Note: Enabling SSL on Pi-hole may have side effects, which may cause ads not to transform into blank ads correctly.

Option: certfile

The certificate file to use for SSL.

Note: The file MUST be stored in /ssl/, which is default for Hass.io

Option: keyfile

The private key file to use for SSL.

Note: The file MUST be stored in /ssl/, which is default for Hass.io

Option: interface

Configures the interface the Pi-hole DNS server should be listening to. By leaving it empty, the add-on will try to auto-detect the interface to use.

Note: This option is in place in case auto-detection fails on your setup.

Option: ipv6

Set this option to false to disable IPv6 support.

Option: ipv4_address

Manually set the IPv4 address for Pi-hole to use. By leaving it empty, the add-on will try to auto-detect the interface to use.

Note: This option is in place in case auto-detection fails on your setup.

Option: ipv6_address

Manually set the IPv6 address for Pi-hole to use. By leaving it empty, the add-on will try to auto-detect the interface to use.

Note: This option is in place in case auto-detection fails on your setup.

Option: virtual_host

In case you have an alternative hostname to access Pi-hole (e.g., DuckDNS), you can specify it in this option. This improves the handling of the Pi-hole blocked website & admin web interface pages.

Option: hosts

This option allows you create your own DNS entries for your LAN. This capability can be handy for pointing easy to remember hostnames to an IP (e.g., point printer.local to the IP address of your printer).

Add a list of hosts you want to add. Some hosts can have both IPv4 and IPv6 addresses. In that case, simply add the host twice (with both addresses).

See the example above this chapter for a more visual representation.

Sub-option: name

This option specifies the DNS name of the host you are adding. Its value could be a short style hostname like: printer or a longer one printer.local.

Sub-option: ip

The IP address this specified host must point to. Its value must be an IPv6 or IPv4 IP address.

Embedding into Home Assistant

It is possible to embed the Pi-hole admin directly into Home Assistant, allowing you to access your Pi-hole admin through the Home Assistant frontend.

Home Assistant provides the panel_iframe component, for these purposes.

Example configuration:

panel_iframe:
  pihole:
    title: Pi-hole
    icon: mdi:block-helper
    url: http://addres.to.your.hass.io/admin/index.php

Using the Pi-hole sensor in Home Assistant

Home Assistant offers a Pi-hole sensor that allows you to display the statistical summary of your Pi-hole installation.

To enable this sensor, add the following lines to your configuration.yaml file:

# Example configuration.yaml entry
sensor:
  - platform: pi_hole

For more information and documentation about configuring this sensor, please check the documentation of Home Assistant.

Changelog & Releases

This repository keeps a change log using GitHub's releases functionality. The format of the log is based on Keep a Changelog.

Releases are based on Semantic Versioning, and use the format of MAJOR.MINOR.PATCH. In a nutshell, the version will be incremented based on the following:

  • MAJOR: Incompatible or major changes.
  • MINOR: Backwards-compatible new features and enhancements.
  • PATCH: Backwards-compatible bugfixes and package updates.

Support

Got questions?

You have several options to get them answered:

You could also open an issue here GitHub.

Contributing

This is an active open-source project. We are always open to people who want to use the code or contribute to it.

We have set up a separate document containing our contribution guidelines.

Thank you for being involved! 😍

Authors & contributors

The original setup of this repository is by Franck Nijhof.

For a full list of all authors and contributors, check the contributor's page.

We have got some Hass.io add-ons for you

Want some more functionality to your Hass.io Home Assistant instance?

We have created multiple add-ons for Hass.io. For a full list, check out our GitHub Repository.

License

MIT License

Copyright (c) 2017 Franck Nijhof

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.