Hi everyone,
i have openhab running and recently got some “smart plugs” as a gift. Do you think there is some form of integration for this things: Amazon Link
I already checked there is some “alexa app”, wich is really simple and the whole thing only has one open port (10000/tcp).
Although it looks a lot like the Edimax protocol a short test using this script did not work: Github
So. Is there any chance I can get this to work without reversing the connection made by the “WeConn” App myself?
Thanks a lot
Edit: I discovered, that the plugs are sold as well with the names “Jinvoo” or “M.Way”. Seems to be all the same. Finding a binding would be really cool since these are cheap and easily available.
Thank you Vincent. Just so you know: Although all the apps seem to utilize the same kind of hardware the vendor has put their own software. Jinvoo and Sensibo seem to use a HTTP-Based method to interact with their hardware.
Weconn on the other side uses a completely proprietary binary protocol. On the upside: its unencrypted. The downside: Its binary and I cannot find specs. A Python implementation would be written pretty fast if I could get some more information on the protocol. I really don’t feel like reversing (for now).
I will play around a bit and maybe I can identify the important bits. But nevertheless: Using a script with these plugs will probably depend on manual identification of the plugs using tcpdump and so on…
here are my discoveries of those S171 SmartPlugs (I have 5 of them laying around unused, because there is no openhab implemention yet):
Discussion about protocol with basic on/off control - confirmed to work well but first you have to pair the plugs with “Weconn Plug” app to your wlan:
My Python3-implementation:
import socket
import time
# Thanks to: https://stackoverflow.com/a/31929689/5383897
global GET_INFO, OFF_CODE, ON_CODE, SET_AS_ADMIN
SET_AS_ADMIN = '0101100148000000010000005c6c5c6c0000000000000000000000000000000000000000000000000000000000000000xxxxxxxxxxxx0000feff0000xxxxxxxxxxxx000000000100'
ON_CODE = '0101010180000000010000005c6c5c6c0000000000000000000000000000000000000000000000000000000000000000xxxxxxxxxxxx0000000000000000000001000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
OFF_CODE = '0101010180000000010000005c6c5c6c0000000000000000000000000000000000000000000000000000000000000000xxxxxxxxxxxx0000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
GET_INFO = '0101030138000000010000005c6c5c6c0000000000000000000000000000000000000000000000000000000000000000xxxxxxxxxxxx0000'
ip = "192.168.210.129"
mac = "7C:DD:90:EE:83:E3"
def set(state, ip, mac):
if state: data = ON_CODE
else: data = OFF_CODE
HOST, PORT = ip, 9957
data = data.replace("xxxxxxxxxxxx", mac.replace(":",""))
data = bytes.fromhex(data)
# SOCK_DGRAM is the socket type to use for UDP sockets
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(data, (HOST, PORT))
def get(ip,mac):
HOST, PORT = ip, 9957
data = GET_INFO
data = data.replace("xxxxxxxxxxxx", mac.replace(":",""))
data = bytes.fromhex(data)
# SOCK_DGRAM is the socket type to use for UDP sockets
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(data, (HOST, PORT))
received = sock.recv(1424)
newoutput=""
output = received
output = str(output).split("\\x")
for a in output:
if a == "00":
pass
else:
newoutput += a
print(newoutput)