Sonoff /eWeLink component for original firmware

@quarx thanks for sharing the scripts :+1:

i have to admit, the MQTT part is not complicated at all but in the same time is hard to ignore the fact that trying to evolve your idea you will inevitably run in HA-like code rules and here’s why: if you want to keep a good device support you/me will have to split the ewelink login/devices part into a separated library (just like HA requires), after that there’s the devices exposing part to MQTT (again, just like HA) and last but not least you need to write some automation with these new toys (sounds familiar?)
i get why you choose to move everything into simpler scripts, i’ve done it the same for a while (before this i was controlling the ewelink devices with Alexa API but i decided to take it up a notch after i discovered HA, because it was too messy and hard to maintain)
also, i’m pretty sure by now someone else already forked this component for openhab and/or domoticz :thinking: if not, i might take it up as a challenge once i’m content enough of the state of current component.

@hus2020 i would appreciate if you could open an issue on github and provide the output of all the states of the device of this debug script as mentioned here https://github.com/peterbuga/HASS-sonoff-ewelink/tree/master/sonoff-debug
(so basically you need to run it at least 3-4 times and name to output logs accordingly)

i’ll try to get to it, there are still some other issues in the queue though :persevere:

Hi @peterbuga
I thank you for your great work.
I am new here
all my Sonoff are working fine on Home Assistant
I know nothing about python language that’s why I am asking if it is possible to print the sonoff-debug >devices.json without hiding all secret data to keep it safe as a detail reference.

	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)

thanks

@Ze_Pico just comment/remove the above mentioned lines

It works
thanks

@peterbuga
I am using an application called BLYNK for years now because of its nice GUI.
to see my sonoff data on Blynk I change the sonoff original firmware to TASMOTA to be able to use MQTT publish and subscribe message protocol.
Hacking the new ITEAD Studio - Sonoff S31
I am asking if there is an easy way to communicate with BLYNK app like you did with HA without changing the sonoff FW
thanks a lot


Blynk GUI

@Ze_Pico read the last 10+ or so replies from here regarding the MQTT part.

tl;dr: unless you want to fork the code and go in a direction similar with what @quarx started, i would not hold my breath for MQTT support (or better said MQTT-bridge) anytime soon.

i see you’re comfortable with flashing sonoff devices, why not stick with that?

I thank you

@e-budianto could you explain what and how you done to solve this problem*? I´m have the same issue, I tried a lot of things/times (reinstall rpi2 and rp3, with hassio and raspbian + HA).
I really appreciate and thank you your help.

Note: I tried… pip3 install uuid / pip3 install websocket-client / change dns at resolv.conf. But not working yet.

  • requests.exceptions.ConnectionError: HTTPSConnectionPool(host=‘us-api.coolkit.cc’, port=8080): Max retries exceeded with url: /api/user/login (Caused by NewConnectionError(’<urllib3.connection.VerifiedHTTPSConnection object at 0x733416f0>: Failed to establish a new connection: [Errno -3] Try again’))

If pihole is blocking a connection, then the site you are trying to connect to is probably on your pihole’s blacklist, ie it is a known advert or tracking domain/host.

The whitelisting in pihole.

1 Like

@nickrout thank you.
At this point I don’t want understand, I’ll just accept!
I did not have the pihole instaled. So I instaled and add “us-api.coolkit.cc” as whitelist and after that, everything works. :upside_down_face:

glad you finally make it!, we have same error message but slightly different case, in my case is because i was running pihole and change dns routing of my router to my pihole, this component somewhat considered i was using proxy, and it couldn’t access internet, but I can access coolkit from web browser, so definitely not because of whitelist/blacklist problem. In you case it seems somewhere has blocked access to us-api.coolkit.cc

1 Like

That makes no sense.

Hi gents, I have just upgraded to 0.89 and it looks like the custom components folder structure has changed. I tried to move the whole set of scripts inside a “sonoff” directory but it did not make the trick. Any clues?

Your answer is found here:

1 Like

Many thanks.

Knipsel

does anyone know what to do?

hi, i have a sonoff basic with tasmota firmware, where i can find a original firmware bin? anyone knows?
thanks

@Rodolfo_Vieira
You should backup your official firmware before flashing Tasmota, not any other firmware bin file will work.

your request it’s a highly unusual one around here :sweat_smile:
next, i might say something terrible stupid or maybe drop the answer you’re looking for!
while developing this component i realised that the ewelink app at every login queries the attached devices for new update data under this format:

{  
   "rtnCode":0,
   "upgradeInfoList":[  
      {  
         "bizRtnCode":10001,
         "deviceid":"10002xxxxx",
         "model":"ITA-GZ1-GL",
         "version":"2.6.1",
         "upgradeText":"2018-12-27 •	Feature:Factory模式版本升级至v1.1.2; •	Feature:IOT框架升级至v1.5.1(支持OTA断点续传); • Bugfix:修复离线超时软重启后,循环定时器失效的bug; ",
         "binList":[  
            {  
               "downloadUrl":"http://52.28.103.75:8088/ota/rom/tv07T5vijsnlAF4ROZ2PpbZbFVPOfLTf/user1.1024.new.2.bin",
               "digest":"30c39041734d1eee86d659264037e28bc22295c154bd3407c6950186f31a9b76",
               "name":"user1.bin"
            },
            {  
               "downloadUrl":"http://52.28.103.75:8088/ota/rom/tv07T5vijsnlAF4ROZ2PpbZbFVPOfLTf/user2.1024.new.2.bin",
               "digest":"695a5dfa269e2126d42d87931691e26e090247d6d304ded18467a89a3928b5d8",
               "name":"user2.bin"
            }
         ]
      }
   ]
}

one could craft a request reporting a lower version of the FW for a specific device, in order to get a download fw-url for that device (i tested it and it works! what’s even funnier is that i can get the last update url even for devices that are not in my account using the pre-known deviceid). what baffles me is why there are 2x download urls and how they are supposed to get downloaded (and used), i need the headers to know how to send the “digest” auth (the download request from the device needs to be captured. basically one needs to dump current fw and try to update, if that doesn’t work restore the dump and start over with a new capture method)
i don’t have a super-basic-cheap usb-ttl to do all the steps above, nor i have much of intention to do it (i do have have a raspberry pi but not have the required cables/headers :frowning: )

if this one can be cracked in theory everyone could return to original firmware making the above tutorials sort of obsolete (sorry @Ze_Pico) just imagine that :rofl:
ps: in case you don’t know your deviceID or you don’t have it attached in your eWeLink account anymore, you can open the physical device and should be written somewhere in there (just checked on one device of mine)

anyone else interested in restoring original firmware?

2 Likes