Fixed a bug within the SP2 class.
check_power and check_nightlight did not check to see if the payload was already an int before calling ord.
This commit is contained in:
		
							parent
							
								
									3b6b55ae73
								
							
						
					
					
						commit
						e724aec007
					
				
					 1 changed files with 18 additions and 6 deletions
				
			
		| 
						 | 
					@ -417,6 +417,12 @@ 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:]))
 | 
				
			||||||
 | 
					      if type(payload[0x4]) == int:
 | 
				
			||||||
 | 
					        if payload[0x4] == 1 or payload[0x4] == 3:
 | 
				
			||||||
 | 
					          state = True
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					          state = False
 | 
				
			||||||
 | 
					      else:
 | 
				
			||||||
        if ord(payload[0x4]) == 1 or ord(payload[0x4]) == 3:
 | 
					        if ord(payload[0x4]) == 1 or ord(payload[0x4]) == 3:
 | 
				
			||||||
          state = True
 | 
					          state = True
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					@ -431,6 +437,12 @@ 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:]))
 | 
				
			||||||
 | 
					      if type(payload[0x4]) == int:
 | 
				
			||||||
 | 
					        if payload[0x4] == 2 or payload[0x4] == 3:
 | 
				
			||||||
 | 
					          state = True
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					          state = False
 | 
				
			||||||
 | 
					      else:
 | 
				
			||||||
        if ord(payload[0x4]) == 2 or ord(payload[0x4]) == 3:
 | 
					        if ord(payload[0x4]) == 2 or ord(payload[0x4]) == 3:
 | 
				
			||||||
          state = True
 | 
					          state = True
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue