Sla over naar de inhoud

How to monitor a dynamic WAN IP address with openHAB

Please note: I have published this tutorial on the openHAB wiki as well.

Most Internet Service Providers (ISP) provide you with a dynamic WAN IP address. This address may change over time. If you rely on this address, for example for accessing a computer inside your home network, you might want to monitor changes to the address. Websites like icanhazip and WhatIsMyIP return your public IP address as plain text.

This solution grabs that address and stores it in an item. A rule monitors changes to the item and acts on it.

This solution requires that you have the [[HTTP Binding|Http-Binding]] installed.

Note: Please be nice to the websites you ping. Don’t increase the interval above once per minute.

demo.items

// check for WAN IP address changes every 10 mins
String Network_WAN_IP "WAN IP address [%s]" (Network) { http="<[http://icanhazip.com:600000:REGEX((.*?))]"

demo.rules

rule "Monitor WAN IP"
when
Item Network_WAN_IP changes
then
// perform any action needed
logInfo("MonitorWANIP", "WAN IP changed to " + Network_WAN_IP.state)
end

demo.sitemap

sitemap demo label="Demo" {
Frame {
Text item=Network_WAN_IP
}
}
Published inComputers