[RELEASE] Tasmota RGBW LED Light Bulb Driver

Hi @damon.dinsmore, nice to hear you're moving over to using my firmware :slight_smile: I could add support of ifan02/ifan03 in my new driver, I don't have one though and right now nothing of what I order here in China is being delivered.
My driver is different in philosophy to many others, I have it very performant and fast (when I put down my first foot in a room, my lights are on), but it has MANY lines of code. Most of those lines are not active when performing or receiving actions/updates since they are there for auto-configuration and setup, among other things. If you don't mind a driver such as that, I'd be happy to add iFan support.
For that I'd like the output of "status 0" in the Tasmota Console. This is the information I use for auto-detecting which device it is. The output of that together with your drivers and the template for the devices you use should be enough to get it working.

My driver contains entries like these for all directly supported devices:

[typeId: 'brilliantsmart-20676-plug' ,
        name: 'BrilliantSmart 20676 USB Charger Plug',
        template: '{"NAME":"Brilliant20676","GPIO":[0,0,0,0,0,21,0,0,0,52,90,0,0],"FLAG":0,"BASE":18}',
        installCommands: [["SetOption81", "1"]],
        deviceLink: 'https://templates.blakadder.com/brilliantsmart_20676.html',
        open: ["TuyaSend4", "101,0"],
        stop: ["TuyaSend4", "101,1"],
        close: ["TuyaSend4", "101,2"],
],

The above is not a correct device entry, but it showcases the types of settings it can take. For a fan instead of open, stop, close there would be the different fan-mode commands. Do you use anything that needs TuyaSend? I saw a fan controller driver with that from you?

You can take a look at my current development drivers, the parent, and a child driver. There would be need for a child driver for fans, there is no built-in Generic Component Fan, but those are simple and you could even make your own the way you want it and just put that one as the driver for the child device created by the parent if you don't want the one I'll make.

What do you think? I'd love to collaborate on this and I'd love input from a fellow developer :slight_smile:

For others reading this, the above driver is not yet released and not supported, unless you want to live on the bleeding edge and is very technically minded, don't use it.

@markus, I like what you have done. I was hoping to find a way to get Tasmota to do what you and ericm has done without having to modify the firmware but now that you have gotten the firmware to use the original interface with some additions it meets my needs.

I like that I can add devices just using the device drivers and not have to use the app to make the devices work with Hubitat. This allows me to move a device with all of its rules, connections and other groups or apps without having to redo all of that. The ability to use ip address was huge as well as I run VLANS to protect my devices and computers from possible hacks. Thank you!

I don't use the TuyaSend command except for the one driver that someone had asked me to attempt and he never responded. So I'm not worried about that one.

The ifan02 is very straight forward and should be able to be converted in the way you suggest.

The ifan03 is much more complicated because we have to send the command and a beep command as it is not hardware linked in the ifan03. I had worked with Theo Arends to add that support and it works great but causes the response back to be messed up because I was using the backlog command. If you have a way to fix this I'm all for it and would love to see the fix as I'm sure that we would have used for this in other drivers as well. iFan03 can use the template layout as you show in the example above.

I have 2 ifan02 and 2 ifan03 and can use one of each for testing. I can't remember off hand but we may have to compile a specific version of the Tasmota firmware to get it to load on the iFan. Not use but I will try and load it on one of each to get up to version 8.1.0.

Also, there is light control for each so it may take 2 child devices.

I look forward to working with you on this.

Nice to hear!

Yes, that is something I do as well, but it is an "advanced" usage so not anything most people do. The issue are with child devices if they were added as components. Then you "can't" change the driver they use. You actually can, the restriction is just in the html, so easy enough to get around. My new driver doesn't add as component devices and if you as the user set the wrong driver, that is your own problem... Usually it shouldn't be changed anyway. So full flexibility.
With that said, this new driver of mine doesn't use the parent as anything except for things like parsing and handling the communication with Tasmota. The only capability of note is Presence, this is used to show if that the Tasmota device is online and active, or not. This would make a switch device which previously had no child devices to have a child device as the switch. It would be possible to add an option to do it differently, but I chose to do it this way because sometimes people want their switches to be shown as lights in Google Home/Alexa integrations and other such things. It allows for more flexibility without having to touch the parent.
I can also have only 1 parent.

That is why that option exists, for us with non-simple home networks...

That was rude of that person! Then we don't need to worry about that one.

Ok, we do it as you have it in your code to begin with, when I get an iFan03 I will see what I can do to improve it.

If that is needed, tell me what the compile options you need are and I'll include it in my build configuration as a special build.

If the light is reported as Power by Tasmota, it will be added as a child device automatically. No extra code needed. This is why I want to see the result of "Status 0" from both devices, that way I can see if my detection methods will work properly.

Likewise, if you have the time to look through my code, I'd be happy to hear your opinions as well! Everything is stitched together from multiple files when "building" the driver, so there's auto-generated comments in the code about that.

1 Like

@markus, Sorry I missed that you needed me to do that. Here it is:

ifan02 Status 0

05:09:07 CMD: status 0
05:09:07 RSL: STATUS = {"Status":{"Module":44,"FriendlyName":["Sonoff"],"Topic":"sonoff","ButtonTopic":"0","Power":0,"PowerOnState":3,"LedState":1,"SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0}}
05:09:07 RSL: STATUS1 = {"StatusPRM":{"Baudrate":115200,"GroupTopic":"sonoffs","OtaUrl":"http://thehackbox.org/tasmota/release/sonoff.bin","RestartReason":"Software/System restart","Uptime":"29T05:09:06","StartupUTC":"","Sleep":50,"CfgHolder":4617,"BootCount":81,"SaveCount":124,"SaveAddress":"F8000"}}
05:09:07 RSL: STATUS2 = {"StatusFWR":{"Version":"6.5.0(basic)","BuildDateTime":"2019-07-30T12:29:19","Boot":7,"Core":"2_5_2","SDK":"2.2.1(cfd48f3)"}}
05:09:07 RSL: STATUS3 = {"StatusLOG":{"SerialLog":2,"WebLog":2,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["WLAN-Devices",""],"TelePeriod":300,"Resolution":"558180C0","SetOption":["00008001","280500000100000000000000000000000000","00000000"]}}
05:09:07 RSL: STATUS4 = {"StatusMEM":{"ProgramSize":467,"Free":536,"Heap":27,"ProgramFlashSize":1024,"FlashSize":1024,"FlashChipId":"144051","FlashMode":3,"Features":["00000809","07002380","00000000","00000006","000000C0"]}}
05:09:07 RSL: STATUS5 = {"StatusNET":{"Hostname":"sonoff-7841","IPAddress":"192.168.50.101","Gateway":"192.168.50.1","Subnetmask":"255.255.254.0","DNSServer":"(IP unset)","Mac":"DC:4F:22:DB:9E:A1","Webserver":2,"WifiConfig":1}}
05:09:07 RSL: STATUS7 = {"StatusTIM":{"UTC":"Fri Jan 30 05:09:07 1970","Local":"Fri Jan 30 05:09:07 1970","StartDST":"Thu Jan 01 00:00:00 1970","EndDST":"Thu Jan 01 00:00:00 1970","Timezone":"+00:00","Sunrise":"07:23","Sunset":"16:43"}}
05:09:07 RSL: STATUS10 = {"StatusSNS":{"Time":"1970-01-30T05:09:07"}}
05:09:07 RSL: STATUS11 = {"StatusSTS":{"Time":"1970-01-30T05:09:07","Uptime":"29T05:09:06","Vcc":3.486,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"POWER1":"OFF","FanSpeed":0,"Wifi":{"AP":1,"SSId":"WLAN-Devices","BSSId":"34:8F:27:55:F7:48","Channel":11,"RSSI":94,"LinkCount":10,"Downtime":"0T00:01:06"}}}

ifan03 Status 0

03:42:08 CMD: status 0
03:42:08 RSL: STATUS = {"Status":{"Module":71,"FriendlyName":["TH Kitchen Fan"],"Topic":"sonoff","ButtonTopic":"0","Power":0,"PowerOnState":3,"LedState":1,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0}}
03:42:08 RSL: STATUS1 = {"StatusPRM":{"Baudrate":9600,"GroupTopic":"sonoffs","OtaUrl":"http://thehackbox.org/tasmota/release/sonoff.bin","RestartReason":"Power on","Uptime":"52T03:42:07","StartupUTC":"","Sleep":50,"CfgHolder":4617,"BootCount":19,"SaveCount":99,"SaveAddress":"F9000"}}
03:42:08 RSL: STATUS2 = {"StatusFWR":{"Version":"6.6.0.4(basic)","BuildDateTime":"2019-08-12T13:22:25","Boot":7,"Core":"2_5_2","SDK":"2.2.1(cfd48f3)"}}
03:42:08 RSL: STATUS3 = {"StatusLOG":{"SerialLog":0,"WebLog":2,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["WLAN-Devices",""],"TelePeriod":300,"Resolution":"558180C0","SetOption":["00008001","280500000100060000005A00000000000000","00020000"]}}
03:42:08 RSL: STATUS4 = {"StatusMEM":{"ProgramSize":471,"Free":532,"Heap":28,"ProgramFlashSize":1024,"FlashSize":1024,"FlashChipId":"144051","FlashMode":3,"Features":["00000809","87082383","003003A0","20021706","010001C0","00000001"]}}
03:42:08 RSL: STATUS5 = {"StatusNET":{"Hostname":"sonoff-4884","IPAddress":"192.168.50.103","Gateway":"192.168.50.1","Subnetmask":"255.255.254.0","DNSServer":"(IP unset)","Mac":"DC:4F:22:AA:33:14","Webserver":2,"WifiConfig":4}}
03:42:08 RSL: STATUS7 = {"StatusTIM":{"UTC":"Sun Feb 22 03:42:08 1970","Local":"Sun Feb 22 03:42:08 1970","StartDST":"Thu Jan 01 00:00:00 1970","EndDST":"Thu Jan 01 00:00:00 1970","Timezone":"+00:00","Sunrise":"06:46","Sunset":"17:21"}}
03:42:08 RSL: STATUS10 = {"StatusSNS":{"Time":"1970-02-22T03:42:08","Epoch":4506128}}
03:42:08 RSL: STATUS11 = {"StatusSTS":{"Time":"1970-02-22T03:42:08","Epoch":4506128,"Uptime":"52T03:42:07","UptimeSec":4506127,"Vcc":3.427,"Heap":28,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":0,"POWER1":"OFF","FanSpeed":0,"Wifi":{"AP":1,"SSId":"WLAN-Devices","BSSId":"34:8F:27:55:F7:48","Channel":11,"RSSI":76,"LinkCount":28,"Downtime":"0T00:02:55"}}}

@markus So in looking at my firmware that I compiled for the ifan02/03 I have my size down to 468kb

I'm about to backup and try to upload your hubitat firmware at 547kb

We will see what happens.... Well its successful on the ifan03....

Ok, I see that is an older Tasmota firmware, do follow the upgrade instructions for Tasmota. Using minimal etc...

Ok, that’s great

@markus, Ok so all firmware is updated and ready. Just need a driver now

Which template do you use? The one found here:

@markus

{"NAME":"Sonoff iFan03","GPIO":[17,255,0,255,0,0,29,33,23,56,22,24,0],"FLAG":0,"BASE":44}

Module 44 is for iFan02 and iFan 03 is module 71. Have you tried the one in the Tasmota Docs I linked to (which is module 71)? Is there a reason you don't use it?

I've ordered an iFan03, iFan02 doesn't exist anywhere in stock right now, but I guess I don't truly need that one. I don't really know when they will ship it, but we'll see. Since I don't have a fan to use, I'll just connect it to an incandescent lightbulb, that should do just as well for testing.

I'll see if maybe I can get this into my new driver sometime tomorrow, shouldn't take long.

@markus, I don't think module 71 existed for the ifan03 when I started BUT I do think I tried it and at the time the beep would not work when using 71 so I just kept with the custom one.

LOL on the light bulb. That will probably work. I have a few hundred Wemos D1 mini's here so I usually use one of those for testing. Whatever works works right?

Ok, SetOption67 indicates that the beep should work unless disabled when using module 71. None of this is critical to make the driver, I'll make it with what you use first, then a variant for the dropdown list selection without beep could be added.

Yes, I don't have that many, but a few, until I get my iFan03 I will test on one of those. That's a lot of Wemos D1 minis...

I look forward to testing the driver out. I did the same thing with a dropdown in the driver to allow the beep or not.

Yes I ordered a large batch as I make a lot of my own sensors. Water leak, pest control, and others.

Haven't had much time today, all meetings took longer than expected... I did look at your driver, you're using 'capability "Switch Level"' to represent the fan speed with a number, is that needed for you? I find it non-standard and possibly redundant, but if you have a use for it, it could be added.

For the buzzer, I've been thinking to use a rule to catch the event and send the buzzer command, that way I don't have to send commands differently. The rule can be set automatically by the driver based on which device type is selected.

Then I understand, I normally get whatever I order in electronics from Shenzhen in 2-3 days, so don't need a large stock. Though with the current situation I'm happy I do have a lot of things to tinker with at home already.

EDIT: @damon.dinsmore I got a few moments to update the driver for iFan02 and iFan03, it is not tested, do test the beep. I did add the choice between using module 44 and module 71, tell me which one works best and I'll remove the other one. The child device driver can be found here. The parent is here. And the OPTIONAL App is here. As I mentioned before, this is built with my new Universal driver currently in Alpha. To set the device settings, choose the device type in "Device Configuration". Save Preferences and press Configure. It should work without Configure, but sometimes not all commands are received by Tasmota due to a reboot. I don't catch this automatically yet, so Configure can be needed.

@markus

switchlevel is not needed any more fan level should be good. The iFan can only do low, med and high so I was using that as a way to show where it was but do what works here. I don't need that part.

I like setting the buzzer as a rule. that's a nice workaround. Especially since the driver can set that. It would also allow for control when using the tasmota interface to work properly.

As far as the 44 / 71 I think I remember that using my template allowed me to use the remote control or allowed the beep to be set from the remote and 71 did not allow that. I will have to test that once we have a working beep.

I loaded the app and the drivers. I was able to create the Fan parent and it added the fan and light. The light works, the fan works by setting the speed. The beep would not work no matter which 44/71 beep handler that I used. I did make sure to configure and check the device to make sure it was using the correct template. So something is not quite working correctly.

So except for the been the driver is working perfectly for this. Getting close!!

Ok, then we skip that part

Good to hear :slight_smile:

Ok, what do you get when you run "rule1" in the console?

RESULT = {"Rule1":"OFF","Once":"OFF","StopOnError":"OFF","Free":428,"Rules":"ON Fanspeed#Data>=1 DO Buzzer %value%; ENDON ON Fanspeed#Data==0 DO Buzzer 1; ENDON"}

try to activate the rule with "rule1 1" and see if the beep works?

RESULT = {"Rule1":"ON","Once":"OFF","StopOnError":"OFF","Free":428,"Rules":"ON Fanspeed#Data>=1 DO Buzzer %value%; ENDON ON Fanspeed#Data==0 DO Buzzer 1; ENDON"}

No beep

So the rule doesn't activate when you change fan speed?