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)
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)