Device Enable on remote gateway?

Hey folks,

We’re running a remote gateway as our tag provider, and I would like to allow maintenance to enable / disable devices on the remote gateway from the client.

I can use system.device.setDeviceEnabled(device, bool) on the local gateway, but cannot figure out how to pass this command to the remote gateway.

Is this possible?


You can use system.util.sendMessage to send messages between gateways over the gateway network - which you would need to combine with a message handler on the receiving gateway that would then execute the setDeviceEnabled command.

1 Like

Thanks PG, I’ll give it a shot and see where I wind up.

Here’s where I wound up. I was having hard time getting the bool to convert properly, thus the if/elif statement in the message handler. If you have any recommendations to improve the script or handle that boolean, I’d be happy to hear it.

Message Script

security = 0

for row in dataIn:
  if row['Rolename'] == admin or row['Rolename'] == mechanic:

if security == 1: 
	device = event.source.parent.getComponent('Container').getComponent('Label').text
	state = event.source.parent.getComponent('Container').getComponent('Dropdown').selectedValue
	project= "Transaction_Groups"
	messageHandler = "deviceMessages"
	message = {'device': device, 'state': state, 'security': security}
	scope = "G"
	server = ["Ignition"]
	system.util.sendMessage(project=project, messageHandler=messageHandler, payload=message, scope=scope, remoteServers=server)
	system.gui.warningBox('User not authorized to make changes', 'Error')

Message Handling

	first = payload['first']
	second = payload['second']
	if second > 0:
		bool = 1
	elif second < 1:
		bool = 0
	system.tag.write('Gateway_First', first)
	system.tag.write('Gateway_Second', bool)
	system.device.setDeviceEnabled(first, bool)