Pi-Hole Integration

Do you have a new Version?

The Switch don’t work anymore…

hey… I integrated the Pi-Hole yesterday… the switch works well in my case. I do not use a map in the channel in my case (please check that you call the URL with “disable” and not with “disabled”):

- id: status
    channelTypeUID: http:switch
    label: Status
    description: null
    configuration:
      onValue: enable
      offValue: disable
      stateExtension: /admin/api.php?summaryRaw&auth=xxxx
      commandExtension: /admin/api.php?%2$s&auth=xxxxx
      stateTransformation: JSONPATH:$.status∩REGEX:s/led/le/g

Disable and enable the Pi-Hole.
Regards,
Tim

Don’t work for me… Anyone else with text based things?

When I work with your stateExtension, commandExtension my other things don’t work anymore (because of the BaseURL).

Thing http:url:pihole "Pihole" [
	baseURL = "http://192.168.1.17/admin/api.php?summary&auth=xxxx",
	refresh = "120",
	timeout ="5000",
	ignoreSSLErrors = "true"
]
{
	Channels:
      
		Type number : domains_being_blocked [
			mode = "READONLY",
			stateTransformation = "JSONPATH:$.domains_being_blocked"
		]
		Type number : dns_queries_today [
			mode = "READONLY",
			stateTransformation = "JSONPATH:$.dns_queries_today"
		]
		Type number : ads_blocked_today [
			mode = "READONLY",
			stateTransformation = "JSONPATH:$.ads_blocked_today"
		]
		Type number : ads_percentage_today [
			mode = "READONLY",
			stateTransformation = "JSONPATH:$.ads_percentage_today"
		]
		Type number : unique_domains [
			mode = "READONLY",
			stateTransformation = "JSONPATH:$.unique_domains"
		]
		Type number : queries_forwarded [
			mode = "READONLY",
			stateTransformation = "JSONPATH:$.queries_forwarded"
		]
		Type number : queries_cached [
			mode = "READONLY",
			stateTransformation = "JSONPATH:$.queries_cached"
		]
		Type number : clients_ever_seen [
			mode = "READONLY",
			stateTransformation = "JSONPATH:$.clients_ever_seen"
		]
		Type number : unique_clients [
			mode = "READONLY",
			stateTransformation = "JSONPATH:$.unique_clients"
		]
		Type number : dns_queries_all_types [
			mode = "READONLY",
			stateTransformation = "JSONPATH:$.dns_queries_all_types"
		]
		Type number : reply_NODATA [
			mode = "READONLY",
			stateTransformation = "JSONPATH:$.reply_NODATA"
		]
		Type number : reply_NXDOMAIN [
			mode = "READONLY",
			stateTransformation = "JSONPATH:$.reply_NXDOMAIN"
		]
		Type number : reply_CNAME [
			mode = "READONLY",
			stateTransformation = "JSONPATH:$.reply_CNAME"
		]
		Type number : reply_IP [
			mode = "READONLY",
			stateTransformation = "JSONPATH:$.reply_IP"
		]
		Type number : privacy_level [
			mode = "READONLY",
			stateTransformation = "JSONPATH:$.privacy_level"
		]
		Type switch : status [
			mode = "READONLY",
			stateTransformation = "JSONPATH:$.status",
			onValue = "enabled",
			offValue = "disabled"
		]
		Type switch : enable_disable "PiHole Command (Enable/Disable)" [
				mode = "WRITEONLY",
				stateExtension = "/admin/api.php?summaryRaw&auth=xxxx",
				commandExtension = "/admin/api.php?%2$s&auth=xxxx",
				stateTransformation = "JSONPATH:$.status∩REGEX:s/led/le/g",
				onValue = "enable",
				offValue = "disable"		
			]


		//GRAVITY LAST UPDATED
		Type string : file_exists [
			mode = "READONLY",
			stateTransformation = "JSONPATH:$.gravity_last_updated.file_exists"
		]
		//ABSOLUTE TIME OF LAST UPDATE
		Type number : absolute [
			mode = "READONLY",
			stateTransformation = "JSONPATH:$.gravity_last_updated.absolute"
		]
		//RELATIVE TIME OF LAST UPDATE
		Type number : days [
			mode = "READONLY",
			stateTransformation = "JSONPATH:$.gravity_last_updated.relative.days"
		]
		Type number : hours [
			mode = "READONLY",
			stateTransformation = "JSONPATH:$.gravity_last_updated.relative.hours"
		]
		Type number : minutes [
			mode = "READONLY",
			stateTransformation = "JSONPATH:$.gravity_last_updated.relative.minutes"
		]
}

Great!

But… When I click the PiHole Status card, the command is sent, and my pi-hole is disabled, however, the status of the card only changes after a couple of seconds. That is of course confusing for other users with less patience…

Why is there a delay, and is it possible to speed up the status update of the card? Maybe have it toggled immediately, along with the command that’s sent?

(My yaml knowledge and understanding is still quite small - for a so-called easy language, I find it difficult :stuck_out_tongue:)

Now it worked for me, but the switch dont update its status. Do you have any idea?

Also i get this warning:

2024-07-10 14:25:36.433 [WARN ] [nelTransformation$TransformationStep] - Failed to use TransformationStep{serviceName='REGEX', function='s/led/le/g'}, service not found
//THING
Thing http:url:pihole "Pihole" [
	authMode = "BASIC",
	ignoreSSLErrors = "false",
	baseURL = "http://192.168.1.17/admin/",
	delay = "0",
	stateMethod = "GET",
	refresh = "300",
	commandMethod = "GET",
	timeout ="3000",
	bufferSize = "2048"
]
{
	Channels:
      
         Type number : domains_being_blocked "Domains in Blockierlisten" [
			mode = "READONLY",
			stateExtension = "api.php?summaryRaw&auth=xxx",
			stateTransformation = "JSONPATH:$.domains_being_blocked"
			]

        Type number : dns_queries_today "DNS Anfragen (heute)" [
			mode = "READONLY",
			stateExtension = "api.php?summaryRaw&auth=xxx",
			stateTransformation = "JSONPATH:$.dns_queries_today"
			]

	    Type number : ads_blocked_today "Werbung Blockiert (heute)" [
			mode = "READONLY",
			stateExtension = "api.php?summaryRaw&auth=xxxx",
			stateTransformation = "JSONPATH:$.ads_blocked_today"
			]

		Type number : ads_percentage_today "Werbung Anteil (heute)" [
			mode = "READONLY",
		    unit = "%",
			stateExtension = "api.php?summaryRaw&auth=xxxx",
			stateTransformation = "JSONPATH:$.ads_percentage_today"
			]

		Type switch : status "Webseiten Filter" [
			onValue = "enable",
            offValue ="disable",
            stateExtension = "api.php?summaryRaw&auth=xxx",
            commandExtension = "api.php?%2$s&auth=xxxx",
            stateTransformation = "JSONPATH:$.status∩REGEX:s/led/le/g"
			]
}

Do you install REGEX Transformation?

Now I have installed Regex. The warning is now gone.

However, the Switch still doesn’t update. Switching works.

Please double check the configuration: Pi-Hole Integration in openHAB - 360°Friends
You could also check the log. You should see the HTTP requests and could check, if the URL is the right one. You can also call the URL manually and check if the PiHole take the command (perhaps the API key is wrong).
Regards,
Tim

Checked the whole config. Now it works. Thank you!