mirror of https://github.com/arendst/Tasmota.git
Updated Script Cookbook (markdown)
parent
ecae9e48d6
commit
2cb0205d31
|
@ -524,7 +524,108 @@ endif
|
|||
[Back To Top](#top)
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
#### Ledbar Display with WS2812 ledchain
|
||||
used as display for solar house power input/output (+-5000 Watts)
|
||||
|
||||
>D
|
||||
m:array=0 60 ;defines array for 60 led pixels
|
||||
cnt=0
|
||||
val=0
|
||||
ind=0
|
||||
; rgb values for grid
|
||||
colr1=0x050000
|
||||
colr2=0x050100
|
||||
colg1=0x000300
|
||||
colg2=0x020300
|
||||
ledbar=0
|
||||
blue=64
|
||||
pixels=60
|
||||
steps=10
|
||||
div=0
|
||||
tog=0
|
||||
max=5000
|
||||
min=-5000
|
||||
pos=0
|
||||
|
||||
>B
|
||||
div=pixels/steps
|
||||
=#prep
|
||||
ws2812(array)
|
||||
|
||||
; ledbar is set from broker
|
||||
>S
|
||||
if ledbar<min
|
||||
then ledbar=min
|
||||
endif
|
||||
|
||||
if ledbar>max
|
||||
then ledbar=max
|
||||
endif
|
||||
|
||||
pos=(ledbar/max)*(pixels/2)
|
||||
if ledbar>0
|
||||
then
|
||||
pos+=(pixels/2);
|
||||
if pos>pixels-1
|
||||
then pos=pixels
|
||||
endif
|
||||
else
|
||||
pos+=(pixels/2)+1
|
||||
if pos>pixels-1
|
||||
then pos=1
|
||||
endif
|
||||
endif
|
||||
|
||||
if pos<1
|
||||
or pos>pixels
|
||||
then pos=1
|
||||
endif
|
||||
|
||||
=#prep
|
||||
|
||||
if ledbar==0
|
||||
then
|
||||
array[pos]=blue
|
||||
array[pos-1]=blue
|
||||
else
|
||||
array[pos]=blue
|
||||
endif
|
||||
|
||||
; only used if power is off
|
||||
; so lets may be used normally if on
|
||||
if pwr[1]==0
|
||||
then
|
||||
ws2812(array)
|
||||
endif
|
||||
|
||||
|
||||
#prep
|
||||
for cnt 1 pixels 1
|
||||
ind+=1
|
||||
if ind>div
|
||||
then ind=1
|
||||
tog^=1
|
||||
endif
|
||||
|
||||
if cnt<=pixels/2
|
||||
then
|
||||
if tog>0
|
||||
then val=colr1
|
||||
else val=colr2
|
||||
endif
|
||||
else
|
||||
if tog>0
|
||||
then val=colg1
|
||||
else val=colg2
|
||||
endif
|
||||
endif
|
||||
;->print %cnt% %tog%
|
||||
array[cnt]=val
|
||||
next
|
||||
|
||||
>R
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
#### Multiple IR Receiver Synchronization
|
||||
since i own a magic home with ir receiver i made a script to show how it works
|
||||
i have 2 magic home devices that should be synchronized so i send the commands also to a second magic home via websend
|
||||
|
@ -660,75 +761,74 @@ endif
|
|||
|
||||
#### Switching By Recognizing Mains Power Frequency
|
||||
[#6085 (comment)](../issues/6085#issuecomment-512353010)
|
||||
>D
|
||||
sw1=0
|
||||
sw2=0
|
||||
cnt1=0
|
||||
cnt2=0
|
||||
timer1=0
|
||||
timer2=0
|
||||
toggle1=0
|
||||
toggle2=0
|
||||
>D
|
||||
sw1=0
|
||||
sw2=0
|
||||
cnt1=0
|
||||
cnt2=0
|
||||
timer1=0
|
||||
timer2=0
|
||||
toggle1=0
|
||||
toggle2=0
|
||||
|
||||
>B
|
||||
=>print "WiFi 2-Gang Switch Script"
|
||||
>B
|
||||
=>print "WiFi 2-Gang Switch Script"
|
||||
|
||||
>F
|
||||
; Counter1/2 and Relay1/2 configured in template
|
||||
cnt1=pc[1]
|
||||
cnt2=pc[2]
|
||||
>F
|
||||
; Counter1/2 and Relay1/2 configured in template
|
||||
cnt1=pc[1]
|
||||
cnt2=pc[2]
|
||||
|
||||
if chg[cnt1]>0
|
||||
then
|
||||
if chg[cnt1]>0
|
||||
then
|
||||
; counter1 has changed, switch is on
|
||||
sw1=1
|
||||
else
|
||||
; no change switch is off
|
||||
sw1=0
|
||||
endif
|
||||
sw1=1
|
||||
else
|
||||
; no change switch is off
|
||||
sw1=0
|
||||
endif
|
||||
|
||||
if chg[cnt2]>0
|
||||
then
|
||||
; counter2 has changed, switch is on
|
||||
sw2=1
|
||||
else
|
||||
; no change switch is off
|
||||
sw2=0
|
||||
endif
|
||||
if chg[cnt2]>0
|
||||
then
|
||||
; counter2 has changed, switch is on
|
||||
sw2=1
|
||||
else
|
||||
; no change switch is off
|
||||
sw2=0
|
||||
endif
|
||||
|
||||
; 100 ms timer
|
||||
timer1+=1
|
||||
timer2+=1
|
||||
; 100 ms timer
|
||||
timer1+=1
|
||||
timer2+=1
|
||||
|
||||
if sw1==0
|
||||
and timer1>2
|
||||
and timer1<30
|
||||
then
|
||||
;=>print short press1
|
||||
toggle1^=1
|
||||
=>Power1 %toggle1%
|
||||
endif
|
||||
if sw1==0
|
||||
and timer1>2
|
||||
and timer1<30
|
||||
then
|
||||
;=>print short press1
|
||||
toggle1^=1
|
||||
=>Power1 %toggle1%
|
||||
endif
|
||||
|
||||
if sw1==0
|
||||
then
|
||||
timer1=0
|
||||
endif
|
||||
if sw1==0
|
||||
then
|
||||
timer1=0
|
||||
endif
|
||||
|
||||
if sw2==0
|
||||
and timer2>2
|
||||
and timer2<30
|
||||
then
|
||||
;=>print short press2
|
||||
toggle2^=1
|
||||
=>Power2 %toggle2%
|
||||
endif
|
||||
if sw2==0
|
||||
and timer2>2
|
||||
and timer2<30
|
||||
then
|
||||
;=>print short press2
|
||||
toggle2^=1
|
||||
=>Power2 %toggle2%
|
||||
endif
|
||||
|
||||
if sw2==0
|
||||
then
|
||||
timer2=0
|
||||
endif
|
||||
if sw2==0
|
||||
then
|
||||
timer2=0
|
||||
endif
|
||||
|
||||
[Back To Top](#top)
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue