Add serial and fw version property
This commit is contained in:
parent
38272656cf
commit
de7cbecb77
1 changed files with 25 additions and 14 deletions
39
sem6000.py
39
sem6000.py
|
@ -46,13 +46,6 @@ class SEMSocket():
|
||||||
msg = self.BTLEMessage(self, cmd, payload)
|
msg = self.BTLEMessage(self, cmd, payload)
|
||||||
msg.send()
|
msg.send()
|
||||||
|
|
||||||
def getSN(self):
|
|
||||||
# 15, 5, 17, 0, 0, 0, 18, -1, -1
|
|
||||||
cmd = bytearray([0x11])
|
|
||||||
payload = bytearray([0x00, 0x00, 0x00])
|
|
||||||
msg = self.BTLEMessage(self, cmd, payload)
|
|
||||||
msg.send()
|
|
||||||
|
|
||||||
def setStatus(self, status):
|
def setStatus(self, status):
|
||||||
# 0f 06 03 00 01 00 00 05 ff ff -> on
|
# 0f 06 03 00 01 00 00 05 ff ff -> on
|
||||||
# 0f 06 03 00 00 00 00 04 ff ff -> off
|
# 0f 06 03 00 00 00 00 04 ff ff -> off
|
||||||
|
@ -127,8 +120,28 @@ class SEMSocket():
|
||||||
#for i in range(7):
|
#for i in range(7):
|
||||||
# payload[i+1] = 0x00
|
# payload[i+1] = 0x00
|
||||||
#msg = self.BTLEMessage(self, cmd, payload)
|
#msg = self.BTLEMessage(self, cmd, payload)
|
||||||
if not success: raise self.SendMessageFailed
|
if not success:
|
||||||
if self.name != newName: raise self.NotLoggedIn
|
raise self.SendMessageFailed
|
||||||
|
if self.name != newName:
|
||||||
|
raise self.NotLoggedIn
|
||||||
|
|
||||||
|
@property
|
||||||
|
def serial(self):
|
||||||
|
# 15, 5, 17, 0, 0, 0, 18, -1, -1
|
||||||
|
cmd = bytearray([0x11])
|
||||||
|
payload = bytearray([0x00, 0x00, 0x00])
|
||||||
|
msg = self.BTLEMessage(self, cmd, payload)
|
||||||
|
success = msg.send()
|
||||||
|
if not success:
|
||||||
|
raise self.SendMessageFailed
|
||||||
|
return self._serial
|
||||||
|
|
||||||
|
@property
|
||||||
|
def firmware_version(self):
|
||||||
|
char_value = self._version_char.read()
|
||||||
|
major = char_value[11]
|
||||||
|
minor = char_value[12]
|
||||||
|
return "{}.{}".format(major, minor)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def connected(self):
|
def connected(self):
|
||||||
|
@ -158,10 +171,6 @@ class SEMSocket():
|
||||||
if self.connected == True:
|
if self.connected == True:
|
||||||
self._btle_device.disconnect()
|
self._btle_device.disconnect()
|
||||||
|
|
||||||
#def SynVer(self):
|
|
||||||
# print("SynVer")
|
|
||||||
# self.read_char.read_value()
|
|
||||||
|
|
||||||
#def ______RESET(self):
|
#def ______RESET(self):
|
||||||
# #15, 5, 16, 0, 0, 0, 17, -1, -1 ??? maybe reset?
|
# #15, 5, 16, 0, 0, 0, 17, -1, -1 ??? maybe reset?
|
||||||
# pass
|
# pass
|
||||||
|
@ -271,7 +280,7 @@ class SEMSocket():
|
||||||
self.__btle_device.power_factor = power / (voltage * current)
|
self.__btle_device.power_factor = power / (voltage * current)
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
self.__btle_device.power_factor = None
|
self.__btle_device.power_factor = None
|
||||||
elif message_type == 0x10:
|
elif message_type == 0x10: #plug settings response
|
||||||
self.__btle_device.default_charge = (data[5] / 100)
|
self.__btle_device.default_charge = (data[5] / 100)
|
||||||
self.__btle_device.night_charge = (data[6] / 100)
|
self.__btle_device.night_charge = (data[6] / 100)
|
||||||
night_charge_start_time = int((data[7] << 8 | data[8]) / 60)
|
night_charge_start_time = int((data[7] << 8 | data[8]) / 60)
|
||||||
|
@ -281,6 +290,8 @@ class SEMSocket():
|
||||||
self.__btle_device.night_mode = not bool(data[11])
|
self.__btle_device.night_mode = not bool(data[11])
|
||||||
self.__btle_device.icon_idx = data[12]
|
self.__btle_device.icon_idx = data[12]
|
||||||
self.__btle_device.power_protect = (data[13] << 8 | data[14])
|
self.__btle_device.power_protect = (data[13] << 8 | data[14])
|
||||||
|
elif message_type == 0x11: #serial number response
|
||||||
|
self.__btle_device._serial = data[-16:].decode("UTF-8")
|
||||||
elif message_type == 0x17: #authentication related response
|
elif message_type == 0x17: #authentication related response
|
||||||
if data[5] == 0x00 or data[5] == 0x01:
|
if data[5] == 0x00 or data[5] == 0x01:
|
||||||
# in theory the fifth byte indicates a login attempt response (0) or a response to a password change (1)
|
# in theory the fifth byte indicates a login attempt response (0) or a response to a password change (1)
|
||||||
|
|
Loading…
Reference in a new issue