WAN IP Checker Reinvented

Easy to use, 100% Lua-based event scripting framework.
Post Reply
User avatar
Posts: 953
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi
Domoticz version: latest
Location: Milano, Italy

WAN IP Checker Reinvented

Post by emme » Monday 16 July 2018 10:50


based on the fact that 4.icfg.me seems to be no longer working and thans to dzVents new frameworks that support Http response,
I rewrite the wan IP checker that now looks much smarter:

Code: Select all

local getIp    = 'https://api.ipify.org/?format=json'

return {
	on = {
		timer =         { 'every 6 hours' },
		httpResponses = { 'wanIP' }
	logging = {
        level = domoticz.LOG_FORCE,
        marker = '[WAN IP]'

	execute = function(dz, devNil)
    local actIP = dz.devices('Wan IP').text 
    local newIP = 'Unable to retrieve IP'
        if (devNil.isTimer)  then
            dz.log("Send WanIP request")
                url = getIp,
                method = 'GET',
                callback = 'wanIP'
        elseif (devNil.isHTTPResponse) then
            dz.log("WanIP response")
            if (devNil.ok) then -- statusCode == 2xx
                newIP = devNil.json.ip
            if newIP ~= actIP then 
                dz.devices('Wan IP').updateText(newIP)
..mmh... I don't know ho to update the wiki :P :P
The most dangerous phrase in any language is:
"We always done this way"

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests