Example #1
0
 def action_list_adapters(self):
     '''
     Find connected CEC adapters
     '''
     self.adapters = cec.list_adapters()
     meta = {'device': self.adapter}
     if self.location:
         meta.update({'location': self.location})
     self.sendEvent('adapters', {'adapters': {'value': self.adapters}}, meta)
Example #2
0
 def action_list_adapters(self):
     '''
     Find connected CEC adapters
     '''
     self.adapters = cec.list_adapters()
     meta = {'device': self.adapter}
     if self.location:
         meta.update({'location': self.location})
     self.sendEvent('adapters', {'adapters': {
         'value': self.adapters
     }}, meta)
Example #3
0
 def onInit(self):
     self.adapters = cec.list_adapters()
     if len(self.adapters) < 1:
         sys.exit('No CEC adapters found')
     else:
         self.adapter = self.adapters[0]
         log.info('Found adapter(s): %s' % str(self.adapters))
         log.info('Using adapter %s' % self.adapter)
         self.sendEvent('current_adapter', {'id': 0})
     cec.init(self.adapter)
     # Service config
     self.interval = self.config.get('interval') or 60
     self.location = self.config.get('location')
     self.cur_service = None
Example #4
0
 def onInit(self):
     self.adapters = cec.list_adapters()
     if len(self.adapters) < 1:
         sys.exit('No CEC adapters found')
     else:
         self.adapter = self.adapters[0]
         log.info('Found adapter(s): %s' % str(self.adapters))
         log.info('Using adapter %s' % self.adapter)
         self.sendEvent('current_adapter', {'id': 0})
     cec.init(self.adapter)
     # Service config
     self.interval = self.config.get('interval') or 60
     self.location = self.config.get('location')
     self.cur_service = None
Example #5
0
 def init_cec(self):
     """Method to init cec adapter. Return True if cec initiated successfully"""
     if (self.initiated): return
     adapter = cec.list_adapters()
     if len(adapter) >= 1:
         try:
             cec.init()
             self.adapter = adapter.pop()
             self.devices = cec.list_devices()
             self.initiated = True
             cec.add_callback(cb, cec.EVENT_ALL & ~cec.EVENT_LOG)
             cec.add_callback(log_cb, cec.EVENT_LOG)
         except:
             self.initiated = False
Example #6
0
 def init_cec(self):
     """Method to init cec adapter. Return True if cec initiated successfully"""
     if self.initiated:
         return
     adapter = cec.list_adapters()
     if len(adapter) >= 1:
         try:
             cec.init()
             self.adapter = adapter.pop()
             self.devices = cec.list_devices()
             self.initiated = True
             cec.add_callback(cb, cec.EVENT_ALL & ~cec.EVENT_LOG)
             cec.add_callback(log_cb, cec.EVENT_LOG)
         except:
             self.initiated = False
Example #7
0
#!/usr/bin/env python

import time
import cec

adapters = cec.list_adapters()

if len(adapters) > 0:
   adapter = adapters[0]
   cec.init(adapter)

   d = cec.Device(0)

   # d.standby()
   # d.power_on()


   d.set_av_input(01)

 # echo "tx 4F 82 10 00" | cec-client -s -d 1
Example #8
0
# when a broadcast is received.
p.add(u)

# Create our FauxMo virtual switch devices
for one_faux in FAUXMOS:
    if len(one_faux) == 2:
        # a fixed port wasn't specified, use a dynamic one
        one_faux.append(0)
    switch = fauxmo(one_faux[0],
                    u,
                    p,
                    None,
                    one_faux[2],
                    action_handler=one_faux[1])

adapters = cec.list_adapters()
dbg(adapters)

if len(adapters) > 0:
    adapter = adapters[0]
    cec.init(adapter)
else:
    cec.init()

tv = cec.Device(0)

dbg("Entering main loop\n")

while True:
    try:
        # Allow time for a ctrl-c to stop the process