def aurora(): config = configparser.ConfigParser() config.read('aurora.ini') need_save = False if not 'device' in config: config['device'] = {} need_save = True if not 'ip' in config['device']: print('Finding device...') addrs = setup.find_auroras(seek_time=5) if addrs: config['device']['ip'] = addrs[0] need_save = True if 'ip' in config['device'] and not 'token' in config['device']: print('Authenticating...') config['device']['token'] = setup.generate_auth_token( config['device']['ip']) need_save = True a = AuroraWrapper(config) if not 'panel_positions' in config['device']: config['device']['rotation'] = '0' config['device']['panel_positions'] = json.dumps(a.panel_positions) need_save = True if need_save: config.write(open('aurora.ini', 'w')) return a
def connect_to_aurora(): ipAddressList = setup.find_auroras() print('Number of Auoras found: %i', len(ipAddressList)) print('Connecting to first available') IP = ipAddressList[0] raw_input('Press and hold reset for 5-7s and then enter any key') TOKEN = setup.generate_auth_token(IP)
def handle_nano_leaf_get_token_intent(self, message): silent_kw = message.data.get("SilentKeyword") # retrieve the token from the nanoleaf try: token = setup.generate_auth_token(self.settings["ipstring"]) LOG.info("Retrieved Aurora Token: " + token) except Exception as e: LOG.error(e) token = "Not Found" if not silent_kw: self.speak("The Token Was Not Found!") self.speak_dialog("token.response") self.settings["tokenstring"] = str(token) if token != "Not Found": if not silent_kw: self.speak('I have retrieved a new token')
# Creates link for current game's live feed. def get_live(url): default = "https://statsapi.web.nhl.com" liveURL = default + url return liveURL # Runs the goal light. def goal(): for x in range(0, 4): myAurora.rgb = [255, 0, 0] # Red sleep(1) # Red delay myAurora.rgb = [255, 255, 255] # White sleep(1) # White delay # Resets to previous colors and brightness. def reset(teamEffect, brightness): myAurora.effect = teamEffect myAurora.brightness = brightness if __name__ == "__main__": ########################## ipAddress = '192.168.0.10' ########################## token = setup.generate_auth_token(ipAddress) myAurora = Aurora(ipAddress, token) main()
from nanoleaf import setup, Aurora ips = setup.find_auroras(1) token = setup.generate_auth_token(ips[0]) print(token)
def GetToken(): token = setup.generate_auth_token(IPstring) print(token)
from nanoleaf import setup from nanoleaf import Aurora from time import sleep IPaddress = '192.168.0.10' token = setup.generate_auth_token(IPaddress) myAurora = Aurora(IPaddress, token) index = 0 while index < 4: myAurora.rgb = [255,0,0] # Red sleep(1) # Red delay myAurora.rgb = [255,255,255] # White sleep(1) # White delay index = index + 1 myAurora.effect = "Flames"