Sonoff Light/Fan controller

So i spent some time looking into the problem… basically you get a Null Pointer Exception at line 137 in the code. When you look at what is happening, it is grabbing the module value but it isnt grabbing it correctly (actually the same is happening with the GPIO but we dont need this information if we have the module ID)
The value for the module ends up being something like [71:Sonoff iFan03] … note the value is in square brackets [ ] and this isnt correct. It means it is within an object (Im assuming) but Im too tired right now to see how that has happened.

Anyway I was being lazy so I just forced the right value ie without it being in an object. And basically the driver creates the child and the child happily works with the iFan03. I also modified the device so it is a little easier to use (based upon the kind of way dalec did his driver.)

[BETA v0515] Hampton Bay Zigbee Ceiling Fan/Light Controller

Problem is the default software from Brett isnt working. Not a showstopper once you know where the problem is, but the real issue is how do we fix the NPE.

Oh and this isnt the only device Im getting the NPE with, so it is a more generic problem than with the iFan03.

what you have done is right and the device handler does work. The issue is that the Module isnt being read correctly and so it never gets to this point to spawn the child device.

Hi @Richierich ive just bought a sonoff ifan03. I am just about to flash the tasmota firmware onto it. Can you please provide the modified DTH and instructions for ifan03.

hi @Snuffy2 did you manage to solve the issue of not being able to spawn child devices for ifan03? What is the line that needs to be modified in the DTH? Ive already changed Line 257 case 44: //iFan03.

Can someone please provide assistance?

I was able to get it working similarly to how @Richierich explains (hardcoding the Module number in instead of letting the DTH detect the module number. So I added Line 260: case 71: //iFan03 and then set the DTH to use case 71 every time. This worked for me but I only have one Sonoff/Tasmota device.

However, once I got it working, I found that the iFan03 didn’t fit in the canopy of the fan it was intended for (should have checked that first, I know). So I no longer have it installed and never took it beyond what I did above. Sorry.

Thanks @Snuffy2 for the quick response. I am a bit confused. The tasmota.groovy file from does not have case 71. Line 257 to 260 is now Case 44 where I have changed it to // iFan03. But I cannot find where I should be changing the module ID? Also what is the change in syntax required to harcode the module id into the DTH?

Hi @Snuffy2 i have added a new case 71 below case 44: // IFan02 f or IFan03. But how do I force the DTH to use case 71 every time?

hi @Snuffy2 @Richierich @BrettSheleski I finally manged to get Tasmota.groovy to spawn 2 devices Tasmota Light and Tamota Fan Speed. Tasmota Light works fine but Tasmota Fan Speed gives the following error :
groovy.lang.MissingMethodException: No signature of method: script_dth_e10587a32291cfd5f05dd710123cf11eee202daf03423fae404097b1cd806f57.setFanSpeed() is applicable for argument types: (null) values: [null]
Possible solutions: setFanSpeed(int), lowerFanSpeed(), raiseFanSpeed() @line 73 (on)

Can someone please help?

Perhaps you may want to try this? It works on my Sonoff ifan03.

I’ve made this FAQ for Tasmota devices and would welcome any feedback.

Its now running: okay:)

@hongtat thanks for the DTH link. The realtime status update definitely works better. Is there a way to delete the child device without deleting the parent device with your DTH? ie my fan does not have a light built in.


I’ll set the light as an option in the future updates, for now, you may want to try this (untested though) -

  1. Comment out the parent.delete() in the Child Switch Device

  2. Delete the light

  3. Uncomment the parent.delete()

    def uninstalled() {
    // parent.delete()

Thanks @hongtat that worked perfectly!

Hi @hongtat im having loads of problems with mine, seems to be offline quite abit, but even when it doesn’t say offline it hardly works, also google thinks the fan is a light, this is what smartthings says about my wifi in the device signal strength LQI 24 , RSSI -88 dBm , thank you.

The wifi strength/signal (24%) is too weak.

ok thanks, the wifi areal did brake off when i unboxed it, so i just soldered it back on, ill order a replacement with amazon, as all other devices have very strong wifi in the same room, cheers.

OK so I switched to [RELEASE] Tasmota (Connect) for Sonoff, Tuya, SmartLife & other ESP8266 devices) earlier this year (and stopped using MQTT and a bridge).
I have around 12 sonoff mini (all flashed with tasmota); shelly devices (some flashed some not); ifan03 flashed with tasmota. All work perfectly. This software is by far the easiest way to controll the tasmota devices and the ifan03 is easy… I actually use both the ifan03 and a mini to control the lights… the mini isnt connected to smartthings but I use tasmota rules to share light settings between mini and ifan03. The ifan is not connected to the light, but is the switch in ST… this is just so I keep the setup simple and the light switches work the way I expect them to.

Sorry to revive an old thread, but I’d like to use something like this but I don’t understand the premise.

How can you use Wi-Fi devices with smart things, specifically I would they have a DTH and connect to the hub if they’re not ZigBee devices in the first place?


A SmartThings hub can be used to control devices directly using Z-wave and Zigbee, or “indirectly” using TCP-IP. The latter is the case for WiFi devices like Sonoff WiFi devices, Chamberlain garage door controllers, etc. DTHs and SmartApps are available to facilitate this.