51 lines
1.1 KiB
Python
Executable File
51 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Contact a Bosh-Siemens Home Connect device
|
|
# todo: document how to extract the psk
|
|
import sys
|
|
import json
|
|
import re
|
|
import time
|
|
import io
|
|
from HCSocket import HCSocket, now
|
|
from HCDevice import HCDevice
|
|
|
|
if len(sys.argv) >= 1 and sys.argv[1] == 'clothes':
|
|
# clothes dryer
|
|
# RX:{'service': 'ro', 'version': 1}
|
|
# {'service': 'ei', 'version': 2}
|
|
# {'service': 'ci', 'version': 2}
|
|
# {'service': 'ni', 'version': 1}]}
|
|
host = '10.1.0.145'
|
|
psk64 = 'KlRQQyG8AkEfRFPr0v7vultz96zcal5lxj2fAc2ohaY'
|
|
iv64 = 'tTUvqcsBldtkhHvDwE2DpQ'
|
|
else:
|
|
# dish washer
|
|
# RX: {"service":"ci","version":3}
|
|
# {"service":"ei","version":2}
|
|
# {"service":"iz","version":1}
|
|
# {"service":"ni","version":1}
|
|
# {"service":"ro","version":1}]}
|
|
host = "10.1.0.133"
|
|
psk64 = "Dsgf2MZJ-ti85_00M1QT1HP5LgH82CaASYlMGdcuzcs="
|
|
iv64 = None # no iv == https
|
|
|
|
while True:
|
|
try:
|
|
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)
|
|
|
|
time.sleep(5)
|