Today I think I knew how Peter Buga can control Sonoff / eWeLink smart devices.
Download and install Python 2.x or 3.x from https://www.python.org/downloads
Go to sonoff-debug.py
To run this just, cd
to the location of the script and:
python sonoff-debug.py -u 'email or phone-number username' -p 'password'
> devices.json
you will get a file named “devices.json”
this is one of my Sonoff POW R2 but the file contain all Sonoffs in my Home.
if you take a close look to the file you will find all the variables power, voltage, current, rssi, device id, and more…
[
{
"__v": 0,
"_id": "[hidden]",
"apikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"brandLogoUrl": "",
"brandName": "Sonoff",
"createdAt": "xxxx-xx-xxxxx:xx:xx.xxx",
"deviceStatus": "",
"deviceUrl": "",
"deviceid": "[hidden]",
"devicekey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"extra": {
"_id": "[hidden]",
"extra": {
"apmac": "xx:xx:xx:xx:xx:xx",
"brandId": "58e5f344baeb368720e25469",
"description": "WO1881982",
"mac": "xx:xx:xx:xx:xx:xx",
"manufacturer": "\u6df1\u5733\u677e\u8bfa\u6280\u672f\u6709\u9650\u516c\u53f8",
"model": "PSC-B67-GL",
"modelInfo": "5a2e1ae50cf772f92c342ef6",
"ui": "\u529f\u7387\u68c0\u6d4b\u63d2\u5ea7\u8fc7\u8f7d\u544a\u8b66",
"uiid": 32
}
},
"group": "",
"groups": [],
"ip": "[hidden]",
"location": "",
"name": "[hidden]",,
"offlineTime": "xxxx-xx-xxxxx:xx:xx.xxx",
"online": true,
"onlineTime": "xxxx-xx-xxxxx:xx:xx.xxx",
"params": {
"alarmCValue": [
-1,
10
],
"alarmPValue": [
-1,
-1
],
"alarmType": "pcv",
"alarmVValue": [
-1,
240
],
"bindInfos": {
"alexa": [
"xxxxxx-xxxx-xxxxx-xxxxx-xxxxxxxxxxxxx_26ca1996a20e8bd63617axxxxxxxxxxxxxxxxxxxx"
],
"gaction": [
"xxxxxxxxxx-xxxxx-xxxxxx-xxxxxxxxxxx_ewelink-google-home-v1"
]
},
"current": "0.28",
"endTime": "xxxx-xx-xxxxx:xx:xx.xxx",
"fwVersion": "2.8.0",
"hundredDaysKwh": "get",
"init": 1,
"oneKwh": "stop",
"partnerApikey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"power": "59.81",
"rssi": -71,
"sledOnline": "on",
"staMac": "xx:xx:xx:xx:xx:xx",
"startTime": "xxxx-xx-xxxxx:xx:xx.xxx",
"startup": "stay",
"switch": "on",
"timeZone": 2,
"voltage": "234.57"
},
"productModel": "Pow_R2",
"settings": {
"alarmNotify": 1,
"opsHistory": 1,
"opsNotify": 0
},
"sharedTo": [
{
"nickname": "Pico",
"note": "",
"permit": 15,
"phoneNumber": "[hidden]",,
"shareTime": 1551282301502
}
],
"showBrand": true,
"type": "10",
"uiid": 32
},
to remove all hidden information in this file go to sonoff-debug.py and comment
data = re.sub(r'"phoneNumber": ".*"', '"phoneNumber": "[hidden]",', data)
data = re.sub(r'"name": ".*"', '"name": "[hidden]",', data)
data = re.sub(r'"ip": ".*",', '"ip": "[hidden]",', data)
data = re.sub(r'"deviceid": ".*",', '"deviceid": "[hidden]",', data)
data = re.sub(r'"_id": ".*",', '"_id": "[hidden]",', data)
data = re.sub(r'"\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2}"', '"xx:xx:xx:xx:xx:xx"', data)
data = re.sub(r'"\w{8}-\w{4}-\w{4}-\w{4}-\w{12}"', '"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"', data)
data = re.sub(r'"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+Z"', '"xxxx-xx-xxxxx:xx:xx.xxx"', data)
before running the script .
at end I think https://community.home-assistant.io/u/peterbuga has done a great job
and here is what he wrote:
the data that you see/get, it’s exactly what I get from eWeLink API and nothing more.
I recently found out that sensor data is propagated over websocket messages too, not just basic requests (as it now), when I do find the time I’ll update the component to take advantage of this and hopefully an overall better output