def specific_action(self, action = "disarm"): if action.lower() == "arm_away": action_id = 3 elif action.lower() == "arm_home": action_id = 2 elif action.lower() == "disarm": action_id = 1 elif action.lower() == "arm_latchkey": action_id = 4 elif action.lower() == "arm_partition": action_id = 5 elif action.lower() == "arm_quick": action_id = 6 elif action.lower() == "arm_home_quick": action_id = 7 elif action.lower() == "arm_instant": action_id = 8 #elif action.lower() == "check_code": # action_id = 9 else: print "Wrong event was specified for TAG" sys.exit(0) pkt = SPC.device_cmd(self.serial, self.short_id, 4, 69, chr(self.bin_partitions) + chr(action_id) + self.bin_user_code) packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'arm_away' )
def tag_action(self, tag_id=0, action="away" ''',part_bitmap=0'''): action_id = 3 if action.lower() == "away": action_id = 3 elif action.lower() == "home": action_id = 2 elif action.lower() == "disarm": action_id = 1 elif action.lower() == "away_latchkey": action_id = 4 elif action.lower() == "arm_part": action_id = 5 elif action.lower() == "quick_away": action_id = 6 elif action.lower() == "quick_home": action_id = 7 elif action.lower() == "arm_instant": action_id = 8 elif action.lower() == "check_code": action_id = 9 else: print "Wrong event was specified for TAG" sys.exit(0) packet = SPC.device_cmd(self.serial, self.short_id, 4, 73, chr(self.bin_partitions) + chr(action_id) + '\x28\x00\x00\x00\x00' + chr(tag_id) + '\x00\x00\x00') packet_f2 = SPC.make_packet( 0xF2, 9, packet ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'tag_action={0}'.format(action) )
def enroll(self, customer_Mid = 0, customer_Did = 0): """ enroll device """ ser_num = SPC.dev_serial(int(self.serial)) #print SPC.hexdump(ser_num) rssi = '\x32' tx_power = '\x01' association_request_data = '\x00' #attached_device_information = '\x01'+self.type+'\x03\x14\x03\x00\x00' attached_device_information = '\x00'+self.type+'\x01\x14\x03\x00\x00' #Counting customer id manufacturing_information = chr(customer_Mid) + chr(customer_Did % 256) + chr(customer_Did / 256) rf_module_information = '\x00\x70\x09\x28\x03\x08\x01' host_protocol_message = SPC.make_host_packet( 0x41, ser_num + rssi + tx_power + association_request_data + '\x00' + SPC.str_len_plus_str(attached_device_information) + '\x01' + SPC.str_len_plus_str(manufacturing_information) + '\x02' + SPC.str_len_plus_str(rf_module_information) ) enroll_packet = '\x01' + host_protocol_message packet_f2 = SPC.make_packet( 0xF2, 13, enroll_packet ) # F2 protocol packet StrLog = '(enroll): {0}'.format( SPC.hexdump(packet_f2) ) print StrLog logging.debug( StrLog ) Cmd = SPC.packet( 11 ) self.SerPort.wait(Cmd, 'Start') #self.SerPort.ser.write(packet_f2) self.SendPacketTo_PortOrFile( packet_f2, 'enroll' ) self.SerPort.wait(Cmd, 'Check', 5) #print 'ShortID {0}, DevTypeNum {1}, DevNum {2}'.format( Cmd.ShortID, Cmd.DevTypeNum, Cmd.DevNum ) if Cmd.ShortID == -1: raise enroll_failed() self.short_id = Cmd.ShortID if Cmd.DevTypeNum == 0: self.DevType = 'RP' elif Cmd.DevTypeNum == 1: self.DevType = 'K' # KEYPAD_2WAY_TYPE elif Cmd.DevTypeNum == 2: self.DevType = 'SR' elif Cmd.DevTypeNum == 3: self.DevType = 'Z' elif Cmd.DevTypeNum == 4: self.DevType = 'K' # KEYPAD_1WAY_TYPE elif Cmd.DevTypeNum == 5: self.DevType = 'F' # KEYFOB_TYPE else: self.DevType = 'Unknown' self.DevNum = '%02d' % Cmd.DevNum if self.DevType == 'RP': self.DevNum = '%d' % Cmd.DevNum print 'After wait cmd #11. short_id: {0}, DevType: {1}, DevNum: {2}'.format( self.short_id, self.DevType, self.DevNum ) return
def set_temperature(self, iTemperature = -40.0): # Temperature: 0x00 - out of range (low) # 0xFC - out of range (high) # 0x01 = -40.0, 0x02 = -39.5, 0x03 = -39.0, ... , oxFA = +84.5, 0xFB = +85.0 TempHex = 0 iTemperature = float(iTemperature) if (iTemperature > 85.0): TempHex = 0xFC elif (iTemperature >= -40.0): TempHex = int(((iTemperature + 40.0) * 2) + 1) pkt = SPC.device_cmd(self.serial, self.short_id, 5, 24, chr(TempHex)) #send_host_cmd(pkt) packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'set_temperature={0}'.format(iTemperature) )
def disarm(self): pkt = SPC.device_cmd(self.serial, self.short_id, 4, 69, chr(self.bin_partitions)+'\x01'+self.bin_user_code) packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'disarm' )
def hello(self): #Seems to be Keep-alive message pkt_ka = SPC.device_cmd(self.serial, self.short_id, 5, 64, chr(0)) #send_host_cmd(pkt_ka) packet_f2 = SPC.make_packet( 0xF2, 9, pkt_ka ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'hello ka' )
def hot(self, IsOpen=1): # > 28(35) pkt = SPC.device_cmd(self.serial, self.short_id, 5, 24, chr(self.aTemp[int(not(IsOpen))])) packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'hot={0}'.format(IsOpen) )
def probe(self, IsOpen=1): # ? pkt = SPC.device_cmd(self.serial, self.short_id, 5, 50, chr(IsOpen)) packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'probe={0}'.format(IsOpen) )
def aux_button(self): pkt = SPC.device_cmd(self.serial, self.short_id, 4, 74, chr(1)) packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'aux_button' )
def open(self, IsOpen=1): pkt = SPC.device_cmd(self.serial, self.short_id, 5, 8, chr(IsOpen)) # Switch / Magnetic #pkt = '\x29\x30\x0B\x04\xF8\x00\x4A\xED\x04\x88\x23\xF9\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0B\xE4\x00\x2D\x02\x00\x00\x05\x03\x08\x01\x01\x7F\x0A' packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'open/close={0}'.format(IsOpen) )
def glass_break(self): pkt = SPC.device_cmd(self.serial, self.short_id, 5, 6, chr(2)) # Glass Break #send_host_cmd(pkt) packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'glass_break' )
def enable_partitions(self): pkt = SPC.device_cmd(self.serial, self.short_id, 4, 118, chr(self.h_partitions)) #send_host_cmd(pkt) packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'enable_partitions' )
def clean_me(self): pkt = SPC.device_cmd(self.serial, self.short_id, 5, 10, chr(2)) #send_host_cmd(pkt) packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'clean_me' )
def violate(self): pkt = SPC.device_cmd(self.serial, self.short_id, 5, 1, chr(2)) # Passive Motion ? #send_host_cmd(pkt) packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'violate' )
def supervision(self, IsOpen=1): pkt = SPC.device_cmd(self.serial, self.short_id, 5, 116, chr(IsOpen)) #ser_old.send_host_cmd(pkt) packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'supervision={0}'.format(IsOpen) )
def aux(self, IsOpen=1): bMask = 0xFF * IsOpen #Open all 8 auxilary inputs, according to mask 0b11111111 = 0xFF pkt = SPC.device_cmd(self.serial, self.short_id, 5, 17, chr(bMask)) # Magnet with Auxiliary Input #ser_old.send_host_cmd(pkt) packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'aux={0}'.format(IsOpen) )
def smoke_trouble(self, IsOpen=1): pkt = SPC.device_cmd(self.serial, self.short_id, 5, 46, chr(IsOpen)) packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'smoke_trouble={0}'.format(IsOpen) )
def panic(self, IsOpen=1): pkt = SPC.device_cmd(self.serial, self.short_id, 5, 33, chr(IsOpen)) packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'panic' )
def update(self): pkt = SPC.device_cmd(self.serial, self.short_id, 5, 253, chr(0)) packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'update={0}'.format(1) )
def emergency(self): pkt = SPC.device_cmd(self.serial, self.short_id, 5, 35, chr(1)) packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'emergency' )
def cold(self, IsOpen=1): # < 19 pkt = SPC.device_cmd(self.serial, self.short_id, 5, 24, chr(self.aTemp[IsOpen])) packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'cold={0}'.format(IsOpen) )
def trouble(self, IsOpen=1): pkt = SPC.device_cmd(self.serial, self.short_id, 5, 51, chr(IsOpen)) # CO Sensor Trouble #send_host_cmd(pkt) packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'trouble={0}'.format(IsOpen) )
def fire(self): pkt = SPC.device_cmd(self.serial, self.short_id, 5, 34, chr(1)) packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'fire' )
def jamming(self, IsOpen=1): pkt = SPC.device_cmd(self.serial, self.short_id, 5, 48, chr(IsOpen)) packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'jamming={0}'.format(IsOpen) )
def flood(self, IsOpen=1): pkt = SPC.device_cmd(self.serial, self.short_id, 5, 16, chr(IsOpen)) #send_host_cmd(pkt) packet_f2 = SPC.make_packet( 0xF2, 9, pkt ) # F2 protocol packet self.SendPacketTo_PortOrFile( packet_f2, 'gas_alert={0}'.format(IsOpen) )