Skip to content

Commit 892ac12

Browse files
authored
add missed commands to TOC (#1448)
follow-up for #1447
1 parent bc87ede commit 892ac12

File tree

1 file changed

+37
-19
lines changed

1 file changed

+37
-19
lines changed

docs/Scripting-Language.md

+37-19
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,8 @@ remark: state variable names used for IO in the web interface may not contain an
460460
`WSO_FORCEPLAIN` = 4 send line in plain (no table elements)
461461
`WSO_FORCEMAIN` = 8 send lines in main mode ($ mode)
462462

463-
#### Google Charts
463+
### Google Charts
464+
464465
google chart support requires arrays and to make sense also permanent arrays. Therefore on 4M Flash Systems the use of `USE_UFILESYS` is recommended while on 1 M Flash Systems the special EEPROM mode should be used (see above). other options may also be needed like `LARGE_ARRAYS`
465466

466467
draws a google chart with up to 4 data sets per chart
@@ -522,7 +523,8 @@ remark: state variable names used for IO in the web interface may not contain an
522523

523524

524525

525-
`>w` ButtonLabel
526+
### >w ButtonLabel
527+
526528
generates a button with the name "ButtonLabel" in Tasmota main menu.
527529
Clicking this button displays a web page with the HTML data of this section.
528530
all cmds like in >W apply here. these lines are refreshed frequently to show e.g. sensor values.
@@ -534,7 +536,8 @@ you may display files from the flash or SD filesystem by specifying the url: IP
534536
==Requires compiling with `#define SCRIPT_FULL_WEBPAGE`.==
535537

536538

537-
`>M`
539+
### >M
540+
538541
[Smart Meter Interface](Smart-Meter-Interface)
539542

540543
If a variable does not exist, `???` is displayed for commands
@@ -774,13 +777,15 @@ If you define a variable with the same name as a special variable that special v
774777
_**Recursion**_: If you execute a tasmota cmd in an >E section and this cmd itself executes >E you will get an infinite loop.
775778
this is disabled normally and enabled by the +> in case you know what you are doing
776779

777-
**Variable Substitution**
780+
### Variable Substitution
781+
778782
- A single percent sign must be given as `%%`
779783
- Variable replacement within commands is allowed using `%varname%`. Optionally, the decimal places precision for numeric values may be specified by placing a digit (`%Nvarname%`, N = `0..9`) in front of the substitution variable (e.g., `Humidity: %3hum%%%` will output `Humidity: 43.271%`)
780784
- instead of variables arbitrary calculations my be inserted by bracketing %N(formula)%
781785
- Linefeed, tab and carriage return may be defined by \n, \t and \r
782786

783-
**Special** commands:
787+
### Special commands:
788+
784789
`print` or `=>print` prints to the log for debugging
785790
A Tasmota MQTT RESULT message invokes the script's `E` section. Add `print` statements to debug a script.
786791

@@ -815,7 +820,8 @@ A Tasmota MQTT RESULT message invokes the script's `E` section. Add `print` stat
815820
`hsvrgb(h s v)` converts hue (0..360), saturation (0..100) and value (0..100) to RGB color
816821
`dt` display text command (if #define USE_DISPLAY)
817822

818-
**Subroutines and Parameters**
823+
### Subroutines and Parameters
824+
819825
`#name` names a subroutine. Subroutine is called with `=#name`
820826
`#name(param)` names a subroutine with a parameter.
821827
Each parameter variable must be declared in the '>D' section.
@@ -852,14 +858,14 @@ S
852858
print subroutine was executed
853859
```
854860

855-
**For loop** (loop count must not be less than 1, no direct nesting supported)
861+
### For loop (loop count must not be less than 1, no direct nesting supported)
856862

857863
```
858864
for var <from> <to> <inc>
859865
next
860866
```
861867

862-
**Switch selector** (numeric or string)
868+
### Switch selector (numeric or string)
863869

864870
```
865871
switch x
@@ -868,7 +874,8 @@ case b
868874
ends
869875
```
870876

871-
**Conditional Statements**
877+
### Conditional Statements
878+
872879
There are two syntax alternatives. You may **_NOT_** mix both formats.
873880

874881
```
@@ -906,7 +913,8 @@ Conditional expressions may be enclosed in parentheses. The statement must be on
906913
if ((a==b) and ((c==d) or (c==e)) and (s!="x"))
907914
```
908915

909-
**Mapping Function**
916+
### Mapping Function
917+
910918
```
911919
mp(x cond1 result1 cond2 result2 ... cond<n> result<n>)
912920
```
@@ -935,7 +943,8 @@ y=100
935943
```
936944

937945

938-
**E-mail**
946+
### >m E-mail
947+
939948
`#define USE_SENDMAIL`
940949
Enabling this feature also enables [Tasmota TLS](TLS) as `sendmail` uses SSL.
941950

@@ -972,15 +981,17 @@ $N attach a webcam picture from rambuffer number N (usually 1)
972981

973982
See [Scripting Cookbook Example](#send-e-mail)
974983

975-
**Subscribe, Unsubscribe**
984+
### MQTT Subscribe, Unsubscribe*
985+
976986
`#define SUPPORT_MQTT_EVENT`
977987
`subscribe` and `unsubscribe` commands are supported. In contrast to rules, no event is generated but the event name specifies a variable defined in `D` section and this variable is automatically set on transmission of the subscribed item
978988
within a script the subscribe cmd must be send with +> instead of =>
979989
the MQTT decoder may be configured for more space in user config overwrite by
980990
`#define MQTT_EVENT_MSIZE` xxx (default is 256)
981991
`#define MQTT_EVENT_JSIZE` xxx (default is 400)
982992

983-
**File System Support**
993+
### File System Support
994+
984995
`#define USE_UFILESYS`
985996
optional for SD_CARD:
986997
`#define USE_SDCARD`
@@ -1009,7 +1020,8 @@ The script itself is also stored on the file system with a default size of 8192
10091020
`frw(fr url)` read file from web url, if url is an immediate string it may be longer than max string size to support very long URLs.
10101021
`fcs(fr "del" index ec)` = gets non string from file: del = delimiter char or string, index = n´th element, ec = end character delimiter.
10111022

1012-
**Other commands** (+?? flash)
1023+
### Other commands (+?? flash)
1024+
10131025
`#define USE_FEXTRACT`
10141026
`fxt(fr ts_from ts_to col_offs accum array1 array2 ... arrayn)` read arrays from csv file from timestamp to timestamp with column offset and accumulate values into arrays1 .. N, assumes csv file with timestamp in 1. column and data values in columns 2 to n.
10151027
`fxto(...` same as above with time optimized access
@@ -1018,7 +1030,8 @@ The script itself is also stored on the file system with a default size of 8192
10181030
`tsn(tstamp)` convert timestamp to seconds
10191031
`s2t(seconds)` convert seconds to Tasmota timestamp
10201032

1021-
**Extended commands** (+0,9k flash)
1033+
### Extended commands (+0,9k flash)
1034+
10221035
`#define USE_SCRIPT_FATFS_EXT`
10231036
`fmd("fname")` make directory fname
10241037
`frd("fname")` remove directory fname
@@ -1030,7 +1043,8 @@ The script itself is also stored on the file system with a default size of 8192
10301043
`fra(array fr)` reads array from open file with fr (assumes tab delimited entries)
10311044
`fwa(array fr (a))` writes array to open file with fr (writes tab delimited entries and line feed at end) the optional a parameter ommits the linefeed for appending arrays
10321045

1033-
**ESP32 real Multitasking support**
1046+
### >t ESP32 real Multitasking support
1047+
10341048
`#define USE_SCRIPT_TASK`
10351049
enables support for multitasking scripts
10361050
res=ct(num timer core (prio) (stack))
@@ -1057,7 +1071,8 @@ print task1 on core %core%
10571071
>t2
10581072
print task2 on core %core%
10591073
1060-
**ESP32 Webcam support**
1074+
### ESP32 Webcam support
1075+
10611076
`#define USE_WEBCAM`
10621077
Template for AI THINKER CAM :
10631078
{"NAME":"AITHINKER CAM No SPI","GPIO":[4992,65504,65504,65504,65504,5088,65504,65504,65504,65504,65504,65504,65504,65504,5089,5090,0,5091,5184,5152,0,5120,5024,5056,0,0,0,0,4928,65504,5094,5095,5092,0,0,5093],"FLAG":0,"BASE":1}
@@ -1178,10 +1193,12 @@ remark: the Flash illumination LED is connected to GPIO4
11781193
```
11791194
11801195
## Scripting Cookbook
1196+
11811197
a valid script must start with >D in the first line!
11821198
some samples still contain comment lines before >D. This is no longer valid!
11831199
11841200
### simple example to start with
1201+
11851202
>D
11861203
; in this section you may define and or preset variables, there are numbers or strings.
11871204
; in contrast to rules you may choose any variable name
@@ -1223,6 +1240,7 @@ remark: the Flash illumination LED is connected to GPIO4
12231240
12241241
12251242
### Scripting Language Example
1243+
12261244
**Actually this code is too large**. This is only meant to show some of the possibilities
12271245
12281246
>D
@@ -2024,7 +2042,7 @@ Used to display home's solar power input/output (+-5000 Watts)
20242042
Shows how a Magic Home with IR receiver works
20252043
Synchronizes 2 Magic Home devices by also sending the commands to a second Magic Home via [`WebSend`](Commands.md#websend)
20262044
2027-
**Script example using `if then else`**
2045+
#### Script example using `if then else`
20282046
; expand default string length to be able to hold `WebSend [xxx.xxx.xxx.xxx]`
20292047
20302048
>D 25
@@ -2094,7 +2112,7 @@ Synchronizes 2 Magic Home devices by also sending the commands to a second Magic
20942112
20952113
istr=""
20962114
2097-
**Script example using `switch case ends`**
2115+
#### Script example using `switch case ends`
20982116
; expand default string length to be able to hold `WebSend [xxx.xxx.xxx.xxx]`
20992117
21002118
>D 25

0 commit comments

Comments
 (0)