def __init__(self, name, callback_function, queue, threadlist): """ This class puts it all together, creating a state machine and a socket thread that calls state changes for received commands """ HomeAutomationQueueThread.__init__(self, name, callback_function, queue, threadlist) logging.info('LEDMatrixCore initialized') self.rgbmatrix = Adafruit_RGBmatrix(32, 1) self.rgbm = RGBMatrix(self.rgbmatrix, self.queue, self.threadlist) self.transitions = [ { 'trigger': 'SetPixel', 'source': 'idle', 'dest': 'settingpixel' }, { 'trigger': 'Clear', 'source': 'idle', 'dest': 'clearing' }, { 'trigger': 'AudioVisualize', 'source': 'idle', 'dest': 'audiovisualizing' }, { 'trigger': 'StopAudioVisualize', 'source': 'audiovisualizing', 'dest': 'stopaudiovisualizing' }, { 'trigger': 'SetMatrixFromImgBase64', 'source': 'idle', 'dest': 'settingmatrixfromimage' }, { 'trigger': 'Screensaver', 'source': 'idle', 'dest': 'screensaver' }, { 'trigger': 'SplashScreen', 'source': 'idle', 'dest': 'splashscreen' }, ] self.states=['idle', 'settingpixel', 'clearing', 'audiovisualizing', 'settingmatrixfromimage', 'stopaudiovisualizing', 'screensaver', 'splashscreen'] self.machine = Machine(model = self.rgbm, states = self.states, transitions = self.transitions, initial = 'idle') lmssu = LEDMatrixSocketServiceUDP(name='SocketService', callback_function=None, rgbmatrix=self.rgbmatrix, rgbm=self.rgbm, queue=queue) #lmssu.start() threadlist.append(lmssu) #hacore should start() it afterwards global CurrentInstance CurrentInstance = self
def __init__(self, name, callback_function, queue, threadlist, baseurl=None): HomeAutomationQueueThread.__init__(self, name, callback_function, queue, threadlist) #if baseurl == None: # baseurl = HA_JOINTSPACE_URI #self.baseurl = baseurl self.Serial = serial.Serial('/dev/ttyACM0', 9600, timeout=2)
def __init__(self, name, callback_function, queue, threadlist): HomeAutomationQueueThread.__init__(self, name, callback_function, queue, threadlist) self.env = Environment() self.lights = {} self.relevant_light_attrs = ('name', 'on', 'saturation', 'hue', 'brightness') self.cache = [] self.lock = threading.Lock()
def __init__(self, name, callback_function, queue, threadlist, bridgeip=None): HomeAutomationQueueThread.__init__(self, name, callback_function, queue, threadlist) if bridgeip == None: bridgeip = HA_PHILIPS_HUE_BRIDGE self.bridgeip = bridgeip self.bridge = None self.lights = {} self.relevant_light_attrs = ('name', 'on', 'saturation', 'hue', 'brightness') self.cache = [] self.lock = threading.Lock()
def __init__(self, name, callback_function, queue, threadlist, modules): global SharedQueue # deprecated? SharedQueue = queue global ThreadList ThreadList = threadlist self.modules = modules HomeAutomationQueueThread.__init__(self, name = name, callback_function = callback_function, queue = queue, threadlist = threadlist) self.load_ws_definitions()
def __init__(self, name, callback_function, queue, threadlist): HomeAutomationQueueThread.__init__(self, name, callback_function, queue, threadlist) self.devices = []
def __init__(self, name, callback_function, queue, threadlist): HomeAutomationQueueThread.__init__(self, name, callback_function, queue, threadlist)
def __init__(self, name, callback_function, queue, threadlist): """ This class puts it all together, creating a state machine and a socket thread that calls state changes for received commands """ HomeAutomationQueueThread.__init__(self, name, callback_function, queue, threadlist) logging.info('LEDMatrixCore initialized') self.rgbmatrix = Adafruit_RGBmatrix(32, 1) self.rgbm = RGBMatrix(self.rgbmatrix, self.queue, self.threadlist) self.transitions = [ { 'trigger': 'SetPixel', 'source': 'idle', 'dest': 'settingpixel' }, { 'trigger': 'Clear', 'source': 'idle', 'dest': 'clearing' }, { 'trigger': 'AudioVisualize', 'source': 'idle', 'dest': 'audiovisualizing' }, { 'trigger': 'StopAudioVisualize', 'source': 'audiovisualizing', 'dest': 'stopaudiovisualizing' }, { 'trigger': 'SetMatrixFromImgBase64', 'source': 'idle', 'dest': 'settingmatrixfromimage' }, { 'trigger': 'Screensaver', 'source': 'idle', 'dest': 'screensaver' }, { 'trigger': 'SplashScreen', 'source': 'idle', 'dest': 'splashscreen' }, ] self.states = [ 'idle', 'settingpixel', 'clearing', 'audiovisualizing', 'settingmatrixfromimage', 'stopaudiovisualizing', 'screensaver', 'splashscreen' ] self.machine = Machine(model=self.rgbm, states=self.states, transitions=self.transitions, initial='idle') lmssu = LEDMatrixSocketServiceUDP(name='SocketService', callback_function=None, rgbmatrix=self.rgbmatrix, rgbm=self.rgbm, queue=queue) #lmssu.start() threadlist.append(lmssu) #hacore should start() it afterwards global CurrentInstance CurrentInstance = self
def __init__(self, name, callback_function, queue, threadlist, modules): HomeAutomationQueueThread.__init__(self, name=name, callback_function=callback_function, queue=queue, threadlist=threadlist) global WebServiceDefinitions WebServiceDefinitions = WebServiceDefinitionList() for mod in modules: wsdef = modules[mod].cls.webservice_definitions if wsdef is not None: if type(wsdef) == types.FunctionType: logging.debug('wsdef is function, trying to execute') wsdef_addition = wsdef( ) # extend submodules or other dynamic collection if type(wsdef_addition) == types.ListType: wsdef = wsdef_addition elif type(wsdef) != types.ListType: wsdef = [] if hasattr(modules[mod].cls, '_webservice_definitions'): # automatically created through decorator wsdef_internal = getattr(modules[mod].cls, '_webservice_definitions') wsdef.extend(wsdef_internal) logging.info('added decorator definitions') WebServiceDefinitions.extend(wsdef) logging.debug( str(len(wsdef)) + ' definitions loaded from module ' + mod) for wsdi in wsdef: try: logging.info('wsdi ' + str(wsdi)) _c = getattr(modules[mod].module, wsdi.cl) if wsdi.methodname is not None and wsdi.argnames is not None: c = copy.deepcopy( _c ) # make a copy so that the following overwrites aren't inherited on the next iter wsdi.cl = wsdi.cl + '_' + wsdi.methodname # modify the class instance name reference of our copied class # logging.info(wsdi.cl + ' - attaching methodname and argnames ' + wsdi.methodname) # c.methodname = wsdi.methodname # c.argnames = wsdi.argnames globals()[wsdi.cl] = c # just a little hacky # logging.info('resolved to: ' + `c`) else: globals()[wsdi.cl] = _c # just a little hacky # logging.info('resolved to: ' + `_c`) except AttributeError: logging.info( 'Unexpected exception caught while loading WSD ' + wsdi.cl + ' from module ' + mod + ' - ' + traceback.format_exc()) logging.info(str(len(WebServiceDefinitions)) + ' definitions loaded.') global SharedQueue # deprecated? SharedQueue = queue global ThreadList ThreadList = threadlist webservice_hawebservice_init(SharedQueue=SharedQueue, ThreadList=ThreadList)
def __init__(self, name, callback_function, queue, threadlist): webservice_class_instances_add(self.get_class_name(), self) self.timestopcheck = time.time() HomeAutomationQueueThread.__init__(self, name, callback_function, queue, threadlist)
def __init__(self, name, callback_function, queue, threadlist, modules): HomeAutomationQueueThread.__init__( self, name=name, callback_function=callback_function, queue=queue, threadlist=threadlist ) global WebServiceDefinitions WebServiceDefinitions = WebServiceDefinitionList() for mod in modules: wsdef = modules[mod].cls.webservice_definitions if wsdef is not None: if type(wsdef) == types.FunctionType: logging.debug("wsdef is function, trying to execute") wsdef_addition = wsdef() # extend submodules or other dynamic collection if type(wsdef_addition) == types.ListType: wsdef = wsdef_addition elif type(wsdef) != types.ListType: wsdef = [] if hasattr(modules[mod].cls, "_webservice_definitions"): # automatically created through decorator wsdef_internal = getattr(modules[mod].cls, "_webservice_definitions") wsdef.extend(wsdef_internal) logging.info("added decorator definitions") WebServiceDefinitions.extend(wsdef) logging.debug(str(len(wsdef)) + " definitions loaded from module " + mod) for wsdi in wsdef: try: logging.info("wsdi " + str(wsdi)) _c = getattr(modules[mod].module, wsdi.cl) if wsdi.methodname is not None and wsdi.argnames is not None: c = copy.deepcopy( _c ) # make a copy so that the following overwrites aren't inherited on the next iter wsdi.cl = ( wsdi.cl + "_" + wsdi.methodname ) # modify the class instance name reference of our copied class # logging.info(wsdi.cl + ' - attaching methodname and argnames ' + wsdi.methodname) # c.methodname = wsdi.methodname # c.argnames = wsdi.argnames globals()[wsdi.cl] = c # just a little hacky # logging.info('resolved to: ' + `c`) else: globals()[wsdi.cl] = _c # just a little hacky # logging.info('resolved to: ' + `_c`) except AttributeError: logging.info( "Unexpected exception caught while loading WSD " + wsdi.cl + " from module " + mod + " - " + traceback.format_exc() ) logging.info(str(len(WebServiceDefinitions)) + " definitions loaded.") global SharedQueue # deprecated? SharedQueue = queue global ThreadList ThreadList = threadlist webservice_hawebservice_init(SharedQueue=SharedQueue, ThreadList=ThreadList)