コード例 #1
0
 def __init__(self,
              hp=('', 0),
              mac='',
              root=None,
              name='',
              key=PK_KEY,
              password='',
              deviceid='',
              clientsessionid='',
              hp2=('', 0)):
     Device.__init__(self, hp, mac, root, name)
     ManTimerManager.__init__(self, root)
     IrManager.__init__(self, hp, mac, root, name)
     self.key = key
     self.fid = 0
     if len(clientsessionid) == 0:
         self.clientSessionId = generatestring(32)
     else:
         self.clientSessionId = clientsessionid
     if root is None:
         self.password = password
         self.deviceId = deviceid
         self.localPort = hp2[1]
         self.localIp = hp2[0]
     else:
         self.password = root.attributes['password'].value
         self.deviceId = root.attributes['deviceId'].value
         self.localPort = root.attributes['localPort'].value
         self.localIp = root.attributes['localIp'].value
コード例 #2
0
ファイル: devicesamsungctl.py プロジェクト: p3g4asus/orvpy
 def __init__(self, hp=('', 0), mac='', root=None, name='', conf=''):
     Device.__init__(self, hp, name, root, name)
     ManTimerManager.__init__(self, root)
     IrManager.__init__(self, hp, mac, root, name)
     self.remote = None
     self.last_init = 0
     self.fill_ir_list()
     if root is None:
         self.conffile = conf
     else:
         self.conffile = root.attributes['conffile'].value
     self.config = None
     self.offt = -1
     self.init_device()
コード例 #3
0
ファイル: devicerm.py プロジェクト: p3g4asus/orvpy
 def get_action_payload(self, action):
     if isinstance(action, ActionLearnir):
         return action.irdata
     elif isinstance(action, ActionEmitir):
         return action.irdata
     else:
         return IrManager.get_action_payload(self, action)
コード例 #4
0
ファイル: devicerm.py プロジェクト: p3g4asus/orvpy
 def send_action(self, actionexec, action, pay):
     if isinstance(action, (ActionEmitir, ActionLearnir)):
         if self.inner is None:
             self.inner_init()
             if self.inner is None:
                 return action.exec_handler(None, None)
         data = None
         timeout = action.get_timeout()
         if timeout is None or timeout < 0:
             timeout = actionexec.udpmanager.timeout
         if timeout < 0:
             timeout = None
         self.inner.timeout = timeout
         try:
             if isinstance(action, ActionLearnir):
                 response = self.inner.enter_learning()
                 if response is None:
                     rv = None
                 else:
                     rv = response[0x22] | (response[0x23] << 8)
                     time.sleep(self.inner.timeout)
                     data2 = self.inner.check_data()
                     if data2 is None or isinstance(data2, int):
                         data = {'irc': None, 'attrs': None}
                         rv = data2
                     else:
                         if data2[0:1] == b'\x26':
                             freq = 38000
                         elif data2[0:1] == b'\xb2':
                             freq = 433000000
                         elif data2[0:1] == b'\xd7':
                             freq = 315000000
                         else:
                             freq = 0
                         data = {'irc': data2, 'attrs': {'freq': freq}}
             else:
                 _LOGGER.info(
                     f"S({self.inner.host[0]}:{self.inner.host[1]})-> {tohexs(pay[0])}")
                 response = self.inner.send_data(pay[0])
                 if response is None:
                     rv = None
                 else:
                     rv = response[0x22] | (response[0x23] << 8)
         except:  # noqa: E722
             _LOGGER.warning(f"{traceback.format_exc()}")
             rv = None
         if rv is None or rv != 0:
             # Forzo futura riconnessione
             _LOGGER.info(
                 "Blackbeam %s error: will try to reconnect" % self.name)
             self.inner = None
             if rv is not None:
                 rv += 600
         else:
             rv += 1
         return action.exec_handler(rv, data)
     else:
         return IrManager.send_action(self, actionexec, action, pay)
コード例 #5
0
ファイル: deviceudp.py プロジェクト: p3g4asus/orvpy
 def __init__(self,
              hp=('', 0),
              mac='',
              root=None,
              timeout=DEFAULT_RESUBSCRIPTION_TIMEOUT,
              name='',
              sec1900=0,
              lsa_timeout=DEFAULT_RESUBSCRIPTION_STIMEOUT):
     DeviceUDP.__init__(self,
                        hp=hp,
                        mac=mac,
                        root=root,
                        timeout=timeout,
                        name=name,
                        sec1900=sec1900,
                        lsa_timeout=lsa_timeout)
     ManTimerManager.__init__(self, root)
     IrManager.__init__(self, hp, mac, root, name)
コード例 #6
0
 def __init__(self,
              hp=('', 0),
              mac='',
              root=None,
              name='',
              location='',
              deviceobj=None):
     DeviceUpnp.__init__(self, hp, mac, root, name, location, deviceobj)
     ManTimerManager.__init__(self, root)
     IrManager.__init__(self, hp, mac, root, name)
     self.a = None
     if root is not None and root.hasAttribute('remote_name'):
         self.remote_name = root.attributes['remote_name'].value
         self.ir_load = True
     else:
         self.ir_load = False
         self.remote_name = self.name
     self.offt = -1
コード例 #7
0
 def to_dict(self):
     rv = IrManager.to_dict(self)
     rv.update({
         'key': self.key,
         'password': self.password,
         'deviceId': self.deviceId,
         'localIp': self.localIp,
         'localPort': str(self.localPort)
     })
     return rv
コード例 #8
0
 def send_action(self, actionexec, action, pay):
     if isinstance(action, (ActionEmitir, ActionLearnir)):
         buf = SendBufferTimer(pay, action, (self.host, self.port),
                               self.mac, actionexec)
         if actionexec.tcpserver.schedulewrite(buf):
             return RV_ASYNCH_EXEC
         else:
             return None
     else:
         return IrManager.send_action(self, actionexec, action, pay)
コード例 #9
0
ファイル: devicesamsungctl.py プロジェクト: p3g4asus/orvpy
 def send_action(self, actionexec, action, pay):
     if isinstance(action, ActionEmitir):
         try:
             if self.init_device():
                 _LOGGER.info(self.name + " sending " + pay[0])
                 if not self.remote.control(pay[0]):
                     rv = 5
                     self.destroy_device()
                 else:
                     rv = 1
         except:  # noqa: E722
             _LOGGER.warning(f"{traceback.format_exc()}")
             self.destroy_device()
             rv = None
         return action.exec_handler(rv, None)
     else:
         return IrManager.send_action(self, actionexec, action, pay)
コード例 #10
0
 def get_action_payload(self, action):
     if isinstance(action, ActionLearnir):
         if len(action.irdata):
             fk = action.irdata[action.irdata.find(':') + 1:].translate(
                 None, '!@#$/\\+-_')
             if len(fk) < 2:
                 fk = generatestring(5)
             cmd = collections.OrderedDict()
             cmd['fKey'] = fk
             cmd['fid'] = self.get_fid()
             cmd['uid'] = tohexs(self.mac)
             cmd['cmd'] = 25
             cmd['order'] = 'ir control'
             cmd['lastUpdateTime'] = int(
                 Device.unix_time_millis(datetime.now()) / 1000.0)
             cmd['clientSessionId'] = self.clientSessionId
             cmd['serial'] = None
             cmd['deviceId'] = self.deviceId
             cmd['fName'] = fk
             return cmd
     elif isinstance(action, ActionEmitir):
         if len(action.irdata):
             cmd = collections.OrderedDict()
             cmd['uid'] = tohexs(self.mac)
             cmd['defaultResponse'] = 1
             cmd['delayTime'] = 0
             cmd['qualityOfService'] = 1
             cmd['clientSessionId'] = self.clientSessionId
             cmd.update(action.irdata[2])
             cmd['pluseNum'] = action.irdata[0].count(',') + 1
             cmd['value1'] = 0
             cmd['value2'] = 0
             cmd['value3'] = 0
             cmd['value4'] = 0
             cmd['cmd'] = 15
             cmd['order'] = 'ir control'
             # cmd['userName'] = '******'
             cmd['pluseData'] = action.irdata[0]
             cmd['serial'] = None
             cmd['deviceId'] = self.deviceId
             return cmd
     return IrManager.get_action_payload(self, action)
コード例 #11
0
 def xml_element(self, root, flag=0):
     el = IrManager.xml_element(self, root, flag)
     ManTimerManager.xml_element(self, el, flag)
     return el
コード例 #12
0
 def mqtt_on_message(self, client, userdata, msg):
     DeviceUpnp.mqtt_on_message(self, client, userdata, msg)
     IrManager.mqtt_on_message(self, client, userdata, msg)
コード例 #13
0
 def copy_extra_from(self, already_saved_device):
     DeviceUpnp.copy_extra_from(self, already_saved_device)
     IrManager.copy_extra_from(self, already_saved_device)
     ManTimerManager.copy_extra_from(self, already_saved_device)
     self.remote_name = already_saved_device.remote_name
コード例 #14
0
ファイル: devicerm.py プロジェクト: p3g4asus/orvpy
 def __init__(self, hp=('', 0), mac='', root=None, name='', inner=None):
     Device.__init__(self, hp, mac, root, name)
     ManTimerManager.__init__(self, root)
     IrManager.__init__(self, hp, mac, root, name)
     self.offt = -1
     self.inner = inner
コード例 #15
0
 def to_json(self):
     rv = IrManager.to_json(self)
     rv.update(ManTimerManager.to_json(self))
     return rv
コード例 #16
0
ファイル: deviceudp.py プロジェクト: p3g4asus/orvpy
 def copy_extra_from(self, already_saved_device):
     DeviceUDP.copy_extra_from(self, already_saved_device)
     IrManager.copy_extra_from(self, already_saved_device)
     ManTimerManager.copy_extra_from(self, already_saved_device)
コード例 #17
0
 def copy_extra_from(self, already_saved_device):
     savep = self.port
     IrManager.copy_extra_from(self, already_saved_device)
     ManTimerManager.copy_extra_from(self, already_saved_device)
     self.deviceId = already_saved_device.deviceId
     self.port = savep
コード例 #18
0
 def on_stop(self):
     IrManager.on_stop(self)
     ManTimerManager.on_stop(self)
コード例 #19
0
 def to_json(self):
     rv = DeviceUpnp.to_json(self)
     rv.update(IrManager.to_json(self))
     rv.update(ManTimerManager.to_json(self))
     return rv
コード例 #20
0
ファイル: devicerm.py プロジェクト: p3g4asus/orvpy
 def to_dict(self):
     return IrManager.to_dict(self)