How to get Pi-Hole value into Domoticz Topic is solved

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
drenergy
Posts: 6
Joined: Sunday 16 August 2015 16:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands, Dordrecht
Contact:

How to get Pi-Hole value into Domoticz

Post by drenergy »

Hi,

Yesterday I installed Pi-hole (pi-hole.net) on my raspberry pi. This software is to block advertisements and it's working great!

When I enter the following URL I get the current values for the number of Ads being blocked today and some other values.

http://<raspberrypi IP/admin/api.php

{"domains_being_blocked":"51,409","dns_queries_today":"3,311","ads_blocked_today":"193","ads_percentage_today":"5.8"}

Now I would like to put this values into Domoticz but I have no idea how?

Anyone know an easy way to accomplish this?

Thanks in advance!
User avatar
Westcott
Posts: 423
Joined: Tuesday 09 December 2014 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: How to get Pi-Hole value into Domoticz

Post by Westcott »

That looks like JSON encoding.
Perhaps this topic will give some clues -
http://www.domoticz.com/forum/viewtopic.php?t=11450
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
drenergy
Posts: 6
Joined: Sunday 16 August 2015 16:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands, Dordrecht
Contact:

Re: How to get Pi-Hole value into Domoticz

Post by drenergy »

Westcott wrote:That looks like JSON encoding.
Perhaps this topic will give some clues -
http://www.domoticz.com/forum/viewtopic.php?t=11450
Thank you for your quick reply Westcott! I will look at that topic and try to make it work. I will post the result in this topic for other people who might want to try this.
User avatar
Westcott
Posts: 423
Joined: Tuesday 09 December 2014 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: How to get Pi-Hole value into Domoticz

Post by Westcott »

This is how to read and decode to a table.
Just pass it your URL.
You'll need to get JSON.lus, see the Wiki.

Code: Select all

function GetJSONdata(url)
	if not JSON then
		JSON = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()
	end

	local jsondata = assert(io.popen(url))
	local data = jsondata:read('*all')
	jsondata:close()
	return JSON:decode(data)
end
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
clubeddie
Posts: 80
Joined: Saturday 19 March 2016 21:12
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: How to get Pi-Hole value into Domoticz

Post by clubeddie »

drenergy wrote:
Westcott wrote:That looks like JSON encoding.
Perhaps this topic will give some clues -
viewtopic.php?t=11450
Thank you for your quick reply Westcott! I will look at that topic and try to make it work. I will post the result in this topic for other people who might want to try this.
Did you get it working?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest