openhab3
- Working openhab3 setup
- HTTP-Binding installed
- JSON-Path-Transormation installed
- Add a new HTTP-Thing and configure it like shown in the image below
- Add a
pihole.things
file to your openHab3 config - Add all paths you later want to display in a sitemap as a channel
- an example can be found here
- Add a
pihole.items
file to your openHab3 config - Create an item for each value you want to display or use in openHab
- an example can be found here
- Create a Sitemap and display the pihole values like shown in the image below
- an example for the sitemap below can be found here
If your PiHole instance uses a web interface password, further authentication is required in pihole.things
file.
Original PiHole BlogPost: PiHole BLog Announcement
-
Get your API Token from PiHole Instance: {piHoleUrl}/admin/settings.php?tab=api
-
Change your baseUrl in
pihole.things
file in your openHab3 config.
Thing http:url:piholenew "PiHole" [ baseURL="http://{piHoleUrl}/admin/api.php?summary&auth={RawApiToken}", refresh=36000] {
Channels:
Type string : DomainsBlocked "Domains Blocked" [ stateTransformation="JSONPATH:$.domains_being_blocked" ]
Type string : QueriesToday "Queries Today" [ stateTransformation="JSONPATH:$.dns_queries_today" ]
Type string : AdsBlockedToday "ADS Blocked Today" [ stateTransformation="JSONPATH:$.ads_blocked_today" ]
Type string : AdsPercentageToday "ADS Percentage Today" [ stateTransformation="JSONPATH:$.ads_percentage_today" ]
Type string : UniqueDomains "Unique Domains" [ stateTransformation="JSONPATH:$.unique_domains" ]
Type string : QueriesForwarded "Queries QueriesForwarded" [ stateTransformation="JSONPATH:$.queries_forwarded" ]
Type string : QueriesCached "Queries Cached" [ stateTransformation="JSONPATH:$.queries_cached" ]
Type string : UniqueClients "Unique Clients" [ stateTransformation="JSONPATH:$.unique_clients" ]
Type string : ClientsEverSeen "Clients ever seen" [ stateTransformation="JSONPATH:$.clients_ever_seen" ]
Type string : DomainsBlocked "DNS Queries all Types" [ stateTransformation="JSONPATH:$.domains_being_blocked" ]
Type string : Status "Status" [ stateTransformation="JSONPATH:$.status" ]
}
{RawApiToken} is copied from Step1 using the 'Show API Token' Button.
Please note: Add ?summary
as an additional query parameter to query the PiHole endpoint for the configured json structure from your pihole.things
configuration.