Integrating Sonoff Mini with ST. My findings

I wanted to create a new topic dedicated specifically to the new Sonoff Mini as it has done my head in for the last 2 weeks.

I have been playing around with Sonoffs for a little while now, and I quickly got drawn to @erocm1231’s firmware and DTHs and have been using a couple of basics and a couple of THs and they work brilliantly.

I’ve just recently seen the new Sonoff Mini and thought it looks amazing for a requirement I have.
I want to use this in a light switch, this is different to the basic in that it has 2 terminals that you can connect to a rocker switch and change the state manually as well.

I bought a mini, have flashed it (not fun, I soldered some leads and did it that way!) with Eric’s firmware and it works but I lost the ability to use the switch terminals.

So for the first time, I decided to use Tasmota. I knew nothing about it but had read a little in Eric’s topic and figured it was worth a go.
Because I had put Eric’s firmware on the device, it made it very easy to flash it again with Tasmota through the OTA feature. ( I know the mini does have this feature out of the box but it looked a PITA)
with a little googling etc I found that Tasmota was able to utilise the switch terminals by setting GPIO4 to Switch1 (9).
Now I thought it was all sorted except I did not know how to get this integrated into Smartthings.
With a little more googling, I found @brettsheleski’s DTH and I thought I was nearly there. But, the instructions left me a little confused and I could not get it to work.

Following Brett’s instructions I had installed the 2 DTHs and had put in my IP address in the parent device but it would not spawn a child device so I kept trying and trying but couldn’t really get anywhere.
At this point I gave up. I reached out to erocm1231 to see if he could suggest a way of changing that GPIO on his firmware but unfortunately he doesn’t really support that firmware anymore (although he still seems happy to try and help people) so he suggested I try his forked Tasmota firmware but I would need a DTH.
I’m not really sure what the difference is between his firmware and Arendst’s original but I still could not work anything out.
I have created a DTH before but only something very basic, I certainly am not a programmer!
At this point I gave up again!

Today I picked it up again. I still have Eric’s forked Tasmota firmware on the device but in ST I started again.
I created Brett’s 2 DTHs in IDE again, created a new device and picked the Tasmota device type. In the app, I added the IP address and hoped!

Still nothing.

I ten thought I’d try and be clever. I started looking at the code on the Tasmota DTH and eventually worked out that the module that shows in the app for my device was 0 yet this was not listed in the DTH code. So I added 1 line at line 202 and typed “case 0: // Sonoff Mini”
In the app, I then opened the device again opened the preferences, hit save and found the child device had been created!

YAY it works!

I now have a child device in ST that controls the mini!
The only issue is that if I use the switch then it does not update the status of the device. Luckily Brett has a SmartApp for that. I will play with that tomorrow.

Now what I would like to do is create a new DTH that can do this all as one and not need to create a child device or have a SmartApp but to be honest this is probably well beyond me.

For now, it works and I am happy.
But I thought I would share my findings in case anyone else is thinking about using these devices or is currently struggling with them.

If anyone has any questions or I have not explained well then please let me know.

1 Like

I’m glad you got it working with the Sonoff Mini. I do not yet have any of these devices yet for me to test with. Please submit a pull request with the code modifications you did in order to get the Sonoff Mini working.


1 Like

Hello I have smartthings, and I have acquired some mini sonoff. I’m interested to know your dth

Hi Brett,
I haven’t forked your repository yet I just tweaked it in IDE.
I will do though and I will submit a pull request. Just need a chance to sit and do it.

If you want to adopt it in the meantime. I literally only added:
case 0: // Sonoff Mini
into line 202

Cheers for the DTH. Works well.

Hi Jose,
It’s definitely not my work. Credit all goes to @BrettSheleski.
His DTH is here:

Just read the readme file VERY carefully.

Then add line 202 as I described above.

1 Like

im seeing a problem and not getting the child to spawn.
I set up a NodeMCU with tasmota and tested that and it works fine.

I am getting an error when it tyes to run the reload section…

f238384b-83c4-4e02-a5eb-0693db62a3e8 21:13:32: error java.lang.NullPointerException @line 137 (spawnChildDevices)

f238384b-83c4-4e02-a5eb-0693db62a3e8 21:13:32: debug Module: [0:Sonoff Mini]

f238384b-83c4-4e02-a5eb-0693db62a3e8 21:13:32: debug GPIO: [GPIO16:[0:None]]

f238384b-83c4-4e02-a5eb-0693db62a3e8 21:13:31: debug createCommandAction(Status:0) to device at

f238384b-83c4-4e02-a5eb-0693db62a3e8 21:13:31: debug REFRESH

f238384b-83c4-4e02-a5eb-0693db62a3e8 21:13:31: debug createCommandAction(gpio:null) to device at

f238384b-83c4-4e02-a5eb-0693db62a3e8 21:13:31: debug createCommandAction(module:null) to device at

f238384b-83c4-4e02-a5eb-0693db62a3e8 21:13:31: debug RELOAD

then I checked the iFan03 (which is device 71 (and yes the iFan02 is device 44 still) and I had the same error.

98311039-3b9f-4d2b-9dd7-16ffd452b5e4 21:20:38: error java.lang.NullPointerException @line 137 (spawnChildDevices)

98311039-3b9f-4d2b-9dd7-16ffd452b5e4 21:20:38: debug Module: [71:Sonoff iFan03]

98311039-3b9f-4d2b-9dd7-16ffd452b5e4 21:20:38: debug GPIO: [GPIO:Not supported]

So I need to see what is happening in the code, but I wondered if anyone had and thoughts!

BTW… module 0 is only temporary… this is the module you use to set a manual template. They might add a fixed template to the code later.
Also you need to be careful with module 0 because other templates can be manually uploaded to module 0.

© 2019 SmartThings, Inc. All Rights Reserved. Terms of Use | Privacy Policy

SmartThings; SmartApps®; Physical Graph; Hello, Home; and Hello, Smart Home are all trademarks of the SmartThings, Inc.