Skip to content

Instantly share code, notes, and snippets.

@thxthx0
Last active November 26, 2021 17:21
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save thxthx0/ce7f72ea75ab82be2704c9536ea77bf7 to your computer and use it in GitHub Desktop.
Tasmota Script for WiFi-2Channel-Dimmer QS-WiFi-D02-2C or MS-105B-220
;WiFi-2CH-Dimmer v1.3
;QS-WiFi-D02-2C
;MS-105B
>D
sw1=0
sw2=0
x=0
cn1=0
cn2=0
tm1=0
tm2=0
h1=0
h2=0
t1=0
t2=0
sl1=0
sl2=0
di=""
pl=2
pu=10
dd1=0
dd2=0
mp=2.2
sp=2
ll=15
ul=95
dv1=70
dv2=70
p1=0
p2=0
>B
=>Counter1 0
=>Counter2 0
=>Baudrate 9600
=#sd1(dv1)
delay(1000)
=#sd1(0)
=#sd2(0)
>F
cn1=pc[1]
cn2=pc[2]
if chg[cn1]>0
then sw1=1
else sw1=0
endif
if chg[cn2]>0
then sw2=1
else sw2=0
endif
tm1+=1
tm2+=1
if sw1==0
and tm1>pl
and tm1<pu
then
t1^=1
if t1==1
then
=#sd1(dv1)
else
=#sd1(0)
endif
endif
if sw2==0
and tm2>pl
and tm2<pu
then
t2^=1
if t2==1
then
=#sd2(dv2)
else
=#sd2(0)
endif
endif
if sw1>0
then
if h1==0
then
dd1^=1
endif
if tm1>pu
then
h1=1
if t1>0
then
if dd1>0
then
dv1+=sp
if dv1>ul
then
dv1=ul
endif
=#sd1(dv1)
else
dv1-=sp
if dv1<ll
then
dv1=ll
endif
=#sd1(dv1)
endif
endif
endif
else
tm1=0
h1=0
endif
if sw2>0
then
if h2==0
then
dd2^=1
endif
if tm2>pu
then
h2=1
if t2>0
then
if dd2>0
then
dv2+=sp
if dv2>ul
then
dv2=ul
endif
=#sd2(dv2)
else
dv2-=sp
if dv2<ll
then
dv2=ll
endif
=#sd2(dv2)
endif
endif
endif
else
tm2=0
h2=0
endif
>E
sl1=Channel1
if chg[sl1]>0
then
if sl1>0
then
dv1=sl1
=#sd1(dv1)
else
t1=0
=#sd1(0)
endif
endif
sl2=Channel2
if chg[sl2]>0
then
if sl2>0
then
dv2=sl2
=#sd2(dv2)
else
t2=0
=#sd2(0)
endif
endif
p1=pwr[1]
if p1==1
then
t1=1
=#sd1(dv1)
else
t1=0
=#sd1(0)
endif
p2=pwr[2]
if p2==1
then
t2=1
=#sd2(dv2)
else
t2=0
=#sd2(0)
endif
#sd1(x)
di="FF5501"+hn(x*mp)+"0000000A"
=>SerialSend5 %di%
=>Channel1 %x%
#sd2(x)
di="FF550200"+hn(x*mp)+"00000A"
=>SerialSend5 %di%
=>Channel2 %x%
#
@yuraivan
Copy link

yuraivan commented Jul 7, 2020

Hello everyone!!!! I did everything according instruction.I have entered the script, the template and activated "Setoption68 1". In web interface I see all correct. Toggle 1 and 2 are working but my lamps not light(((((( What is the problem???

@yuraivan
Copy link

yuraivan commented Jul 8, 2020

Hello everyone!!!! I did everything according instruction.I have entered the script, the template and activated "Setoption68 1". In web interface I see all correct. Toggle 1 and 2 are working but my lamps not light(((((( What is the problem???

Sorry for this moment lamp lights everytime and dont turn off. In console I see turn on and off process

@SimasVejas
Copy link

This thread is probably dead but I will try.
I've successfully flashed LM1 chip with script enabled firmware. I've pasted the script and enabled Setoption 1. Everything looks ok in Tasmota. I can see two toggles for both channels, both sliders for dimming and two counters.
My problem - my lamps are always off despite of the status in tasmota. I've tried checking corresponding channels with multimeter and one of them reports ~10V when the lamp is on or off, and the other one is always 0. Using push button also doesn't work. If I push the button toggle status doesn't change and only the counter increases.
I've tried script in this thread and script available here - https://gist.github.com/maxela/64af0e0471aa59c1550b05d8c0d79802
Maybe I did something wrong? Any help would be appreciated...
Thank you!

@maxela
Copy link

maxela commented Sep 1, 2021

This thread is probably dead but I will try

There’s not much happening in this thread, but I get notified and usually I try to help.

Which device and which version of the tasmota firmware are you using?

@SimasVejas
Copy link

SimasVejas commented Sep 1, 2021

Hi, @maxela, thanks for a quick reply!

At first glance it looks like I'm using the same two channel dimmer that is displayed in this thread with LM1 chip but my version might be a bit different. I will attach a photo of the insides when I get back home from work.
I'm not 100% sure but I believe it was 9.5.

20210901_201115

@aceindy
Copy link

aceindy commented Sep 3, 2021

Just for info, i moved to esphome with this 2ch dimmer unit, it works a lot smoother.
https://community.home-assistant.io/t/qs-wifi-d01-triac-dimmer/149811/25?u=aceindy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment