Last active
October 15, 2024 12:59
-
-
Save thxthx0/c22555f6ec25c3367264729a0ff74dce to your computer and use it in GitHub Desktop.
Tasmota Script Ver. a for QS-WiFi-D01-TRIAC 150W 1CH-Dimmer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>D | |
sw=0 | |
tmp=0 | |
cnt=0 | |
tmr=0 | |
hold=0 | |
pwrt=0 | |
slid=0 | |
dim="" | |
doff="FF550005DC0A" | |
splo=2 ;short press lo limit | |
spup=10 ;short press up limit | |
ddir=0 ;dim dir 0/1 | |
dmul=2.2 ;dim multipl 1..2.55 | |
dstp=2 ;dim step/speed 1..5 | |
dlo=15 ;dim lolimit min.0 | |
dup=95 ;dim uplimit max.100 | |
dval=50 ;start dim level 0..100 | |
>B | |
print > Wifi-1CH-Dimmer-Script v2.0a < | |
print >> QS-WiFi-D01 150W Dimmer << | |
;hide cnt webui | |
->WebSensor1 0 | |
;reset cnt@teleperiod | |
->SetOption79 1 | |
->Baudrate 9600 | |
;boot sequ | |
=#snddim(dval) | |
delay(1000) | |
->SerialSend5 %doff% | |
=>Power1 0 | |
>F | |
cnt=pc[1] | |
if chg[cnt]>0 | |
;sw press | |
then sw=1 | |
else sw=0 | |
;sw not pressed | |
endif | |
; 100ms timer | |
tmr+=1 | |
; short press | |
if sw==0 | |
and tmr>splo | |
and tmr<spup | |
then | |
pwrt^=1 | |
;change on/off | |
if pwrt>0 | |
then | |
=#snddim(dval) | |
=>Power1 1 | |
else | |
->SerialSend5 %doff% | |
=>Power1 0 | |
endif | |
endif | |
; long press | |
if sw>0 | |
then | |
if tmr>spup | |
then | |
hold=1 | |
;off then on | |
if pwrt==0 | |
then | |
pwrt=1 | |
endif | |
;dim if on&hold | |
if pwrt>0 | |
then | |
if ddir>0 | |
then | |
;incr dimlevel | |
dval+=dstp | |
if dval>dup | |
then | |
;upper limit | |
dval=dup | |
endif | |
else | |
;decr dimlevel | |
dval-=dstp | |
if dval<dlo | |
then | |
;lower limit | |
dval=dlo | |
endif | |
endif | |
endif | |
endif | |
else | |
tmr=0 | |
if hold>0 | |
then | |
hold=0 | |
;change dim dir | |
ddir^=1 | |
endif | |
endif | |
if chg[dval]>0 | |
then | |
=#snddim(dval) | |
=>Dimmer %dval% | |
endif | |
>E | |
; slider | |
slid=Dimmer | |
if chg[slid]>0 | |
then | |
; dim per slider | |
if slid>0 | |
then | |
dval=slid | |
else | |
pwrt=0 | |
endif | |
endif | |
>P | |
; on/off webui | |
if pwr[1]>0 | |
then | |
pwrt=1 | |
dim="FF55"+hn(dval*dmul)+"05DC0A" | |
->SerialSend5 %dim% | |
else | |
pwrt=0 | |
->SerialSend5 %doff% | |
endif | |
; subroutine | |
#snddim(tmp) | |
dim="FF55"+hn(tmp*dmul)+"05DC0A" | |
->SerialSend5 %dim% | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
Thank you for your quick reply and nice script. I like the combination of switch and web interface operation.
After looking into the script it appears that it is not a firmware issue but just a functional requirement.
According to the script: After boot or restart the dimvalue gets a preset and after 1 second the dimmer turns OFF and after a while it goes always ON with the actual slider value.
I assume that the intention was to see if the dimmer is alive? It seems odd to me because the dimmer does not stay to the init varable value.
My requirement is that the dimmer restores the state it had before powerup or restart.
To accomplish both requirements I made some changes in the script. My lines are commented with “EML”
For those who are interested:
;EML begin
;=#senddim(dimval)
;delay(1000)
;->SerialSend5 %doff%
;=>Power1 0
;EML end
; 100ms timer
tmr+=1
; short press
if sw==0
and tmr>shortprl
and tmr<shortpru
then
powert^=1
;change on/off
if powert>0
then
=#senddim(dimval)
=>Power1 1
else
->SerialSend5 %doff%
=>Power1 0
endif
endif
; long press
if sw>0
then
if tmr>shortpru
then
hold=1
;off then on
if powert==0
then
powert=1
endif
;dim if on&hold
if powert>0
then
if dimdir>0
then
;incr dimlevel
dimval+=dimstp
if dimval>dimul
then
;upper limit
dimval=dimul
endif
else
;decr dimlevel
dimval-=dimstp
if dimval<dimll
then
;lower limit
dimval=dimll
endif
endif
endif
endif
else
tmr=0
if hold>0
then
hold=0
;change dim dir
dimdir^=1
endif
endif
if chg[dimval]>0
then
=#senddim(dimval)
=>Dimmer %dimval%
endif
if chg[slider]>0
then
; dim per sliderer
if slider>0
then
dimval=slider
else
powert=0
endif
endif
else ;EML
bootst=0 ;EML
endif ;EML
; on/off webui
if pwr[1]>0
then
powert=1
dim="FF55"+hn(dimval*dimmlp)+"05DC0A"
->SerialSend5 %dim%
else
powert=0
->SerialSend5 %doff%
endif
; subroutine
#senddim(tmp)
dim="FF55"+hn(tmp*dimmlp)+"05DC0A"
->SerialSend5 %dim%