sp2.get_energy
This commit is contained in:
		
							parent
							
								
									626b459b5b
								
							
						
					
					
						commit
						2160488da2
					
				
					 1 changed files with 10 additions and 0 deletions
				
			
		| 
						 | 
					@ -386,6 +386,16 @@ class sp2(device):
 | 
				
			||||||
        state = bool(ord(payload[0x4]))
 | 
					        state = bool(ord(payload[0x4]))
 | 
				
			||||||
      return state
 | 
					      return state
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def get_energy(self):
 | 
				
			||||||
 | 
					    packet = bytearray([8, 0, 254, 1, 5, 1, 0, 0, 0, 45])
 | 
				
			||||||
 | 
					    response = self.send_packet(0x6a, packet)
 | 
				
			||||||
 | 
					    err = response[0x22] | (response[0x23] << 8)
 | 
				
			||||||
 | 
					    if err == 0:
 | 
				
			||||||
 | 
					      payload = self.decrypt(bytes(response[0x38:]))
 | 
				
			||||||
 | 
					      energy = int(hex(ord(payload[7]) * 256 + ord(payload[6]))[2:]) + int(hex(ord(payload[5]))[2:])/100.0
 | 
				
			||||||
 | 
					      return energy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class a1(device):
 | 
					class a1(device):
 | 
				
			||||||
  def __init__ (self, host, mac):
 | 
					  def __init__ (self, host, mac):
 | 
				
			||||||
    device.__init__(self, host, mac)
 | 
					    device.__init__(self, host, mac)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue