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

Most of my sonoff devices are behind wall switches manually operated and, therefore, they loose power for some time while the wall switch is off. When that happens the device handler reports the switch as ON or OFF all the time of course…

I have modified the device handler by @erocm1231 and I have added an OFFLINE status so I know the switch is disconnected. It seems to work fine although smartthings does not call the polling capability often enough so I force it (using a core rule) to update every 5 minutes.

Don’t want to clutter this thread with more device handlers as @erocm1231 has done an excellent work but if someone else use the switches in a similar configuration as me and wants to take a look at it let it is in my github page (jrhbcn).


You can also power the sonoff thru the [quote=“kevin, post:262, topic:45957”]
Do these devices have a temperature sensor? Maybe could use that as a warning/trigger to ST if temp started rising.

The TH model supports an external temperature sensor with the stock firmware. If those pins are exposed inside then you could possibly mount one in it, but IME when powersupplies start to get really hot they stop outputting properly so the thing would have crashed and not be able to read the sensor.

I am yet to have any of the ones I have do anything strange, and at least for the TH16 and TH10 models they look really well built. Its the S22 that I have issues with - crap soldered only terminals for the input and output sockets and mis-wired so it was switching the neutral.

I’m curious if the 4 (or 2) nodes work as well,. Would be nice for a couple projects. Let us know if you try it!

Great News! Sonoff works with Amazon Echo now. The new version will be released after 2017 Chinese New Year Holiday. Please stay tuned!

Has anybody connected Sonoff TH with DS18B20 temperature sensor?
Will it work with @erocm1231 firmware?

Haven’t had a chance to try this device out yet.

@aivar The DS18B20 does not work at this time. I have one somewhere, I just need to play with it.

Tomorrow is my B-Day and my present from my wife is an entire day to myself! So, since I am not entertaining little ones or working, I’ve got a few updates to finally post. I’ve created a firmware specifically for the Sonoff Touch and Sonoff S20. The S20 is a nice little device. The touch is great in theory, but I’m a little disappointed in its build quality. It is only $15 though, so maybe I shouldn’t complain? It is rated for only 2A and the wire terminals do not seem like they are made for standard 14 gauge electrical. The plastic is cheap and I broke some tabs trying to shove it into my wall. Admittedly I was being a little careless, but be very gentle with this stuff.

The S20 and Touch both use the regular Sonoff Switch device handler. You will need to update the smartapp to find the new devices on your network.

I’m just about to post the firmwares, so give it just a minute.


HA tomorrow’s my B Day as well, maybe I’ll order some of these a gift to myself… Thanks!

1 Like

You probably deserve it. :wink:

1 Like

Thanks Eric!

[quote=“erocm1231, post:272, topic:45957”]
It is rated for only 2A and the wire terminals do not seem like they are made for standard 14 gauge electrical.
[/quote] I think they are targeted more for overseas type installations where a wall switch operates a load relay with lighter gauge wire not the load directly which doesn’t fit a US residential installation very well.

You do know that Amazon Echo has been working with this device since last year when this custom device handler was released?

Hi, I’ve purchased one of these, uploaded the firmware, but the Sonoff app fails to detect it. I can manually add it using the IP I’ve reserved, I can sort of control it. If I press on, the led on the board lights up to show on. But the app status stays at turning on. If I turn it off, it turns off, but the status stays at turning off.
Did you have to alter the code to make it work correctly?

Is the device close to your wifi for testing? SSDP is finicky sometimes and may hate wifi extenders. Some routers have poor support for it as well. Can you access it via IP in a web browser and turn it on and off without trouble?

Make sure you have the SmartApp update I posted yesterday. It is needed to discover the new devices.

Also, if you did a manual install, go into the device and hit the configure button. That should make it so it will talk back to the SmartThings Hub.

@erocm1231 does your firmware support hooking up the wall switch to the sonoff gpio Ground + 14 pins so that the load can be toggled normally also ?

Pls see the link for description on how it works with standard sonoff and even using the sensor output on the TH models:

u may skip to time 22:20 and 27:48 for details.

I plan to use them behind wall switches and thus making the load operable manually would make them more functional.

1 Like

I don’t currently, but it is a single line of code that needs to be changed. I’ll go ahead and put it in.

I would be careful though as these are not in-wall rated I believe. Also, they are kind of big. They wouldn’t fit in any of my gang boxes (and probably most others) because of all the wiring / dimensions of the box.


Hi, First I would like to thank you Eric, great app.
I added another Sonoff to my network last night and can not change its name.
I can not remove it (or any other device) to rediscover again or delete the app to reinstall.
Any ideas?

If there are any SmartApps tied to the devices they will not remove until the SmartApps are reconfigured or deleted. To rename the device you can just rename it within SmartThings just like any other device.

Alternatively you can just remove the SmartApp through the IDE, but that is kind of like holding the power button down to shut off your computer.


It would be nice/extra appreciated if you were able to edit the main post to provide links to all firmware DLs, and possibly installation videos or at diagrams, as each device is different.
especially the s20 and Touch. I wholly realize you do this on your own time, so if there’s anything I or any of us can do to make these videos/disgrams please let me know. I’m simply asking because this is all a new (learning) experience for me, and I’m looking for that stuff myself.

Add a section to the post like:

Currently supported devices:

  • Sonoff [current firmware DL link]
  • Sonoff TH [current firmware DL link]
  • Sonoff S20 [current firmware DL link]
  • Sonoff Touch [current firmware DL link]
  • Etc

Flashing/Installation videos:

  • Sonoff [youtube link] / [wiring diagram + 1. 2. 3. 4. etc instructions]
  • Sonoff TH [youtube link] / [wiring diagram + 1. 2. 3. 4. etc instructions]
  • Sonoff S20 [youtube link] / [wiring diagram + 1. 2. 3. 4. etc instructions]
  • Sonoff Touch [youtube link] / [wiring diagram + 1. 2. 3. 4. etc instructions]
  • Etc

Again, only a suggestion to make this even more amazing setup an extra degree more user friendly. THANK YOU for the great work and dedication with all of this development. It is amazing!


Wait, that’s not how you turn off a computer??? Oh man this is gonna be rough news to break to the vast majority of humanity…


I have tried to rename it like I did before (Roy’s Light in attached image) but it just not changing anything.
Also, the message says “press next to continue” but there is no next, only “Done”.
I was able to remove and rediscover the switch but that didn’t help with renaming it.

Is the Sonoff POW on the list of supported devices?
Do you plan to support the power monitoring feature?