Sonoff /eWeLink component for original firmware

OMG!!! I got it working now. Thank you so much. Too good to be true.

Glad you’ve got it working :wink:

Regarding Charles, (for future reference) what I usually/easily do is to connect the laptop/iphone (or android) to the same wifi, point phone’s proxy settings to Charles/laptop local ip, install the certificate and enjoy. (do notice that this doesn’t work all the time, especially if you have apps using certificate pinning, for this you need to globally disable SSL on the phone :upside_down_face: google it).

PS: In the current state the component logs in automatically so no need to mess up with charles anymore. Also, keep an eye on the project I’m still tweaking it and the next update will (hopefully) add support for a wider range of devices with multiple switches.

2 Likes

Also confirm that works with original firmware that already updated. I have v1.6 and 2.6 both ori version works great and can be seen and used in HA.

1 Like

Yup have been using with Sonoff Basic, works great.
Eagerly waiting for the update that adds support for multiple channel devices. :slight_smile:
Wish I knew python, still messing around to see if I can be useful. :slight_smile:

The man @peterbuga deserves a beer!
Why not set up a Patreon page for yourself or something man?

Just added a generic 3-gang touch switch as well, works perfectly.
Will update with the device name as soon as I find out. :slight_smile:

1 Like

Excuse me for my ignorance and the OT question, but what is Charles?

Charles is the app that listen and log your internet access which will show the api host and bearer token when you login with ewelink app. Now don’t need it anymore because of sonoff.py

Charles is basically an app to read http traffic going in and out of the computer.

You won’t require it for this to work.
This was required for the other implementations of ewelink on nodejs

@peterbuga did a great job making that process really easy

Further request for this. Hope it support Sonoff S31 soon and also possible to add these switches to homekit component.
Thank you very much.

With update to new sonoff.py there is showing this in info

Sun Dec 02 2018 16:32:26 GMT+0700 (Indochina Time)

found new region: >>> `as` <<< (you should change api_region option to this value in configuration.yaml)4:32 PM custom_components/sonoff.py (WARNING)

My setting is

sonoff:
  email: myemail
  password: mypassword
  scan_interval: 60
  grace_period: 600

Got the answer now.
I found already. There is new login api region for asia is ‘as’ instead of ‘cn’

feel free to follow these quick steps :wink:

regarding the log message, read the project’s description regarding api_region setting. strangely, there’s no mention anywhere of as value in the eWelink source code app. do you live in Australia?

I think I found it. I should probably use cn.

If your location is in Asia:
cn-long.coolkit.cc, cn-api.coolkit.cc, api.coolkit.cc.
If your location is in EU:
eu-long.coolkit.cc, eu-api.coolkit.cc, api.coolkit.cc.
If your location is in Oceania:
cn-long.coolkit.cc, cn-api.coolkit.cc, api.coolkit.cc.
eu-long.coolkit.cc, eu-api.coolkit.cc, api.coolkit.cc.
If your location is North Ameria or South America:
cn-long.coolkit.cc, cn-api.coolkit.cc, api.coolkit.cc.
How to ping? Check this tutorial.
If the result shows the connection between the server and WiFi is well, your network is OK.
If the result shows the connections is bad, please change your phone’s DNS to 119.29.29.29.
Still failed? Please change router’s DNS to 119.29.29.29, then ping the corresponding URL again.
If the result shows the IP addresses don’t run, please send the related URL to your network operator, let them help you. For example, if you are Asian user, please ask the network operator to parse these two domains: cn-long.coolkit.cc, cn-api.coolkit.cc, and api.coolkit.cc.

The cloud is a definite no-no.
Since Home assistant chews up sd-cards and screw up your home automation, you better keep it all local and make loads of backups.

I think the only hiccup to local sonoffs is the difficulty to add google assistant (ignoring the fact that flashing is intimidating at first) without paying for HA cloud.
For lot of us beginners, home automation begins with adding smart switches/lights to google assistant and hence routines.
So this lets us benefit from the potential of HA automations & algorithms while making it still easy for the wifey to use Google assistant

1 Like

Having devices on the local network only they still keep updating the states / writing the db. This component it’s just a matter of preference and usability (just 3 lines in configuration.yaml and you get your devices up and running).

Alternatively one can easily create a ram disk and write the sqlite database there => no increased sd card writes, with periodical backups (an easy script to be done) but out of the scope of this thread.

Hello, @peterbuga, ¡Great job! I have some devices connected to ewelink and I want to use them with home assistant. I have a staadard home assistant installation under Raspbian strech. I have followed your steps at github, moved py files to custom_components dir, created the entrance in configuration.yaml, restarted home assisitant without errors but i can´t find a sonoff basic that I have linked to ewlink. Where is it? Do I have to do anything more? Thanks for your help!

Could you please send some error details from logger/dev-info tab of your HA
Thanks

here’s some debug ideas for starters:

add (temporarily) to your configuration.yaml

logger:
  default: warning
  logs:
    custom_components.sonoff: debug
    custom_components.switch.sonoff: debug

and it should spit out at least some info about what is happening there regarding this component if you watch closely the boot logs of HA

the switches should show up by default in your dashboard (depends on your config) or search for it in the Developer Tools > States entities list

ps: always use the latest version of the component - master branch (just pushed some improvements … i hope) last night

1 Like

Hey while debugging myself early on it seems like
homeasistant.components.switch.sonoff doesn’t work
You have to add:
custom_components.switch.sonoff

1 Like

right :wink: i’ll edit to reflect the change