Sonoff /eWeLink component for original firmware

+1

Working with shared sonoff Basic device!
Latency of about 2 seconds.

Thanks a lot

It looks like you’re adding device_name from eWeLink API, why not also change friendly_name to that?

entity_id can still be switch.sonoff_xxxxx

:grin: a man, you’re welcome!

Unfortunately I just discovered HA last week myself and I’m still not familiar with the proper custom components updating methods. i haven’t tested hass.io install or anything other then above mentioned raspbian+virtual env, i do not know what you have there so it’s better to say for the sake of simplicity to copy-paste the files for now.

Refreshing too fast it’s like trying to pull-down-to-refresh in mobile app, depends on what hardware you have HA installed, on my rasp pi w it gets into timeouts sometimes. you can try to lower the value and keep an eye on the logs for a while and see how it works for you. i wouldn’t take it lower than 10sec though, but then again do you really need it to refresh that fast :face_with_raised_eyebrow:?

The latency can be lowered down even further if I’m using the websocket to listen realtime for all the events (this will make almost instantly the refresh part mentioned above) basically I’m getting closer to simulate the mobile app. But because I started this small project just to learn HA framework and this will require some serious code refactoring, I might do it this component it presents enough interest for more people and for me to do a pull-request on HA project :crossed_fingers::heart_eyes:

The naming part, again fresh project, I really prefer id’s because they have a real link to the hardware and it’s easier to change it in automations if needed. I might add an option or change it as you mentioned aaand just like it’s already specified in README file :stuck_out_tongue:

Great Work!

scan_interval: 10 seconds so far works well on a Rpi2 with Hassio

Hopefully this will pick up attention as there seem to be a lot of people who want to get started with sonoff devices on HA without flashing. (in order for them to work with Google assistant as well without having to integrate that into HA by exposing HA to internet or pay for HA cloud)

Yup naming the entity with device_id seems to be perfect, I was just wondering if adding friendly_name attribute with device_name info from API just makes it a little polished. :slight_smile:

For now, I have just used a customization for friendly_name on Hassio.

2 Likes

Hope the websocket thing works out. Somehow the app on my phone updates instantly when I turn on/off switch using google home.
HA basically updates every 10 seconds.

For you and for anyone else willing to help (themselves) I created this little script that can provide me useful data on the details of various devices. Please read the description carefully :slight_smile:

. HASS-sonoff-ewelink/sonoff-debug at master · peterbuga/HASS-sonoff-ewelink · GitHub

1 Like

Awesome. Will give it a try tomorrow. Will add other devices to the shared account as well

For the naming part, I used the customize.yaml and so far all is working well:

switch.sonoff_10004d43f8:
  friendly_name: Sonoff Soggiorno
switch.sonoff_10004dd3da:
  friendly_name: Sonoff Cucina

Cattura

I have two sonoffs and they are working as expected.

For you and for anyone else willing to help (themselves) I created this little script that can provide me useful data on the details of various devices.

As I said I’m on Hass.io, I logged on the terminal but it seems that I don’t have a python command to work with, sorry :sweat:

i see it’s pretty common to have a hassio install so i’ll guess this seems to fit the bill for my request above

i would like to mention that the script can be ran from anywhere be it a linux/macos/windows command line (as long as the highly common dependencies are met), it’s totally independent from HA install.

thanks for trying it out :wink:

Yup doing the same right now.
Just wanted to be get my hands dirty with coding myself. :stuck_out_tongue:

Check out the GitHub repo.
Added JSON dumps.

Adding Sonoff 4Ch pro to account currently breaks the platform/component. (Error added on GitHub)

Let me know if I can be of any other help.

Any setting need in Charles in order to catch the login from ewelink app on iphone?

I have installed Charles on my notebook and share the wifi hotspot, my iphone can connect and use internet share from the notebook. However there is no any display in Charles. I noticed that the ip address received to my iphone is in different subnet mask. I also try to change it manually to the same subnet mask but if do so I can connect to wifi hotspot but cannot use internet and cannot login to ewelink app.

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