forked from sqozz/sem6000
Make current config availible as attributes
This commit is contained in:
parent
80c0c5dd4b
commit
9b49abd66e
33
sem6000.py
33
sem6000.py
|
@ -4,6 +4,7 @@ import datetime
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
class SEMSocket():
|
class SEMSocket():
|
||||||
|
icons = ["plug", "speaker", "flatscreen", "desk lamp", "oven", "kitchen machine", "canning pot", "stanging lamp", "kettle", "mixer", "hanging lamp", "toaster", "washing machine", "fan", "fridge", "iron", "printer", "monitor", "notebook", "workstation", "video recorder", "curling iron", "heater"]
|
||||||
password = "0000"
|
password = "0000"
|
||||||
powered = False
|
powered = False
|
||||||
voltage = 0
|
voltage = 0
|
||||||
|
@ -15,6 +16,7 @@ class SEMSocket():
|
||||||
mac_address = ""
|
mac_address = ""
|
||||||
custom_service = None
|
custom_service = None
|
||||||
authenticated = False
|
authenticated = False
|
||||||
|
_icon_idx = None
|
||||||
_name = None
|
_name = None
|
||||||
_read_char = None
|
_read_char = None
|
||||||
_write_char = None
|
_write_char = None
|
||||||
|
@ -163,26 +165,10 @@ class SEMSocket():
|
||||||
# print("SynVer")
|
# print("SynVer")
|
||||||
# self.read_char.read_value()
|
# self.read_char.read_value()
|
||||||
|
|
||||||
#def GetSynConfig(self):
|
|
||||||
# print("GetSynConfig")
|
|
||||||
# #15, 5, 16, 0, 0, 0, 17, -1, -1
|
|
||||||
# self.write_char.write_value(bytearray(b'\x0f\x05\x10\x00\x00\x00\x11\xff\xff'))
|
|
||||||
|
|
||||||
#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
|
||||||
|
|
||||||
#def GetSN(self):
|
|
||||||
# print("GetSN")
|
|
||||||
# #15, 5, 17, 0, 0, 0, 18, -1, -1
|
|
||||||
# self.write_char.write_value(bytearray(b'\x0f\x05\x11\x00\x00\x00\x12\xff\xff'))
|
|
||||||
|
|
||||||
# self.SynVer()
|
|
||||||
# self.notify_char.enable_notifications()
|
|
||||||
# self.Login("1337")
|
|
||||||
# self.GetSynConfig()
|
|
||||||
# #self.GetSN()
|
|
||||||
|
|
||||||
class NotConnectedException(Exception):
|
class NotConnectedException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -289,12 +275,15 @@ class SEMSocket():
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
self.__btle_device.power_factor = None
|
self.__btle_device.power_factor = None
|
||||||
elif message_type == 0x10:
|
elif message_type == 0x10:
|
||||||
print("ordinaryPrice:", data[5] / 100)
|
self.__btle_device.default_charge = (data[5] / 100)
|
||||||
print("valleyPrice", data[6] / 100)
|
self.__btle_device.night_charge = (data[6] / 100)
|
||||||
print("valleyStart", (data[7] << 8 | data[8]) / 60)
|
night_charge_start_time = int((data[7] << 8 | data[8]) / 60)
|
||||||
print("valleyEnd", (data[9] << 8 | data[10]) / 60)
|
night_charge_end_time = int((data[9] << 8 | data[10]) / 60)
|
||||||
icons = ["plug", "speaker", "flatscreen", "desk lamp", "oven", "kitchen machine", "canning pot", "stanging lamp", "kettle", "mixer", "hanging lamp", "toaster", "washing machine", "fan", "fridge", "iron", "printer", "monitor", "notebook", "workstation", "video recorder", "curling iron", "heater"]
|
self.__btle_device.night_charge_start_time = time.strptime(str(night_charge_start_time), "%H")
|
||||||
print("iconName", data[12])
|
self.__btle_device.night_charge_end_time = time.strptime(str(night_charge_end_time), "%H")
|
||||||
|
self.__btle_device.night_mode = not bool(data[11])
|
||||||
|
self.__btle_device.icon_idx = data[12]
|
||||||
|
self.__btle_device.power_protect = (data[13] << 8 | data[14])
|
||||||
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