The power supply fans, accessory power and PoE ports on the XSmart System Tray can be controlled via a simple Python script.
Implement the following Python script:
######### Start Script ######## #!/usr/bin/python # # Usage example is at the bottom. # import urllib, urllib2, json class BoardController: def __init__(self, host, user=None, passwd=None): self.creds = {'username': user, 'password': passwd} self.host = host self.retried = False self.authToken = None def authenticate(self): url = "{host}/api/board/auth/login".format(host=self.host) data = json.dumps(self.creds) resp = json.loads(self.call(url, data)) self.authToken = resp['data']['token'] def call(self, url, data=None): def do(): req = urllib2.Request(url, data) req.add_header("Content-Type", "application/json") if self.authToken is not None: req.add_header("Authorization", "Bearer " + self.authToken) return urllib2.urlopen(req) try: return do().read() except urllib2.HTTPError, e: if e.code in (401, 403) and not self.retried: self.retried = True self.authenticate() return do().read() def component(self, name, state): url = "{host}/api/board/components/{name}/{state}".format(host=self.host, name=name, state=state) self.call(url, "{}") def on(self, component): self.component(component, "on") def off(self, component): self.component(component, "off") # ------------------------------------------------------------------------------------------------------------ # Board host is formatted as http://[IP_Address]:[HTTP_Port]. # Replace , and below with the actual Values. board = BoardController("http://:", "admin", "") # Component aliases have to be used as component names. They are listed in the API doc # in the Components section. Un-comment the ports to enable by removing the "#" in the lines below. "board.on" turns port on. # "board.off" turns port off. "Poe" is 24vdc passive PoE on switch port 4. "Apoe" is active PoE on # switch port 1. "fans" are the XSmart System Tray Circulation Fans. #board.off("vdc12_1") #board.off("vdc12_2") #board.off("vdc24_1") #board.off("vdc24_2") #board.off("poe") #board.on("apoe") #board.on("fans") # Continue with other components if needed... ######### END SCRIPT #############