Skip to content

About

Pi-hole Extended: Home Assistant integration for Pi-hole v6 with per-client DNS query sensors and Activity history.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Pi-hole Extended

Open your Home Assistant instance and open this repository inside HACS.

Latest release HACS validation Hassfest

See which device on your network is talking to Pi-hole, and when one goes crazy. Pi-hole Extended turns the queries Pi-hole v6 reports into per-device counters, an activity chart and a live device card for your dashboards, and sensors you can automate on.

Activity card showing three devices, one of them flagged as unusual

A community-built Home Assistant custom integration. It is not affiliated with or endorsed by Home Assistant or Pi-hole.

Features

  • One Home Assistant device per client that Pi-hole sees, with DNS query counters and allowed, blocked and provisional breakdowns.
  • Activity card to chart one or more devices by 5-minute to 1-day blocks over up to 30 days, as lines or bars. Everything is set from the card editor.
  • Live device card (custom:phe-live-card) that shows one device live: rate gauge, usual range, allowed/blocked ring and 60-second bars, editable from the card editor. See Live device card.
  • Unusual-activity detection: a device that stays far above its own usual rate is highlighted in the chart and turns on a binary sensor you can use in automations.
  • Diagnostics for the connection, the last read, the last query seen and ingestion coverage.
  • Privacy-minded: the integration keeps only counters, and the card and sensors use aggregate counts, never domains. Optional Activity entries do include the queried domain; choose Totals only to turn them off.
  • Independent of Home Assistant's built-in Pi-hole integration.

Requirements

  • Home Assistant 2025.1 or newer, with the Recorder enabled (the default).
  • Pi-hole v6. The query API contract is checked against FTL 6.1.0–6.8.x; each Pi-hole serves its API reference at /api/docs.

Installation

HACS (recommended)

  1. In HACS, search for Pi-hole Extended, or select the button at the top of this page to open it directly.
  2. Install it and restart Home Assistant.
  3. Open Settings → Devices & services → Add integration, search for Pi-hole Extended and follow the form.

If the search does not find it, add it as a custom repository: in HACS open ⋮ → Custom repositories, add https://github.com/Andresako/pi-hole-extended, choose Integration and continue from step 2.

Manual

Download the latest release from the releases page, copy custom_components/pihole_queries into your Home Assistant configuration directory and restart Home Assistant.

Configuration

Create an application password in Pi-hole's web interface under Settings; Pi-hole shows it only once (authentication guide). Then enter:

Field Description
Host or IP address Without protocol, port or path.
Web/API port Used exactly as entered.
Use HTTPS / Verify certificate Turn verification off only for a self-signed certificate.
Application password Stored in the integration entry and never written to logs.
Polling interval 1–3600 seconds (default 15). Shorter intervals show new queries sooner and make more API requests.

Options

Open the integration and choose Configure:

Option Values Effect
Polling interval 1–3600 s How often Pi-hole is read.
Activity policy Activity enabled · Totals only Whether new queries are sent to Home Assistant Activity. Totals only sends none.
Activity events All · Blocked only · None Which new queries appear in Activity. Counters are never filtered.
Devices in Home Assistant All clients · Local DNS records only Local DNS records only creates devices just for IPs with a local DNS record in Pi-hole, uses that name and counts the rest under Other devices. Devices left out stop updating; delete them from their page. Default: All clients.
Unusual activity alert Off · Low · Medium · High Sensitivity of the card and the binary sensors. Off creates no sensors. Default: Medium.

Use Reconfigure to change the address or credentials; choose Same Pi-hole to keep counters and identity, or Replacement Pi-hole when the server itself was replaced.

Entities

For every client, grouped under its own device:

Entity Description
sensor.phe_<client>_dns_queries DNS queries: cumulative queries observed.
sensor.phe_<client>_queries_last_minute Queries (last minute): rolling count by Pi-hole's query time.
sensor.phe_<client>_allowed Allowed queries, cumulative.
sensor.phe_<client>_blocked Blocked queries, cumulative.
sensor.phe_<client>_provisional Provisional queries: result not yet recognized.
binary_sensor.phe_<client>_unusual_activity Unusual activity, see below.

Per Pi-hole entry, four diagnostic sensors: Communication status, Last successful read, Last query observed and Ingestion coverage. <client> is the client's address with underscores, for example 192_0_2_21; the entity registry shows the exact IDs.

To delete a device you do not want, open it and choose Delete. Its entities and counters go with it; if the client queries Pi-hole again, the device returns with counters from zero.

The integration counts the queries it observes while polling. It does not backfill what Pi-hole handled before setup.

Activity card

The card is loaded automatically. Add it to a dashboard with Edit dashboard → Add card → Pi-hole Extended activity, or paste it as a manual card:

type: custom:phe-activity-card

Activity card with two devices as bars over three days

Choose the devices, block size, range, chart type and other settings in the card editor. They are saved in the dashboard, so everyone sees the same chart. With no devices selected the card shows the three busiest. You can also write the options in YAML:

type: custom:phe-activity-card
title: Network activity
entities:
  - sensor.phe_192_0_2_21_dns_queries
  - sensor.phe_192_0_2_34_dns_queries
bucket: 30m
span: 1d
chart_type: bar
log_scale: false
show_overview: true
names:
  sensor.phe_192_0_2_21_dns_queries: Living-room TV
Option Values Default
entities Up to 12 DNS queries counters The three busiest
bucket 5m 15m 30m 1h 3h 6h 1d 30m
span 6h 12h 1d 3d 7d 14d 30d 1d
chart_type line · bar line
log_scale true · false false
show_overview Warn about unusual devices, including ones not in the chart true
title Optional heading none
names {entity_id: label} the client's name

In the legend, select a device's colored dot to hide or show it, or its name to open Home Assistant's history for that sensor. Hover the chart for a cursor and a tooltip with each device's rate and how it compares with its usual level.

The card reads Home Assistant's long-term statistics, so the time axis is when Home Assistant received the data. Blocks under one hour are available for ranges up to 10 days, the Recorder's default for 5-minute statistics.

Live device card

The card is loaded automatically. Add it to a dashboard with Edit dashboard → Add card → Pi-hole Extended live device, or paste it as a manual card:

type: custom:phe-live-card
entity: sensor.phe_192_0_2_21_dns_queries

Live device card showing one unusual device

It shows one device right now: a gauge with the current queries per minute, the device's usual rate and alert threshold, a ring with the share of allowed, blocked and provisional queries, 60 one-second bars and a status dot with the age of the last query. The gauge turns red while the device is unusual. Choose the device and which parts to show in the card editor; it only writes the options you change, so the two lines above are all you need. Add one card per device, in a view of your own so you can arrange them. You can also write the options in YAML:

type: custom:phe-live-card
entity: sensor.phe_192_0_2_21_dns_queries
title: Smart camera
show_legend: false
animate: true
Option Values Default
entity The device's DNS queries counter; the card finds the device's other entities by itself required
title Heading the device's name
show_title Show the heading true
show_badge Show Normal, or Unusual activity with how many times the usual rate true
show_gauge Show the rate gauge with the usual rate and the alert threshold true
show_ring Show the allowed, blocked and provisional ring true
show_legend Show the totals of allowed, blocked and provisional queries true
show_strip Show the 60 one-second bars true
show_status Show the status dot and the age of the last query true
animate Move the gauge and the ring smoothly false

The status dot is green when the connection is fresh and the data complete, and amber or red when it may be stale or incomplete. The usual rate is the median of the device's own rates, so it can be 0 for a device that works in bursts; the card then shows only the alert threshold.

Pi-hole is polled, so the bars spread the queries that arrived between two updates over that time. They show the rhythm, not the exact second of each query, and the real values change once per poll interval (15 seconds by default). Like the sensors, the card uses aggregate counts and never shows domains.

Unusual activity

A device is unusual when it stays well above its own recent pattern: several times its usual level, above its typical daily peak and above a minimum rate, for at least 15 minutes. Quiet devices and devices that burst regularly are not flagged for normal behavior, and a new device has no baseline until 24 blocks of history exist (two hours for the sensors).

Each device gets a Unusual activity binary sensor that is on while that happens, off otherwise and unknown until it has enough history (24 five-minute blocks). It is evaluated every 5 minutes, so it reacts within 10 to 20 minutes. Its attributes are current_rate, usual_rate, threshold, times_usual, since and evaluated_at.

automation:
  - alias: Pi-hole · unusual device activity
    triggers:
      - trigger: state
        entity_id: binary_sensor.phe_192_0_2_47_unusual_activity
        to: "on"
        for: "00:10:00"
    actions:
      - action: notify.notify
        data:
          title: Unusual DNS activity
          message: >-
            {{ trigger.to_state.name }} is making
            {{ trigger.to_state.attributes.current_rate }} queries/min,
            {{ trigger.to_state.attributes.times_usual }}× its usual.

Ready-to-import dashboard and automation examples, and how to adapt them, are in the examples guide.

Good to know

  • The card and the sensors read Recorder statistics. If you restrict the Recorder with include, record the client sensors:

    recorder:
      include:
        entity_globs:
          - sensor.phe_*
  • With Activity enabled, each new query is written to Home Assistant's Activity (logbook) with its client, domain and result. Whether it is kept depends on your Recorder and Activity filters. Choose Totals only if you do not want domains in the logbook.

  • At very short polling intervals, or with hundreds of clients, see technical details for the measured limits.

Troubleshooting

  • Counters do not increase: check Communication status, host, port, TLS settings, the password and whether Pi-hole still holds the query in its in-memory history.
  • Counters increase but Activity is empty: confirm Activity enabled is selected, that the events setting allows the result and that Home Assistant's Activity filters allow it.
  • The card is not listed or shows "Custom element doesn't exist": restart Home Assistant after installing or updating and refresh the browser without cache.
  • The chart is empty: the client needs recorded statistics; wait a few minutes after setup and check the Recorder includes sensor.phe_*.
  • Unusual-activity sensors stay unknown: a device needs at least 24 blocks of recorded history (two hours for the sensors) before it has a baseline.
  • Coverage shows Partial or Unknown: the integration could not prove it saw every query (for example Pi-hole trimmed old history or its query IDs restarted). Counters stay valid but may be lower bounds; see architecture. Download the diagnostics from the integration page when reporting an issue.

Support

License

MIT

About

Pi-hole Extended: Home Assistant integration for Pi-hole v6 with per-client DNS query sensors and Activity history.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages