Changing OPC device information with scripting, for main/backup comms IP

Hey all,
Our client is having us replace an existing system where we get data from many RTUs.

These RTUs have two communication methods, a wired connection and backup wireless 4G comms.

I’m trying to write a script that will change the IP to the backup if the comms fail, and this is fine as I can use system.device.setDeviceHostname(X, Y). However, there doesn’t seem to be a way to check the current IP the device is using. So my script can’t know if the device is or isn’t on the backup already.

I could make some tags that store an IP value for each station as it’s written, but I’d prefer the script to check before making changes, as someone might edit it manually.

system.device.listDevices() is a bit useless as it only gives very basic information, but not IP or port.

Anyone had this issue and found a way of doing it.

Thanks everyone!