Updated Script Cookbook (markdown)

Michael Ingraham 2019-08-24 09:01:53 -04:00
parent 54b74db9c6
commit 8ec9a7a7cb
1 changed files with 39 additions and 39 deletions

@ -1,8 +1,8 @@
<a id="top"></a> <a id="top"></a>
- [Scripting Language Example](#Scripting-Language-Example) - [Scripting Language Example](#Scripting-Language-Example)
- [Sensor Logging](#Sensor-Logging) - [Sensor Logging](#Sensor-Logging)
- [ePaper 29 Display with SGP30 and BME280](#ePaper-29-Display-with-SGP30-and-BME280) - [e-Paper 29 Display with SGP30 and BME280](#e-Paper-29-Display-with-SGP30-and-BME280)
- [ePaper 42 Display with SHT31 and BME280](#ePaper-42-Display-with-SHT31-and-BME280) - [e-Paper 42 Display with SHT31 and BME280](#e-Paper-42-Display-with-SHT31-and-BME280)
- [ILI 9488 Color LCD Display with BMP280 and VL5310X](#ILI-9488-Color-LCD-Display-with-BMP280-and-VL5310X) - [ILI 9488 Color LCD Display with BMP280 and VL5310X](#ILI-9488-Color-LCD-Display-with-BMP280-and-VL5310X)
- [LED Bar Display with WS2812 LED Chain](#LED-Bar-Display-with-WS2812-LED-Chain) - [LED Bar Display with WS2812 LED Chain](#LED-Bar-Display-with-WS2812-LED-Chain)
- [Multiple IR Receiver Synchronization](#Multiple-IR-Receiver-Synchronization) - [Multiple IR Receiver Synchronization](#Multiple-IR-Receiver-Synchronization)
@ -191,7 +191,7 @@ if upsecs%60==0
then then
ahum/=tcnt ahum/=tcnt
atemp/=tcnt atemp/=tcnt
=>Websend [184.106.153.149:80]/update?key=PYUZMVWCICBW492&field1=%atemp%&field2=%ahum% =>WebSend [_IP_]/update?key=PYUZMVWCICBW492&field1=%atemp%&field2=%ahum%
tcnt=0 tcnt=0
atemp=0 atemp=0
ahum=0 ahum=0
@ -352,9 +352,8 @@ endif
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
#### ePaper 29 Display with SGP30 and BME280 #### e-Paper 29 Display with SGP30 and BME280
Some vars are set from iobroker Some variables are set from ioBroker
DisplayText substituted to save script space
>**>D** >**>D**
hum=0 hum=0
@ -370,6 +369,7 @@ wr3=0
otmp=0 otmp=0
pwl=0 pwl=0
tmp=0 tmp=0
; DisplayText substituted to save script space
DT="DisplayText" DT="DisplayText"
; preset units in case they are not available ; preset units in case they are not available
punit="hPa" punit="hPa"
@ -382,7 +382,7 @@ tunit="C"
=>%DT% [x0y20h296x0y40h296] =>%DT% [x0y20h296x0y40h296]
>**>T** >**>T**
; get tele vars ; get telemetry sensor values
temp=BME280#Temperature temp=BME280#Temperature
hum=BME280#Humidity hum=BME280#Humidity
press=BME280#Pressure press=BME280#Pressure
@ -393,7 +393,7 @@ tunit=TempUnit
punit=PressureUnit punit=PressureUnit
>**>S** >**>S**
// update display every teleperiod time // update display every [`TelePeriod`](Commands#teleperiod)
if upsecs%tper==0 if upsecs%tper==0
then then
dp2 dp2
@ -422,14 +422,13 @@ endif
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
#### ePaper 42 Display with SHT31 and BME280 #### e-Paper 42 Display with SHT31 and BME280
this script shows 2 graphs some local sensors, and a power statistics on an 4.2 inch epaper This script shows 2 graphs on an 4.2 inch e-Paper display: 1. some local sensors, and 2. power statistics
the first graph is the battery level of a solar battery (tesla powerwall 2) - The first graph is the battery level of a solar battery (Tesla PowerWall 2)
the second shows the solar yield in watts of the roof panels - The second graph shows the solar yield of the roof panels in Watts
also special is the display of daily and weekly averages (via moving average) of all power IO of the house. - Another special feature is that this script displays daily and weekly averages (via moving average) of all power IO of the house.
as the display is a full update panel it is updated only once a minute - Since the display is a full update panel it is updated only once a minute
some values (like power meters) are set remotely from iobroker - Some values (like power meters) are set remotely from ioBroker
>**>D** >**>D**
hum=0 hum=0
@ -450,9 +449,10 @@ M:mezh=0 7
vzh=0 vzh=0
svzh=0 svzh=0
M:mvzh=0 7 M:mvzh=0 7
>
>hr=0 >hr=0
t1=0 t1=0
; DisplayText substituted to save script space
DT="DisplayText" DT="DisplayText"
>**>B** >**>B**
@ -483,19 +483,19 @@ dp0
=>%DT% [p5x360y75]%pwl% %% =>%DT% [p5x360y75]%pwl% %%
=>%DT% [p6x360y180]%wr1%W =>%DT% [p6x360y180]%wr1%W
=>%DT% [g0:%pwl%g1:%wr1%] =>%DT% [g0:%pwl%g1:%wr1%]
>
>=>%DT% [p24x75y230] %wr1% W : %-wr2% W : %-wr3% W >=>%DT% [p24x75y230] %wr1% W : %-wr2% W : %-wr3% W
=>%DT% [p-10x75y245]%ezh% kWh =>%DT% [p-10x75y245]%ezh% kWh
=>%DT% [p-10x75y260]%vzh% kWh =>%DT% [p-10x75y260]%vzh% kWh
=>%DT% [p-10x75y275]%ez1% kWh =>%DT% [p-10x75y275]%ez1% kWh
>
>t1=mezh*7 >t1=mezh*7
=>%DT% [p-10x150y245]: %t1% kWh =>%DT% [p-10x150y245]: %t1% kWh
t1=mvzh*7 t1=mvzh*7
=>%DT% [p-10x150y260]: %t1% kWh =>%DT% [p-10x150y260]: %t1% kWh
t1=mez1*7 t1=mez1*7
=>%DT% [p-10x150y275]: %t1% kWh =>%DT% [p-10x150y275]: %t1% kWh
>
>dp1 >dp1
t1=ezh-sezh t1=ezh-sezh
=>%DT% [p12x250y245]: %t1% kWh =>%DT% [p12x250y245]: %t1% kWh
@ -503,13 +503,13 @@ t1=vzh-svzh
=>%DT% [p12x250y260]: %t1% kWh =>%DT% [p12x250y260]: %t1% kWh
t1=ez1-sez1 t1=ez1-sez1
=>%DT% [p12x250y275]: %t1% kWh =>%DT% [p12x250y275]: %t1% kWh
>
>dp0 >dp0
=>%DT% [f2p5x320y250] %otmp%C =>%DT% [f2p5x320y250] %otmp%C
>
>=>%DT% [d] >=>%DT% [d]
endif endif
>
>hr=hours >hr=hours
if chg[hr]>0 if chg[hr]>0
and hr==0 and hr==0
@ -521,7 +521,7 @@ sezh=ezh
mvzh=vzh-svzh mvzh=vzh-svzh
svzh=vzh svzh=vzh
endif endif
>
>if sezh==0 >if sezh==0
then then
sez1=ez1 sez1=ez1
@ -534,10 +534,10 @@ endif
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
#### ILI 9488 Color LCD Display with BMP280 and VL5310X #### ILI 9488 Color LCD Display with BMP280 and VL5310X
Shows various energy graphs Shows various BMP280 energy graphs
display switches on and off with proximity sensor Turn display on and off using VL5310X proximity sensor to prevent burn-in
some vars are set from iobroker Some variables are set from ioBroker
>**>D** >**>D**
temp=0 temp=0
@ -550,6 +550,7 @@ otmp=0
pwl=0 pwl=0
tmp=0 tmp=0
dist=0 dist=0
; DisplayText substituted to save script space
DT="DisplayText" DT="DisplayText"
punit="hPa" punit="hPa"
tunit="C" tunit="C"
@ -567,15 +568,14 @@ hour=0
=>mp3track 4 =>mp3track 4
>**>T** >**>T**
; get some tele vars ; get some telemetry values
temp=BMP280#Temperature temp=BMP280#Temperature
press=BMP280#Pressure press=BMP280#Pressure
tunit=TempUnit tunit=TempUnit
punit=PressureUnit punit=PressureUnit
dist=VL53L0X#Distance dist=VL53L0X#Distance
> >
>; check proximity sensor to switch display on/off >; check proximity sensor to turn display on and off to prevent burn-in
; to prevent burn in
if dist>300 if dist>300
then then
if pwr[2]>0 if pwr[2]>0
@ -628,7 +628,7 @@ endif
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
#### LED Bar Display with WS2812 LED Chain #### LED Bar Display with WS2812 LED Chain
Used as display for solar house power input/output (+-5000 Watts) Used to display home's solar power input/output (+-5000 Watts)
>**>D** >**>D**
m:array=0 60 ;defines array for 60 led pixels m:array=0 60 ;defines array for 60 led pixels
@ -733,14 +733,14 @@ next
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
#### Multiple IR Receiver Synchronization #### Multiple IR Receiver Synchronization
Since I own a magic home with IR receiver I made a script to show how it works Shows how a Magic Home with IR receiver works
I have 2 magic home devices that should be synchronized so I send the commands also to a second magic home via websend Synchronizes 2 Magic Home devices by also sending the commands to a second Magic Home via [`WebSend`](Commands#websend)
**Script example using `if then else`** **Script example using `if then else`**
>; define (expand string section to 25 chars) >; expand default string length to be able to hold `WebSend [xxx.xxx.xxx.xxx]`
**>D 25** **>D 25**
istr="" istr=""
ws="websend [192.168.178.84]" ws="WebSend [_IP_]"
>; event section >; event section
**>E** **>E**
@ -806,10 +806,10 @@ endif
>istr="" >istr=""
**Script example using `switch case ends`** **Script example using `switch case ends`**
>; define (expand string section to 25 chars) >; expand default string length to be able to hold `WebSend [xxx.xxx.xxx.xxx]`
**>D** 25 **>D** 25
istr="" istr=""
ws="websend [192.168.178.84]" ws="WebSend [_IP_]"
>; event section >; event section
**>E** **>E**
@ -866,10 +866,10 @@ ends
#### Fast Polling #### Fast Polling
>; expand strings to hold websend >; expand default string length to be able to hold `WebSend [xxx.xxx.xxx.xxx]`
**>D 25** **>D 25**
sw=0 sw=0
ws="websend [192.168.178.86]" ws="WebSend [_IP_]"
timer=0 timer=0
hold=0 hold=0
toggle=0 toggle=0