How can I clear niscache and/or reset the robot_device_id of every active robot in my UIM domain?


Article ID: 208622


Updated On:


DX Infrastructure Management


Sometimes (usually due to issues caused by robot cloning) it may be necessary to reset the robot_device_id and clear niscache on every active robot in the entire domain.


The following NAS script can be used to reset every robot's device ID by issuing the _reset_robot_device_id_and_restart callback to every robot found.  (It has also been attached as a file to the bottom of this KB.)

It skips any robot which has the hub probe installed, so if you need to do hubs you should do them manually (otherwise, this script would restart the hubs and cause the robots underneath it to fail to be reset).

Robots must be active and able to communicate with the controller probe for this script to hit them.

The script will print a list of robots as it goes.


How to implement/run it:

- Open NAS GUI, navigate to Auto-Operator, Scripts

- Create a new script

- paste the contents of the below script and hit the green Play button


hubdomain = "MyUIMDomain" -- put your UIM Domain here

-- Get hub addresses into an array called hubs
function get_hubs()
     local hubs = {}
     local gethubs = nimbus.request("hub","gethubs")
     for row,hub in pairs(gethubs.hublist) do
  if (string.match(hub.addr, hubdomain)) then
          hubs[] = hub.addr
   -- print(hub.addr .. " added to list")
    --skip hubs that are not in the domain
     return hubs

-- Fetch a hub's robotlist into table "Robots" as: "robot name", "robot address"
function get_hub_robots(hub_address)
     local robots = {}
     getrobots, rc = nimbus.request(hub_address, "getrobots")
     if (rc ~= 0) then
          return "error"
     for x, robot in pairs(getrobots.robotlist) do
          if (robot.status == 0) then
   local probes, rc2 = nimbus.request(robot.addr.."/controller", "port_list")
   if (not probes["hub"]) then
               robots[] = robot.addr
     -- print("not adding hub: " ..robot.addr)
     return robots

-- take a robot as input and reset its device ID
function reset_id(hub, robot, robot_address)
     print(robot .. " is the current robot")
         local probes, rc = nimbus.request(robot_address.."/controller", "_reset_device_id_and_restart")
   print("resetting " ..robot_address)

if rc == 0 then
          print("success " ..robot_address)
          print ("failed to reset " ..robot_address)

-- Main
local hubs = get_hubs()
for name, address in pairs(hubs) do
     local robots = get_hub_robots(address)
     if (robots == "error") then
          print("failure for hub " ..address)
          for robotname, robotaddress in pairs(robots) do
               reset_id(name, robotname, robotaddress)


Additional Information

NOTE: This script intentionally does not clear niscache on the hubs themselves; those should be done manually if necessary.  Most of the time it is not needed since hubs are not generally hosting monitoring probes.


Alternate method:  How do I clean niscache on all active robots from the command line?


1613506359938__reset_all_robot_id.lua get_app