Perspective IP Address for devices


I am trying to get the IP address of each perspective device to show up on a label of the device. This was pretty straight forward when using the vision tags, in vision applications.

I had called in and the attached code was provided. It is not working properly as it appears it’s grabbing the first available device IP. This same IP is then showing for all attached devices. They are not returning their own IP.

Is this a coding issue, or am I missing something else? Trying to set this up with perspective session properties is not very clear.

Do you see different addresses for the sessions in the gateway status (Status > Connections > Perspective Sessions)?

Yes, they are there.

My phone popped up with the correct IP, but the tablet is using the IP of the server. When I reloaded the tablet page, it is now showing the IP of the phone.

Try this for your transform script:

def transform(self, value, quality, timestamp):
	Transform the incoming value and return a result.

		self: A reference to the component this binding is configured on.
		value: The incoming value from the binding or the previous transform.
		quality: The quality code of the incoming value.
		timestamp: The timestamp of the incoming value as a java.util.Date
	session_infos = system.perspective.getSessionInfo()
	for session in session_infos:
		if ( == value):
			return session.clientAddress
	return "N/A"

I think your comparison of value to is wrong - it should be to

You will see “N/A” in the designer but should see addresses in real sessions.

It works! Thanks!

You can also use or self.getSession().getInfo() directly, and probably eliminate both the scripting call and the bulk of the transform.

1 Like