There is an existing BIND DDNS that is working nicely with my local DHCP and gets the dynamic updates.
I am too lazy to configure the embedded FTL DNS of PiHole to replace my BIND
I didn’t even check if FTL DNS supports dynamic updates… in theory it does
Finally, I placed PiHole between my LAN and External DNS and it works fine (with the disadvantage of listing only localhost as the client )
thanks for your post. I want to know if you have an idea, why it doesn’t work in my environment.
I configure it step by step but I can’t see anything in the Sitemap … in the openHAB shell every pi hole item are NULL …
btw: it’s my first http binding
Good point. My PiHole simply runs independently of anything else. Frankly I totally forgot about it for months now.
Really rarely I’ve disabled it for a few minutes to check if a website is unintentionally blocked or to demonstrate the difference / advantages of PiHole to friends.
Then it is just convenient to have the controls and statistics in the same environment as the home automation.
Automated interaction with light switch, weather data or user presence? Not really imho.
Thanks for the implementation, I have been using it for months now. I have extended a bit. There are more info available from the API:
Number PiHole_DomainsBeingBlocked "Domains being blocked [%d]" <pihole> (gPiHole) {http="<[pihole:100000:JSONPATH($.domains_being_blocked)]"}
Number PiHole_DnsQueriesToday "DNS queries today [%d]" <chart> (gPiHole) {http="<[pihole:100000:JSONPATH($.dns_queries_today)]"}
Number PiHole_AdsBlockedToday "Ads blocked today [%d]" <keyring> (gPiHole) {http="<[pihole:100000:JSONPATH($.ads_blocked_today)]"}
Number PiHole_AdsPercentageToday "Ads percentage today [%.2f %%]" <keyring> (gPiHole) {http="<[pihole:100000:JSONPATH($.ads_percentage_today)]"}
Number PiHole_UniqueDomains "Unique domains [%d]" <network> (gPiHole) {http="<[pihole:100000:JSONPATH($.unique_domains)]"}
Number PiHole_QueriesForwarded "Queries forwarded [%d]" <chart> (gPiHole) {http="<[pihole:100000:JSONPATH($.queries_forwarded)]"}
Number PiHole_QueriesCached "Queries cached [%d]" <wind> (gPiHole) {http="<[pihole:100000:JSONPATH($.queries_cached)]"}
Number PiHole_ClientsEverSeen "Clients ever seen [%d]" <screen> (gPiHole) {http="<[pihole:100000:JSONPATH($.clients_ever_seen)]"}
Number PiHole_UniqueClients "Unique clients [%d]" <screen> (gPiHole) {http="<[pihole:100000:JSONPATH($.unique_clients)]"}
Number PiHole_DnsQueriesAllTypes "DNS queries All Type [%d]" <chart> (gPiHole) { http="<[pihole:100000:JSONPATH($.dns_queries_all_types)]" }
Number PiHole_ReplyNoData "Reply No Data [%d]" <wind> (gPiHole) { http="<[pihole:100000:JSONPATH($.reply_NODATA)]" }
Number PiHole_ReplyNxDomain "Reply NXDomain [%d]" <wind> (gPiHole) { http="<[pihole:100000:JSONPATH($.reply_NXDOMAIN)]" }
Number PiHole_ReplyCName "Reply CName [%d]" <wind> (gPiHole) { http="<[pihole:100000:JSONPATH($.reply_CNAME)]" }
Number PiHole_ReplyIP "Reply IP [%d]" <wind> (gPiHole) { http="<[pihole:100000:JSONPATH($.reply_IP)]" }
String PiHole_UpdatedDays <time> (gPihole) { http="<[pihole:100000:JSONPATH($.gravity_last_updated.relative.days)]" }
String PiHole_UpdatedHours <time> (gPiHole) { http="<[pihole:100000:JSONPATH($.gravity_last_updated.relative.hours)]" }
String PiHole_UpdatedMinutes <time> (gPiHole) { http="<[pihole:100000:JSONPATH($.gravity_last_updated.relative.minutes)]" }
Also built a rule, so that you can disable (temporary) Pi-hole blocking from openHAB:
val String filename = "PiHole.rules"
val String WEBPASS = "YOUR WEBPASS"
rule "Disable Pi-Hole"
when
Item PiHole_Disable received command
then
logInfo(filename, "Started: Disable Pi-Hole - State: " + PiHole_Disable.state.toString)
if(receivedCommand == ON) {
sendHttpGetRequest("http://<PIHOLE IP>/admin/api.php?disable=300&auth=" + WEBPASS, 2000)
}
else if(receivedCommand == OFF) {
sendHttpGetRequest("http://<PIHOLE IP>/admin/api.php?enable&auth=" + WEBPASS, 2000)
}
end
You can find the Webpass in the Pi-hole config file, that is needed for this rule to work. You can specify seconds after “disable=” for how many seconds you want to disable the blocking.
I also have that Just forgot to include in my post.
I don’t know why it always shows enabled. Are you sure that the specified updateInterval ran after you disabled it?
Try disabling Pi-hole and open the http://“Pi-Hole address”/admin/api.php endpoint in your browser and look there if it shows disabled or not.
For me it works as it should. It shows disabled if I turn off blocking. Doesn’t matter if it is temporary or not.
Yes this will never be ‘real time’, because it is just polling that http endpoint.
If I’m right this value is the Refresh Interval, you can set the Update Interval in the http.cfg. If you used the tutorial in the original post, it is set to 10 minutes poll time.
Excellent Rule Kristof, just (as a non developer) I am puzzled how you extract the values of the Days, Hours and Minutes using JSONPATH out of the return from the API call to …/admin/api.php? As the values are stored in ‘sub’ values a direct JSONPATH call like:
Getting this error when using this rule, so the items are not being listed for the last updates. Any input?
An error occurred during the script execution: index=1, size=1
You have an extra space in the first line after the http=" …
I don’t know if this causes any trouble… Try adding these items to a sitemap and see if you get any readable output