Client IP Address in Script

Hi All,

I have a number of popup screens that are triggered to open from a Tag Value Change. At the moment these popups open on all clients. I’d like to only have the popup open on the relevant client. I have tried to use the Client IP address as a way to isolate the popup to a specific client, however it does not seem to work. Please see my Scripts below. Can anyone help get this to work?

Before Change (Was working and opening on all clients)

if currentValue.value==1:
	if previousValue.value==0: 
		system.nav.openWindow('Popups/Prompts/B_Prompt_2')
		system.nav.centerWindow('Popups/Prompts/B_Prompt_2')

After Change (Not working at all)

if "[System]Client/Network/IPAddress" is "169.254.223.201":
	if currentValue.value==1:
		if previousValue.value==0: 
			system.nav.openWindow('Popups/Prompts/B_Prompt_2')
			system.nav.centerWindow('Popups/Prompts/B_Prompt_2')

You will need to read the IP Address tag to use it in your script; at the moment, your code is checking that the string “[System]Client/Network/IPAddress” is an instance of the literal string “169.254.223.201”; which is what’s failing.

Switch to using system.tag.read() and the rest of the code should work:

if system.tag.read("[System]Client/Network/IPAddress").value == "169.254.223.201":
	if currentValue.value==1:
		if previousValue.value==0: 
			system.nav.openWindow('Popups/Prompts/B_Prompt_2')
			system.nav.centerWindow('Popups/Prompts/B_Prompt_2')
3 Likes

Excellent, Ill give it a go

Thanks for the help,

Just in case this doesn’t work for you, I’ve found linux clients do not report the correct IP address, they report the loopback address. If you have linux clients or may have in the future it might be worth basing this off of hostname which is reported correctly from any OS.

1 Like

I agree on using Hostname.

Also, there is a nice method for doing this described in Inductive University.
https://inductiveuniversity.com/video/custom-security?r=/course/security

1 Like