项目作者: waigx

项目描述 :
A Python Library Controls Nanoleaf Light Panels (formerly Aurora)
高级语言: Python
项目地址: git://github.com/waigx/aurora_core.git
创建时间: 2017-12-02T21:16:40Z
项目社区:https://github.com/waigx/aurora_core

开源协议:GNU General Public License v3.0

下载


aurora_core

A Python Library Controls Nanoleaf Light Panels (formerly Aurora)

Usage

  • The libaray contains three main classes: Discover, Manager, and Aurora. After getting an Aurora instance, the usage should be straightforward:
  1. aurora.get.name() #return the name of the panel cluster
  2. aurora.set.on(False) #turn off the panel cluster
  3. aurora.set.effect('Rainfall') #set effect to "Rainfall"
  • To get an Aurora instance, the easiest way is using the Discover class:
  1. from aurora_core import Discover
  2. def authed_handler(aurora): #the callback function once a new aurora got authed
  3. print aurora.get.name(), aurora.get.serial()
  4. aurora.set.brightness(50)
  5. discover = Discover([], authed_handler) #[] is all auroras need to be ignored
  6. discover.start()

You have to hold the power button for ~5 seconds to give this script permission to access the Light Panels. This script will set the cluster brightness to 50% after finishing authorization.

  • Apparently no one want to authenticate/permit access everytime. Manager provides basic Aurora object management, including data persistence:
  1. from aurora_core import Manager
  2. manager = Manager('example_db') #local data store at `example_db`
  3. for aurora in manager.auroras(): #print out all local aurora names
  4. print aurora.get.name()
  5. manager.save(new_aurora) #save new_aurora to local
  6. manager.delete(new_aurora) #delete new_aurora from local

Please note that the Manager is using pickle internally, so no encryption will be applied on the local storage.