Experimental RF code
This commit is contained in:
		
							parent
							
								
									8bc67af6d7
								
							
						
					
					
						commit
						dd6eb8767e
					
				
					 2 changed files with 65 additions and 1 deletions
				
			
		
							
								
								
									
										37
									
								
								README.md
									
										
									
									
									
								
							
							
						
						
									
										37
									
								
								README.md
									
										
									
									
									
								
							| 
						 | 
					@ -37,6 +37,23 @@ Enter learning mode:
 | 
				
			||||||
devices[0].enter_learning()
 | 
					devices[0].enter_learning()
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Sweep RF frequencies:
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					devices[0].sweep_frequency()
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Check whether a frequency has been found:
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					found = devices[0].check_frequency()
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					(This will return True if the RM has locked onto a frequency, False otherwise)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Attempt to learn an RF packet:
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					found = devices[0].find_rf_packet()
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					(This will return True if a packet has been found, False otherwise)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Obtain an IR or RF packet while in learning mode:
 | 
					Obtain an IR or RF packet while in learning mode:
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
ir_packet = devices[0].check_data()
 | 
					ir_packet = devices[0].check_data()
 | 
				
			||||||
| 
						 | 
					@ -77,3 +94,23 @@ Check power state on a SmartPowerStrip:
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
state = devices[0].check_power()
 | 
					state = devices[0].check_power()
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Learning RF packets
 | 
				
			||||||
 | 
					-------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					timeout = 10
 | 
				
			||||||
 | 
					devices[0].sweep_frequency()
 | 
				
			||||||
 | 
					# Hold down the rf button
 | 
				
			||||||
 | 
					for i in range(0, timeout):
 | 
				
			||||||
 | 
					  found = devices[0].check_frequency()
 | 
				
			||||||
 | 
					  if found == True:
 | 
				
			||||||
 | 
					    break
 | 
				
			||||||
 | 
					  time.sleep(1)
 | 
				
			||||||
 | 
					# Tap the rf button
 | 
				
			||||||
 | 
					for i in range(0, timeout):
 | 
				
			||||||
 | 
					  found = devices[0].find_rf_packet()
 | 
				
			||||||
 | 
					  if found == True:
 | 
				
			||||||
 | 
					    break
 | 
				
			||||||
 | 
					  time.sleep(1)
 | 
				
			||||||
 | 
					# Obtain the code
 | 
				
			||||||
 | 
					code = devices[0].check_data()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -501,6 +501,33 @@ class rm(device):
 | 
				
			||||||
    packet[0] = 3
 | 
					    packet[0] = 3
 | 
				
			||||||
    self.send_packet(0x6a, packet)
 | 
					    self.send_packet(0x6a, packet)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def sweep_frequency(self):
 | 
				
			||||||
 | 
					    packet = bytearray(16)
 | 
				
			||||||
 | 
					    packet[0] = 0x19;
 | 
				
			||||||
 | 
					    self.send_packet(0x6a, packet)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def check_frequency(self):
 | 
				
			||||||
 | 
					    packet = bytearray(16)
 | 
				
			||||||
 | 
					    packet[0] = 0x1a
 | 
				
			||||||
 | 
					    response = self.send_packet(0x6a, packet)
 | 
				
			||||||
 | 
					    err = response[0x22] | (response[0x23] << 8)
 | 
				
			||||||
 | 
					    if err == 0:
 | 
				
			||||||
 | 
					      payload = self.decrypt(bytes(response[0x38:]))
 | 
				
			||||||
 | 
					      if payload[0x04] == 1:
 | 
				
			||||||
 | 
					          return True
 | 
				
			||||||
 | 
					    return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def find_rf_packet(self):
 | 
				
			||||||
 | 
					    packet = bytearray(16)
 | 
				
			||||||
 | 
					    packet[0] = 0x1b
 | 
				
			||||||
 | 
					    response = self.send_packet(0x6a, packet)
 | 
				
			||||||
 | 
					    err = response[0x22] | (response[0x23] << 8)
 | 
				
			||||||
 | 
					    if err == 0:
 | 
				
			||||||
 | 
					      payload = self.decrypt(bytes(response[0x38:]))
 | 
				
			||||||
 | 
					      if payload[0x04] == 1:
 | 
				
			||||||
 | 
					          return True
 | 
				
			||||||
 | 
					    return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def check_temperature(self):
 | 
					  def check_temperature(self):
 | 
				
			||||||
    packet = bytearray(16)
 | 
					    packet = bytearray(16)
 | 
				
			||||||
    packet[0] = 1
 | 
					    packet[0] = 1
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue