Compare commits
7 commits
features/r
...
master
Author | SHA1 | Date | |
---|---|---|---|
sqozz | 8c372513d8 | ||
sqozz | de79c2bca5 | ||
sqozz | 06f2cfe33e | ||
sqozz | df9a355ee8 | ||
sqozz | 95983d464f | ||
sqozz | 3755f26081 | ||
sqozz | f488869f3d |
29
example.py
29
example.py
|
@ -11,22 +11,25 @@ while True:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
try:
|
try:
|
||||||
if socket == None:
|
if socket == None:
|
||||||
print("Connecting...")
|
print("Connecting... ", end="")
|
||||||
|
|
||||||
# auto_reconnect_timeout enabled auto reconnect if sending a command fails. Valid values:
|
|
||||||
# None (default): everything that fails throws NotConnectedException's
|
|
||||||
# -1: infinite retries
|
|
||||||
# integer: seconds before exception is thrown
|
|
||||||
|
|
||||||
socket = SEMSocket('f0:c7:7f:0d:e7:17')
|
socket = SEMSocket('f0:c7:7f:0d:e7:17')
|
||||||
print("Connected.")
|
print("Success!")
|
||||||
|
print("You're now connected to: {} (Icon: {})".format(socket.name, socket.icons[0]))
|
||||||
#socket.login("1337")
|
if socket.login("1234") and socket.authenticated:
|
||||||
#socket.changePassword("1234")
|
print("Login successful!")
|
||||||
#socket.login("1234")
|
socket.getSynConfig()
|
||||||
|
print()
|
||||||
|
print("=== Tariff settings ===")
|
||||||
|
print("Default charge:", socket.default_charge)
|
||||||
|
print("Night charge:", socket.night_charge)
|
||||||
|
print("Night tariff from {} to {}".format(socket.night_charge_start_time.tm_hour, socket.night_charge_end_time.tm_hour))
|
||||||
|
print()
|
||||||
|
print("=== Other settings ===")
|
||||||
|
print("Night mode:", "active" if socket.night_mode else "inactive")
|
||||||
|
print("Power protection:", socket.power_protect)
|
||||||
|
print()
|
||||||
|
|
||||||
socket.getStatus()
|
socket.getStatus()
|
||||||
socket.setStatus(True)
|
|
||||||
print("=== {} ({}) ===".format(socket.mac_address, "on" if socket.powered else "off"))
|
print("=== {} ({}) ===".format(socket.mac_address, "on" if socket.powered else "off"))
|
||||||
print("\t{}V {}A → {}W@{}Hz (PF: {})".format(socket.voltage, socket.current, socket.power, socket.frequency, socket.power_factor))
|
print("\t{}V {}A → {}W@{}Hz (PF: {})".format(socket.voltage, socket.current, socket.power, socket.frequency, socket.power_factor))
|
||||||
except (SEMSocket.NotConnectedException, bluepy.btle.BTLEDisconnectError, BrokenPipeError):
|
except (SEMSocket.NotConnectedException, bluepy.btle.BTLEDisconnectError, BrokenPipeError):
|
||||||
|
|
22
sem6000.py
22
sem6000.py
|
@ -97,17 +97,19 @@ class SEMSocket():
|
||||||
self.authenticated = self.authenticated and success
|
self.authenticated = self.authenticated and success
|
||||||
return success
|
return success
|
||||||
|
|
||||||
def clearHistory(self):
|
def setIcon(self, iconIdx):
|
||||||
cmd = bytearray([0x15])
|
cmd = bytearray([0x0f])
|
||||||
payload = bytearray([0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00])
|
payload = bytearray([0x00, 0x03, iconIdx, 0x00, 0x00, 0x00, 0x00])
|
||||||
msg = self.BTLEMessage(self, cmd, payload)
|
msg = self.BTLEMessage(self, cmd, payload)
|
||||||
|
|
||||||
success = msg.send()
|
success = msg.send()
|
||||||
return success
|
return success
|
||||||
|
|
||||||
def factoryReset(self):
|
def enableLED(self, status):
|
||||||
cmd = bytearray([0x15])
|
cmd = bytearray([0x0f])
|
||||||
payload = bytearray([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
|
payload = bytearray([0x00, 0x05, status, 0x00, 0x00, 0x00, 0x00])
|
||||||
msg = self.BTLEMessage(self, cmd, payload)
|
msg = self.BTLEMessage(self, cmd, payload)
|
||||||
|
|
||||||
success = msg.send()
|
success = msg.send()
|
||||||
return success
|
return success
|
||||||
|
|
||||||
|
@ -315,7 +317,13 @@ class SEMSocket():
|
||||||
else:
|
else:
|
||||||
print("5th byte of login-response is > 1:", data)
|
print("5th byte of login-response is > 1:", data)
|
||||||
elif message_type == 0x0f: #set icon response
|
elif message_type == 0x0f: #set icon response
|
||||||
if not data[3:] == b'\x00\x03\x00\x13\xff\xff':
|
if data[3:6] == b'\x00\x03\x00':
|
||||||
|
# LED set successfully
|
||||||
|
pass
|
||||||
|
elif data[3:6] == b'\x00\x05\x00':
|
||||||
|
# Icon set successfully
|
||||||
|
pass
|
||||||
|
else:
|
||||||
print("Unknown response for setting icon: ", end="")
|
print("Unknown response for setting icon: ", end="")
|
||||||
print(data[3:])
|
print(data[3:])
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue