PiHole Status Control - HTTP Binding - OH3

Continuing the discussion from OH3: Integrate PI-Hole via HTTP-Binding using the UI:

Hi OH community,

as it took me some time to get PiHole status changes integrated well after updating to OH3 (changed HTTP binding) I’m happy to share here my new configuration.

Things

Thing http:url:pihole "pihole" [
    baseURL="http://pihole.local/admin/api.php",
    stateMethod="GET",
    commandMethod="POST",
	refresh=30,
    ignoreSSLErrors=true,
    contentType="application/json" ]
    {
		Channels:
			Type switch : status "PiHole Status" [ stateTransformation="JSONPATH:$.status", onValue="enabled", offValue="disabled", commandTransformation="MAP:pihole.map", commandExtension="?%2$s&auth=xx <pihole api key> xxx" ]
    }

pihole.map

enabled=enable
disabled=disable

Item

Switch PiHole_Status "Status [%s]" <pihole> { channel="http:url:pihole:status" }

Sitemap

Frame label="Pi-Hole" {
	Switch item=PiHole_Status
}

The state of pihole will be up-to-date regardless if it get’s changed by WebUI or other programm because status updated every 30 sec. State change can be done by sitemap.

Hope this will save you some time :slight_smile:

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.