Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save KiLLeRRaT/4a65e30014b3c9fc74c2ff88d8295deb to your computer and use it in GitHub Desktop.
Save KiLLeRRaT/4a65e30014b3c9fc74c2ff88d8295deb to your computer and use it in GitHub Desktop.
WiFi-Dimmer-Script-v0.3 - Dimmer with toggle switch.txt
>D
sw=0
swprev=0
tmp=0
cnt=0
tmr=0
hold=0
powert=0
slider=0
dim=""
shortprl=2 ;short press lo limit
shortpru=10;short press up limit
dimdir=0 ;dim direction 0/1
dimmlp=2.2 ;dim multiplier 1..2.55
dimstp=2 ;dim step/speed 1..5
dimll=15 ;dim lower limit min. 0
dimul=95 ;dim upper limit max. 100
dimval=70 ;start dim level 0..100
>B
=>print > WiFi-Dimmer-Script-v0.3 <
=>Counter1 0
=>Baudrate 9600
; boot sequence
=#senddim(dimval)
delay(1000)
=#senddim(0)
>F
cnt=pc[1]
if chg[cnt]>0
; sw pressed
then
sw=1
else
sw=0
; sw not pressed
endif
; 100ms timer
tmr+=1
if swprev!=sw
then
swprev=sw
powert^=1
if powert==1
then
=#senddim(dimval)
else
=#senddim(0)
endif
endif
>E
slider=Dimmer
; slider change
if chg[slider]>0
then
; dim according slider
if slider>0
then
dimval=slider
else
powert=0
endif
endif
if pwr[1]==1
; on/off webui
then
powert=1
=#senddim(dimval)
else
powert=0
=#senddim(0)
endif
; subroutine dim
#senddim(tmp)
dim="FF55"+hn(tmp*dimmlp)+"05DC0A"
=>SerialSend5 %dim%
=>Dimmer %tmp%
#
@c3reeman
Copy link

c3reeman commented Dec 3, 2019

This is working great on the tasmota page Thankyou,

One thing I’m struggling with is using it through home assistant I set option19 1 for auto discover and it gets brought into home assistant no problem and I can use the dimmer slider etc... only problem is switching the light to “on/off” it doesn't work I’ve also noticed the state of the switch on/off isn’t represented either if the light is toggled on the hardwire switch.

Any help would be much appreciated

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