New custom component: Sonoff LAN Mode (local, with stock firmware)

That error indicates wrong API key. Don’t get mixed up between the selfAPIkey it is not the same. You need to capture API key during pairing

I got the key according to the article you link to in documentation:
https://community.hubitat.com/t/sonoff-ewelink-via-homebridge-node/3753
so probably something changed.

I was told that someone had used this successfully, but can’t attest to that as I’ve never used this method.

Sorry if it doesn’t work, I think I’m going to remove that link.

The way I do this is with a local LAN sniff using tcpdump. I find this very reliable, but is not trivial.

I’m sorry that Itead make this so difficult!

Thanks Matt for your work!

@mattsaxon I’m trying to use your custom component for my Sonoff Basic, Basic R2 and RF R2 devices. I got API key from last method in your article:
Sonoff EWeLink via Homebridge/Node, but as @Stooovie suggested maybe something changed on Ewelink side. I have also noticed that length and format of my API is different then one shown in your example on Github. All of my devices added in Home Assistant (Hass.io on RPi3 B+ - HA version 0.104.3) are unavailable and I get this error in log:


Also some zeroconf is mentioned:
2020-01-28 01:04:02 DEBUG (zeroconf-ServiceBrowser__ewelink._tcp.local.) [homeassistant.components.switch.sonoff_lan_mode_r3] Service eWeLink_1000568b68._ewelink._tcp.local. updated (not our switch)
I have read about some issues regarding this but this is solved right? I don’t know how to check which zeroconf my Home Assistant is using and how to revert on maybe older version. I’m new to Home Assistant, so I’m still learning…
Also @mattsaxon i have made some tcpdump of local LAN traffic in my home WIFI when Internet connection was disabled but I don’t know where to find proper API KEY for my Sonoff devices. Also one more question is this API KEY different for each device or it’s the same for all of my devices under my Ewelink account. Thank you Matt for your work on this excellent component…

Yes, the issue is that that key is wrong.

Don’t worry about the debug message, thats expected.

You shouldn’t need to backout zerconf, just make sure you have the latest version of my component, get the API key right and it should just work.

Use one of the other methods of getting the API key. For example you might want to check out this descriptions Sonoff: LAN Mode VS Tasmota

I’ll update the docs when I get a chance.

Thanks for your help. I have latest version from Github.
regarding your link i can’t see the post
image
If you are referencing to enter pairing mode on one of the sonoff devices I’ve tried that also yesterday but without any success. The device is blinking (after pressing the button for more then 7s) but no AP ITEAD-xxxxx is available under WIFI networks. Sorry if this isn’t the topic you have referring to…

He put the link two times after each other.

Thank you @francisp I didn’t check the link from the post, my bad…

Ok, I need a router with DD-WRT on it which I don’t have :frowning: so is there other possibility to sniff via tcpdump apikey?
On more thing - probably noob question. Do I need to obtain apikey for each sonoff device in my home?

Now this is working. But is there a way to make these available on google home (google assistant).
Normally I would go for gbridge (google assistant is not so easy to setup). However then I need MQTT…
Any advise?

I have a sonoff mini. i dont understand one thing. in the doc it is written if i want to use DIY mode with jumper on, then i dont need API key. but while in DIY mode how it will connect to my home network? i thought in DIY mode it only connects to specific ssid!

and then i tried without jumper, i deleted from app, and restarted mini to put it in pair mode (i think), but i couldnt find any ssid starting with ITEAD. but at this point i can pair this in the app. am i doing thing wrong?

i wanted to flash tasmota into this mini. but my DIY tool didnt find the mini, and i tried 3 windows PC. is it a possibility that the mini is somehow corrupted!

The DIY tool needs firmware 3.3 on the mini, so possible you have to upgrade in the app.

Sorry, but you are doing this wrong. DIY mode doesn’t use eWeLink or ITEAD SSID. Its quite poorly documented IMO, but you can find out about it here https://github.com/itead/Sonoff_Devices_DIY_Tools/tree/master/other

You will note there are lots of issues on that repo too. For what it’s worth I stick with eWeLink mode even though you have to sniff the API key.

See instructions here https://pysonofflanr3.readthedocs.io/encryption.html

There are other ways to get the key, but with some devices there is no other way than to sniff.

There are lots of ways to sniff, the LAN, but none are trivial. It’s a whole topic in itself and without knowing your level of expertis, the operating system you are using and your network topology, I don’t think we should get into it here, but you can DM me if you want once you’ve had a google about!

Yes you need a API key per device

Is the API key changing after doing a factory reset to change the SSID?

No it doesn’t change

I want to sniff the API, that’s why I want tried to connect ITEAD***** SSID, but I can’t see this SSID.

If this is a problem with working in DIY mode, I suggest you ask it on the Itead repo I pointed to earlier.

If you are struggling to find the API key when in eWeLink mode, please refer to my link to encryption.md that I pointed to earlier. If you have an issue with that, please raise an issue on my repo.

Finally I have managed to get the API KEY from first Sonof Basic switch - FW:3.3.0.
I have used this method:
https://community.hubitat.com/t/sonoff-ewelink-via-homebridge-node/3753
with my wifes IphoneX and my Macbook as laptop.
I have enter the pairing procedure and when my Sonoff paired (again) i could see in Charles my apikey:


Then i have put this in configuration.yaml and my switch is now available in Home assistant and I can control it from there.
Edit: after few minutes Sonoff device get unresponsive:

and can’t control it from Home Assistant, strange…