HCSocket: do not connect automatically

This commit is contained in:
Trammell Hudson
2022-02-06 13:22:10 +01:00
parent 91e3348b13
commit e19f31290d
2 changed files with 9 additions and 4 deletions

View File

@@ -51,7 +51,8 @@ class HCSocket:
self.port = 443
self.uri = "wss://" + host + ":443/homeconnect"
self.reconnect()
# don't connect automatically so that debug etc can be set
#self.reconnect()
# restore the encryption state for a fresh connection
# this is only used by the HTTP connection
@@ -164,5 +165,6 @@ class HCSocket:
if buf is None:
return None
#print(now(), "RX:", buf)
if self.debug:
print(now(), "RX:", buf)
return buf

7
hcpy
View File

@@ -9,7 +9,7 @@ import io
from HCSocket import HCSocket, now
from HCDevice import HCDevice
if False:
if len(sys.argv) >= 1 and sys.argv[1] == 'clothes':
# clothes dryer
# RX:{'service': 'ro', 'version': 1}
# {'service': 'ei', 'version': 2}
@@ -34,13 +34,16 @@ while True:
ws = HCSocket(host, psk64, iv64)
dev = HCDevice(ws)
#ws.debug = True
ws.reconnect()
while True:
msg = dev.recv()
if msg is None:
break
if len(msg) > 0:
print(now(), msg)
except Exception as e:
print("ERROR", host, e, file=sys.stderr)