Closed HankB closed 7 years ago
I have no inside or formal knowledge about the device, but yes, state.ts encapsulates whatever I could figure out(/guess) about the websocket connection the devices establish with server2.vesync.com
The protocol is indeed in plain-text over a websocket, and consists of JSON payloads being sent back and forth. I think I sniffed it by running tcpdump on my main router, but ARP poisoning it would have probably worked too.
The commands that the device can send to the server are in handleDeviceMessage()
, the commands that can be sent to the device are in handleCloudMessage()
, and for each little case
statement, I've tried to associate an entry in messageSchemas
that defines the expected shape of each payload, very roughly.
Most of the commands were observed over the wire. A few are only listed in comments, because they were present as strings in the firmware, but I couldn't get them to appear in a network payload.
You're spot on about the security aspect, down to the ability to change the firmware, triggered over plain-text, with an unencrypted HTTP firmware download. That's something the proxy disables altogether, because even I have my limits. Everything else is unencrypted too, but it's what allows a dumb MitM proxy like this one to work, so I guess I can't complain too much.
I haven't really used the little plugs as a way to measure power consumption (it's more of an "ok google, turn on the living room lights" kind of thing for me), so I haven't strongly focused on the power measurements and alerts bits of the protocol. But, from memory and staring at the source right now:
Many thanks for the detailed and helpful reply. It looks like monitoring the /report message alone would provide the information I need. (And this device would work for my application.)
Question fully answered.
@HankB not sure if you are trying to just get the power/voltage from the unit, and don't necessarily need a proxy server, but I have a related project that can request the report
Thanks! That might be useful too. I might still want the proxy for the additional security (if I can configure my pfSense firewall to support the DNS requirements.)
On Mon, Oct 23, 2017 at 7:56 PM, Daniel Irwin notifications@github.com wrote:
@HankB https://github.com/hankb not sure if you are trying to just get the power/voltage from the unit, and don't necessarily need a proxy server, but I have a related project that can request the report
https://www.npmjs.com/package/etekcity-smartplug
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/itsnotlupus/vesync-wsproxy/issues/2#issuecomment-338838995, or mute the thread https://github.com/notifications/unsubscribe-auth/ADLOftcgkr41MKmJl6cnWiegwJ-3HmbFks5svTW7gaJpZM4QBreK .
-- '03 BMW F650CS - hers '98 Dakar K12RS - "BABY K" grew up. '93 R100R w/ Velorex 700 (MBD starts...) '95 Miata - "OUR LC" polish visor: apply squashed bugs, rinse, repeat Beautiful Sunny Winfield, Illinois
Do you have any information on the protocol? It looks like state.[js|ts] need to understand the content of the messages. (I have no javascript experience so I am unable to determine this directly by examining the code but it appears that these devices use a straightforward text protocol.)
I'd also like to confirm that these devices are not using encrypted (e.g. TLS, HTTPS etc.) communications. I see no mention of this or certificates in the code so I assume it is straight HTTP. I also see what looks like an HTTP firmware update URL which would reinforce this. (HTTP for OTA updates reminds me that the 'S' in 'IOT' stands for security. :-/ )
My desire is to use one of these devices to monitor power used by a freezer from a PC application so I can tell when the freezer door is open, the freezer is running continuously and contents are starting to thaw. :( Any help you can point me to regarding the protocol would be very helpful.
Thanks!