wg(ipv4.jsonip.com,json,.ip) Update Problem


I've created a text based widget to show me info about my WiFi and network connection. It's working well except for the External IP line never updating unless I manually update it. There are five display lines:

WiFi Signal Strength in %
WiFi Speed in Mbps
Internal IP
External IP

If there's no WiFi, the first line displays •••No WiFi••• in red, and the next three lines are blank. If the cell network is connected, the fifth line continues to show my external IP (a different IP provided by my cell connection when the WiFi stopped). If there's no network at all, the fifth line displays •No Network• in red.


I have Touch functions setup on all five lines. Touching the first line sends you to the Android WifiSettingsActivity screen. Touching any of the other four lines tells Kustom to TEXT_UPDATE.

The first four items update as and when expected. They all rely ONLY on nc() expressions. The fifth item (External IP) also relies on a wg() expression.

The code for the External IP item is:

(nc(ssid)!="" & nc(ssid)!="nossid") | (nc(cell) ="data" | nc(cell)= "dataroaming"),
("Net: " + wg(ipv4.jsonip.com,json,.ip)),
"[f=SouvMed][s=1.4][c=#FF0000]• NO Network •[/c][/s][/f]"

When I go out of WiFi range (or turn WiFi off) the top line goes red, the next three lines disappear, and the fifth line stays there because I still have a network connection via cell. If I turn on airplane mode, the fifth line will change to red and show no network.

So what's the problem? The External IP address fetched by wg(ipv4.jsonip.com,json,.ip) never gets updated after the first time. When I turn off WiFi it continues to display my old WiFi IP address not my new Cell IP address. And it won't update in any amount of time. I can even open it in KWGT and edit it and it won't update. If I tap on any line on the widget once (recall that I have them set to TEXT_UPDATE when touched) the external IP always updates right away to the new IP address.

I have KWGT's update mode set to Default, and as far as I can tell KWGT is whitelisted in my Samsung S21+ properly. Everything else seems to update as expected, including the weather and time Kwidget I made last week when I discovered KWGT.

So what can I do to get "wg(ipv4.jsonip.com,json,.ip)"" to update on its own in a timely manner? And why doesn't it now? (I did read a message from Frank Monza from 5 years ago about wg() caching the json, so maybe it's hopeless, but the code I use is in the documentation as the way to get an external IP address, so I still have hope). Is there any other way for me to get my current external IP address using a different method that will update in a timely manner? As I mentioned in a previous (unanswered) question, I have my own web site that displays the external IP if I could only figure out how to tell wg() to access it, if my update problem is with json caching. I can even make a URL that just returns the calling IP address as text, if that will work.

Thanks for any help!