Skip to content

Instantly share code, notes, and snippets.

@jbrzozoski
Created June 3, 2020 21:17
Show Gist options
  • Save jbrzozoski/a18d801a277f955ff6b244c09e6e9d14 to your computer and use it in GitHub Desktop.
Save jbrzozoski/a18d801a277f955ff6b244c09e6e9d14 to your computer and use it in GitHub Desktop.
Scriptable way to find MQTT/SparkPlug sub-devices in Ignition since MQTT Engine doesn't provide a list
def findDevicesBelow(path, maxdepth):
browse_results = system.tag.browse(path, {})
for item in browse_results.getResults():
if item['name'] == 'Device Info':
device_reference = str(item['fullPath']).replace('[MQTT Engine]Edge Nodes/','').replace('/Device Info','')
print(device_reference)
if (item['hasChildren'] == True) and (maxdepth > 0):
findDevicesBelow(item['fullPath'], (maxdepth-1))
# Searching everyone:
findDevicesBelow(path='[MQTT Engine]Edge Nodes', maxdepth=3)
# Searching one group:
findDevicesBelow(path='[MQTT Engine]Edge Nodes/demo', maxdepth=2)
# Searching one node:
findDevicesBelow(path='[MQTT Engine]Edge Nodes/demo/352656100926891', maxdepth=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment