arupex / etekcity-smartplug

The Unlicense
18 stars 5 forks source link

Are other API endpoints discovered? #2

Closed keatontaylor closed 6 years ago

keatontaylor commented 6 years ago

I'm curious if the API endpoints for gathering the kWh used by device is known/accessible. Would be great to be able to pull that data into another app without the need to poll on specific intervals with your code and calculate usage.

dirwin517 commented 6 years ago

I mean if you're willing to setup a DNS you can run this proxy https://github.com/itsnotlupus/vesync-wsproxy but that doesn't seem like it will solve your use case. (note according to that proxy its about every 180 seconds)

I don't think voltson/vesync has any mechanism where you can subscribe or anything like that so you're kind of stuck with polling, it's not like its Wink using pubnub or something... sadly.

It's possible, I guess, that you can open a websocket to the server/device to get the data anytime it updates, but I wouldn't know, I too would love a mechanism to subscribe/listen to updates

keatontaylor commented 6 years ago

I think we may not be on the same page. The android/iOS app pulls kWh usage information for viewing down from the etekcity servers somehow I guess. (They seem to be collecting that data on 180 second intervals as seen above). My question was, what uri does the app use to pull that information down and what payload data does it require?

dirwin517 commented 6 years ago

Ahh the historic endpoint? its something like

POST /loadStat

headers { 
   tk : TOKEN,
   uniqueId : UserId,
   cid : deviceId
},
body : {
   cid : deviceId, 
   type : 'day', 
   date : '20171023',
   zoneOffset : -5 
}
dirwin517 commented 6 years ago

Just a note All I did to get this is Run Packet Capture software on my Android Phone (needs to have a Cert installed on port 4007 for decryption)

keatontaylor commented 6 years ago

Thanks, I went the route of decompiling the APK for the app. Basically has everything needed. Sorry for bugging you so much. :)