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

My T4EU1C switch is going unavailable in home assistant. Seems to stay available as long as it is in use. Just tried blocking internet access. Will report back if it helps. I notice there is an issue on GitHub about switches going unavailable. This could be the same issue.

EDIT: I can confirm that not allowing the switch to contact the internet appears to have solved this problem so far. It’s a shame that the WiFi light is always flashing like this.

Hi all,

Small contribution from Spain. To capture the Api Key, you can simply put the sonoff on pairing mode, connect your tablet or mobile (in my case an Ipad) to the wifi created by the sonoff (pwd:12345678) and launch from the navigator (in my case safari) “http://10.10.7.1/device”. The sonoff will inmediately return the device ID and the Api Key.

1 Like

Started to notice that since I blocked the internet on my routers fitewall, the switch loses WiFi every few minutes (is it rebooting/watchdog). This also makes it go unavailable. Might flash this soon. Anyone else having this issue? Turned internet back on for now and it seems to be staying connected to WiFi for longer but expect it to go unavailable again.

Given up with this now, with internet blocked SONOFF keeps disconnecting from WiFi every minute or so. With internet open it stays connected to WiFi but keeps going out of Lan mode and showing unavailable.

T4EU1C now has remains of a bit of solder on R10 and Tasmota 6.7.1 installed. My touch panel is working with no modifications.

I don’t get the API key from the V3 firmware. There is no hotspot where I could connect to.
Any help? :slight_smile:

I’ve recently become frustrated with my Sonoff S31s and the extensive delays in updates for power usage (my poor washing machine automations!), so went ahead with the custom_component as described above.

Not sure what I’m doing wrong – I’ve restricted outbound internet to make sure they stay in LAN mode, and have double-checked the IDs vs the API keys. I can see in the debug log all kinds of entries w/ the data I’m after but I don’t see any devices in Home Assistant…

EDIT
OK I lied - I can now see them in HomeAssistant (and there was much rejoicing?)
But they are coming back as unavailable – I’m guessing the message structure doesn’t match what the component is expecting?

2019-12-07 17:02:54 DEBUG (zeroconf-ServiceBrowser_eWeLink_1000384980._ewelink._tcp.local.) [homeassistant.components.switch.sonoff_lan_mode_r3] properties: {b'txtvers': b'1', b'id': b'1000384980', b'type': b'enhanced_plug', b'apivers': b'1', b'seq': b'76', b'encrypt': True, b'iv': b'MjY5NTgzOTY3OTk1MjIxNg==', b'data1': b'PC0ZqdwYHreHvN6XgWbqpffQBQOdalxy3WZedFSa+0+1YCyijOXg2FG4FS+xsOC6odz07YiM4FB/3cfQbxk28eRoH2BRAaVz7Y+9Jn/HwIPzEb6e6lI8IyGdAfcRSKQdUzAqBWwKX279azy9lZTh6zsyHg6g4gT1+CK9lid8FD/yKUr8xUUl+5j59uP2XP/YNlKeHW9mnu6pcM7YpM8uFM5JsrC67f9buauFLp4dsnQ2d3Dsa+yddbpjJ', b'data2': b'U6GrMKS'}
2019-12-07 17:02:54 DEBUG (zeroconf-ServiceBrowser_eWeLink_1000384980._ewelink._tcp.local.) [homeassistant.components.switch.sonoff_lan_mode_r3] type: b'enhanced_plug'
2019-12-07 17:02:54 DEBUG (zeroconf-ServiceBrowser_eWeLink_1000384980._ewelink._tcp.local.) [homeassistant.components.switch.sonoff_lan_mode_r3] decrypted data: b'{"alarmVValue":[-1,-1],"alarmCValue":[-1,-1],"alarmPValue":[-1,-1],"switch":"off","startup":"stay","pulse":"off","pulseWidth":500,"sledOnline":"on","power":0,"voltage":118.72,"current":0}'
2019-12-07 17:02:54 DEBUG (MainThread) [homeassistant.components.switch.sonoff_lan_mode_r3] enter handle_mesage()
2019-12-07 17:02:54 ERROR (MainThread) [homeassistant.components.switch.sonoff_lan_mode_r3] Unknown message received from device:

You didn’t mention what kind of device you were using – on the S31, I had to put it in pairing mode and THEN hold the pairing button for an additional 10s or so to get it to go into a mode that let me do the wifi pairing method (i.e. joining the ad-hoc wifi network w/ the complicated Spaceballs-esque password of ‘12345678’).

How to configure temperature sensors (Sonoff TH16) and use sonoff_lan_mode_r3?
It’s possible?

I just posted an update to support it as a switch, but I haven’t added the temperature to the component yet. I will do in due course if you can confirm that it is working as a switch now

Switch is working! thanks…

When will the sensors be supported?

Please refer to the GitHuib issue https://github.com/mattsaxon/sonoff-lan-mode-homeassistant/issues/12

Multi Outlet devices such as the 4CH, 4CH Pro are now supported with the R3 fork.

@Bluhme, can you confirm if the TH16 now has V3 firmware on it. @tsouza85 seems to be using V3 firmware with theirs.

If so, is there any reason to continue to support the earlier firmware versions in the component?

Hi all,
i can confirm sonoff mini is working well!
Is anyone get the sonoff tx us 3gang working?

What firmware version is it running? I saw some info that said LAN mode wasn’t supported with the multi gang T1s, but they may we’ll be out of date as the same page had lots of information I know to be out of date!

Updated to 100.4 and my entities in this custom_component are listed as unavailable.
I get the following error message in the log

Logdetaljer (ERROR)

Thu Jan 16 2020 11:55:40 GMT+0100 (CET)

Error decrypting for device 10006533c5: Padding is incorrect., probably wrong API key

its running 3.3.0 firmware. using eweling app lan mode is working, i can control the tx 3gang without internet enabled. THe only problem is that i cannot get the apikey. with sonoff mini i used the 10.10.7.1/device while connected to the itead wifi, now i reset the device through ewelink app but i cannot see the itead wifi…how to get the apikey?
edit: it was my error, i have now device id and apykey, but added to HA i see only a switch, instead of 3 switch…ho to get all of them?

Yep, its getting harder to get the key, here’s my docs I’ve written on it. Basically, for these 3.3 devices, I think you need to sniff the LAN, there a couple of pointers on how to go about this in the docs

https://pysonofflanr3.readthedocs.io/encryption.html

Reference to issue here https://github.com/mattsaxon/sonoff-lan-mode-homeassistant/issues/18. Short summary, its related to the zeroconf components that has been upgraded, it’s faulty and I’m working on a solution. There is a workaround in the issue.

All its working! I got the api Key with http://10.10.7.1/device
The 3gang Is working with the outlet parameter set for each gang
No issues! Its US model