Tasmota Dimmer RJWF-02A and Domoticz

Cheap inline dimmer

So the light in the living room was a little too bright, when we are just sitting on the couch. I had a Sonoff Basic installed on that lamp and needed an inline dimmer to replace it. This great page has a lot of devices which are supported by Tasmota so I went looking if Amazon has any of them.
After a little bit of looking I found this "Beauty".


Flashing Tasmota

This dimmer is a Tuya based device, so I was able to use Tuya-Convert to flash it without opening and soldering. I followed the procedure described on the page using my Debian powered laptop and it went without a hitch.

After flashing you can connect to the newly installed Tasmota device and setup Wifi, but you need to upgrade the device to a full Tasmota image, otherwise some options (e.g. Domoticz integration) are missing. OTA way of upgrading didn't work, I kept on getting errors. The manual way worked but you first have to flash tasmota_minimal.img and then a full one like tasmota-DE.img. After that you need to setup the right template and enable the dimming function, as described here.

Not so straight forward integration with Domoticz

After I was able to dim the light using the web interface of Tasmota, I wanted to integrate it with Domoticz.
I created a new Virtual switch of the type X10, this is the default, and then changed the Switch Type to Dimmer. I then took the IDX of the new virtual dimmer and configured the Tasmota with it. Then came the problem, I could not move the bar and dim the light. A look in the Domoticz protocol showed that Tasmota was giving it state out using MQTT interface to Domoticz, but I couldn't change the value in Domoticz. After I had a look around the net, this seems to be a bug in the implementation of the virtual devices of type X10.

I looked around other types of virtual devices and found LightwaveRF which had a working dimmer, e.g. I could move the dimmer bar. But this one didn't give out it's value over MQTT. No idea why.
I then came up with an idea, to simply create a script. This script gets triggered when the virtual dimmer changes, then it reads out it's value and publishes it over MQTT. For that I am using mosquitto_pub command from the Debian package mosquitto-clients.

return {
        on = {
                devices = {'Licht_Wohnzimmer'}

        execute = function(domoticz, triggeredItem)

            -- Controlling the Tasmota dimmer over MQTT, because other virtual dimmer is not working.

            if (domoticz.devices('Licht_Wohnzimmer').changed) then
                if (domoticz.devices('Licht_Wohnzimmer').state == 'On') then
                    domoticz.log('Sende MQTT Nachricht zu Licht_Wohnzimmer mit dem Dimmer-Wert ' .. domoticz.devices('Licht_Wohnzimmer').level)
                    command_dim = 'mosquitto_pub -h -t cmnd/Licht_Wohnzimmer/Dimmer -m ' .. domoticz.devices('Licht_Wohnzimmer').level
                domoticz.log('Sende MQTT Nachricht zu Licht_Wohnzimmer mit dem Dimmer-Wert 0.')
                    command_dim = 'mosquitto_pub -h -t cmnd/Licht_Wohnzimmer/Dimmer -m "0"'

This only works one way, Domoticz tells the dimmer it's value. The return value of the Tasmota dimmer is not read in, so the dimmer bar in Domoticz doesn't give you the actual value of the dimmer (if you changed it directly over the web interface). But this is fine by me, no need to over complicate things.

Happy Hacking!!!

License: CC BY-SA 4.0 Discuss on Mastodon