[RELEASE] Sonoff, Sonoff TH, S20, Dual, 4CH, POW, & Touch Device Handler & SmartApp ($5 & $10 Smart Switches)

Yeah, what @whoismoses said. These are almost certainly not rated for wall use, in a metal box you might be safe, but these are probably a fire hazard just sitting on the floor! Cheap made in China things should not go in walls. Only the pricey made in China things like Fibaro/Monoprice/etc relay’s and switches. :wink:

These do get a bit warm, I’ve not felt one hot enough to be worried about using it in wall or in a fan, but neither location is exactly easy to get to or even KNOW if there’s a fire so I’d just not recommend it.

Well I bit the bullet and bought myself one of those FTDI thingy dubreys.
Followed the instructions at the start of this post and it all went brilliantly.

The only part that had me slightly concerned was that the AP did not appear very quickly but when it did I was off and running.

From start to finish, (this includes soldering flying leads on to my Sonoff unit and the FTDI unit) took around 2 hours.
If I buy any more of these it will probably take 1/2 an hour a unit. (Now that I know what I am doing and have all the frirmware, device handler and smartapp downloaded).

My fishtank light is now fully automated using CoRE pistons and the WAF has increased.
Now she wants me to get something to feed them automatically!!!

1 Like

So I got this all setup. I can hit the IP address given by my router and turn the switch on and off. But Smartthings refuses to see the switch. Im IP range is 10.X.X.X. upnp is running too. This is v1 hub

App Log
1b1c87d1-ebe4-48d4-907d-b5e3e43c7464 6:46:20 PM: error java.lang.NullPointerException: Cannot invoke method startsWith() on null object @ line 266
1b1c87d1-ebe4-48d4-907d-b5e3e43c7464 6:46:20 PM: trace description.xml response (application/xml)
1b1c87d1-ebe4-48d4-907d-b5e3e43c7464 6:46:09 PM: error java.lang.NullPointerException: Cannot invoke method startsWith() on null object @ line 266
1b1c87d1-ebe4-48d4-907d-b5e3e43c7464 6:46:09 PM: trace description.xml response (application/xml)

The protocol used for detection by the SmartApp is SSDP. Some networks do not play nice with it. Especially if you have Wifi bridges, repeaters, or corporate Access Points. Also, sometimes it just takes a reboot of all your networking devices.

You can bypass the SmartApp by just creating a new device in the IDE and assign it the Sonoff Wifi Switch device handler. Then open the device in the SmartThings app and give it a static ip in its preferences. Make sure to check the check box to override the automatic ip.

Thats great. Yeah my router is pfsense with a dd-wrt wifi AP that forwards all requests to the pfsense box. Is there somewhere I can get instructions on creating a new device? This is the first time I’ve ever done this.

On a side note, my Chromecasts performs flawlessly.

Specifically, zigbee id and Device Network id? I’m guessing leave zigbee blank and put the IP address?

This is generally a good link to reference regarding what is involved:

Also, just to make sure, You installed the Sonoff Connect SmartApp and the Sonoff device handler right? Then, when you go into the SmartApp on your phone discovery is done through the SmartApp and not the SmartThings general device discovery. The page should look like this:

Sometimes it takes 5 or so minutes for the switches to send out an SSDP packet.

If that isn’t working, like I said, you can add the switch manually. In the IDE, click on the “My Devices” link. From there click on “+ New Device” in the upper right corner. Fill in the information and select “Sonoff Switch” as the Device Type. For the “Device Network Id” put in random characters. The device handler will set this to what it needs to be once you put the ip address in. Hit “create.”

The device should now show up on your phone where you can input its ip address.

Works now! THANK YOU. pretty awesome stuff. Great work!

Hi All,
Really hate to post this but thought it the responsible thing to do.
I have had one of these turning on/off my fish tank light for just over a week now.
Tonight it lost association with my hub and I could not control it any more. i could turn it off and on via the button.
Then the light started flickering about an hour later.
It was now getting a bit warm.
I have removed it from the circuit and I will bin the other 2 that I have installed.
I am in the UK running 220V.
It could just be one faulty unit but…
Just thought it my duty to tell the forum what I have found.

Appreciate that. I’ve been keeping a close eye on mine as well. Did you check the solder joints on the front and back when you got them or just wired them up? One of mine has a solder line that was stupid close to the ground plane so I cleaned it up. I just don’t trust plugging in anything from China without giving it the once over.

Looks like there’s a refresh underway - updated fused design, sensors, multi-circuit and power monitoring.


1 Like

I have my ST hub in another local network as my WIFI one. Right now the discovery fails (after flashing and connecting to wifi successfully) and I cannot pass this step. Is it possible to manually set things up? Maybe configuring the WIFI router to port forwarding to specific IP switches and changing the port each switch listens to?

Can this be used as dry contact?
I mean can I used this as garage door opener? can I attach two wires that goes to garage opener to open/close the door based on when I press the key in app? I assume it would relay 110V or is there an option where it could relay low voltage as well?

You can edit the device in the app to set the IP address. Setup in the Sonoff’s web portal first of course or use DHCP static assignments.

Enabling UPnP on the router wan interfaces may allow discovery, but I’m not sure. UPnP is generally frowned upon to begin with so doing static IP assignments would be best.

This article may help understand what/how SSDP is/works:

Thanks @michaelahess, with your comment and @erocm1231 post #129 I think I can manage to bypass SSDP and configure the switch manually. However, I am unsure how to accomplish the setup of more than one device in this static way as I cannot change the port the device listens to instead of 80. I have not found any port configuration in the device’s web portal neither the device handler. Right now my solution implies manually redirecting ports to each switch IP in my WIFI router so ST hub can talk to them.

Would it be possible to add a configuration for the port in the handler and firmware?

You’d have to do PAT with Virtual IP’s and probably some ACL magic to make that work. Not trying to open a can of worms, but why not have an SSID/vlan with MAC filtering on your LAN segment? Having WLAN and LAN on two segments is just asking for all kinds of headaches. :wink:

Thanks @michaelahess for the comment, I was just postponing the re-organisation of my house LAN (have two local networks independent to each other) and your comment made me get up and finally do it. Now both ST hub and sonoff switches can see each other and the current smartapp / device handler work perfectly. :grin:

1 Like

Hello Eric!

First, thank you for this project! I’ve now a home with ST hub running 10 Sonoffs.

Itead has released a new sonoff unit, now with real time power consumption monitoring:

Do you think possible envolving your project to have the power information also available in ST platform?


1 Like

Yep. I’m actually just about finished with the Sonoff TH which has a 16 amp version as well as temperature and humidity Reporting . It works great. Then I will be working on the energy reporting version and then the dual relay.


Great Eric!! thanks!

I have finished the firmware and device handler for the Sonoff TH. The info is at the beginning of the first post. It is a great upgrade to the original Sonoff, but is a little bigger and pricier. Cheap way to get temperature sensors in every room for use with something like Keen Vents though.

Flashing the firmware is essentially the same as with the original except vcc and ground are actually labeled on the board making it a little easier.

I should have the energy/power version in hand early next week and will start tinkering with it.