Merge pull request #149 from deel77/master
Default support for python3 in get_energy() for SP2
This commit is contained in:
		
						commit
						00cc79daee
					
				
					 1 changed files with 4 additions and 1 deletions
				
			
		| 
						 | 
					@ -407,7 +407,10 @@ class sp2(device):
 | 
				
			||||||
    err = response[0x22] | (response[0x23] << 8)
 | 
					    err = response[0x22] | (response[0x23] << 8)
 | 
				
			||||||
    if err == 0:
 | 
					    if err == 0:
 | 
				
			||||||
      payload = self.decrypt(bytes(response[0x38:]))
 | 
					      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
 | 
					      if type(payload[0x07]) == int:
 | 
				
			||||||
 | 
					        energy = int(hex(payload[0x07] * 256 + payload[0x06])[2:]) + int(hex(payload[0x05])[2:])/100.0
 | 
				
			||||||
 | 
					      else:
 | 
				
			||||||
 | 
					        energy = int(hex(ord(payload[0x07]) * 256 + ord(payload[0x06]))[2:]) + int(hex(ord(payload[0x05]))[2:])/100.0
 | 
				
			||||||
      return energy
 | 
					      return energy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue