Skip to content

Instantly share code, notes, and snippets.

@thxthx0
Last active November 26, 2021 17:21
Show Gist options
  • Save thxthx0/ce7f72ea75ab82be2704c9536ea77bf7 to your computer and use it in GitHub Desktop.
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%
#
@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