Add experimental support for smartplugs
This adds a set_power() call that should work for the SP2 - unsure whether it will work for the SP3.
This commit is contained in:
		
							parent
							
								
									61efc7ae29
								
							
						
					
					
						commit
						c174e40f59
					
				
					 2 changed files with 11 additions and 0 deletions
				
			
		|  | @ -43,3 +43,8 @@ Obtain sensor data from an A1: | ||||||
| ``` | ``` | ||||||
| data = devices[0].check_sensors() | data = devices[0].check_sensors() | ||||||
| ``` | ``` | ||||||
|  | 
 | ||||||
|  | Set power state on an SP2/SP3 (0 for off, 1 for on): | ||||||
|  | ``` | ||||||
|  | devices[0].set_power(1) | ||||||
|  | ``` | ||||||
|  | @ -180,6 +180,12 @@ class device: | ||||||
|     response = self.cs.recvfrom(1024) |     response = self.cs.recvfrom(1024) | ||||||
|     return response[0] |     return response[0] | ||||||
| 
 | 
 | ||||||
|  |   def set_power(self, state): | ||||||
|  |     packet = bytearray(8) | ||||||
|  |     packet[0] = 2 | ||||||
|  |     packet[4] = state | ||||||
|  |     self.send_packet(0x6a, packet) | ||||||
|  | 
 | ||||||
|   def send_data(self, data): |   def send_data(self, data): | ||||||
|     packet = bytearray([0x02, 0x00, 0x00, 0x00]) |     packet = bytearray([0x02, 0x00, 0x00, 0x00]) | ||||||
|     packet += data |     packet += data | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue