Skip to content

Commit d21f2b3

Browse files
authored
Merge pull request #1447 from mi-hol/patch-2
add to TOC
2 parents 5dff151 + d7609ba commit d21f2b3

File tree

1 file changed

+61
-32
lines changed

1 file changed

+61
-32
lines changed

docs/Scripting-Language.md

Lines changed: 61 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ If you're used to working with Visual Studio Code, you can use [this extension](
166166
## Script Sections
167167
_Section descriptors (e.g., `>E`) are **case sensitive**_
168168
a valid script must start with >D in the first line
169-
`>D ssize`
169+
170+
### >D ssize
171+
170172
`ssize` = optional max string size (default=19, max=48 unless increased with `#define SCRIPT_MAXSSIZE`)
171173
define and init variables here, must be the first section, no other code allowed
172174
`p:vname`
@@ -199,29 +201,35 @@ therefore when specifing permanent variables, add newly defined ones always at t
199201
Memory is dynamically allocated as a result of the D section.
200202
Copying a string to a number or reverse is supported
201203

202-
`>B`
204+
### >B
205+
203206
executed on BOOT time before sensors are initialized and on save script
204207

205-
`>BS`
208+
### >BS
209+
206210
executed on BOOT time after sensors are initialized
207211

208-
`>E`
212+
### >E
209213
Executed when a Tasmota MQTT `RESULT` message is received, e.g., on `POWER` change. Also Zigbee reports to this section.
210214

211-
`>F`
215+
### >F
212216
Executed every 100 ms
213217

214-
`>S`
218+
### >S
219+
215220
Executed every second
216221

217-
`>R`
222+
### >R
223+
218224
Executed on restart. p vars are saved automatically after this call
219225

220-
`>T`
226+
### >T
227+
221228
Executed at least at [`TelePeriod`](Commands.md#teleperiod) time (`SENSOR` and `STATE`) but mostly faster up to every 100 ms, only put `tele-` vars in this section
222229
Remark: JSON variable names (like all others) may not contain math operators like - , you should set [`SetOption64 1`](Commands.md#setoption64) to replace `-` (_dash_) with `_` (_underscore_). Zigbee sensors will not report to this section, use E instead.
223230

224-
`>H`
231+
### >H
232+
225233
Alexa Hue interface (up to 32 virtual hue devices) *([example](#hue-emulation))*
226234
`device`,`type`,`onVars`
227235
Remark: hue values have a range from 0-65535. Divide by 182 to assign HSBcolors hue values.
@@ -233,7 +241,8 @@ Remark: hue values have a range from 0-65535. Divide by 182 to assign HSBcolors
233241
!!! example
234242
`lamp1,E,on=pwr1,hue=hue1,sat=sat1,bri=bri1,ct=ct1`
235243

236-
`>h` passcode
244+
### >h passcode
245+
237246
Siri Homekit interface (up to 16 virtual Homekit devices)
238247
passcode = 111-11-111 keep this format, numbers 0-9
239248
`name`,`type`,`opt`,`var1`,`var2`...
@@ -281,29 +290,38 @@ the special variables
281290
lib_extra_dirs
282291
lib/libesp32_div
283292

284-
`>U`
293+
### >U
294+
285295
JSON messages from cmd status arrive here
286296

287-
`>C`
297+
### >C
298+
288299
HTML messages arrive here (on web user io event, (if defined USE_HTML_CALLBACK))
289300

290-
`>G`
301+
### >G
302+
291303
global variable updated section
292304

293-
`>P`
305+
### >P
306+
294307
any power change triggers here (if defined SCRIPT_POWER_SECTION)
295308

296-
`>jp`
309+
### >jp
310+
297311
https webpage json parse arrives here
298312

313+
### >ti#
314+
299315
`>ti1`
300316
`>ti2`
301317
`>ti3`
302-
`>ti4`
318+
303319
ticker callback after timer expiration
304320

305321

306-
`>b` _(note lower case)_
322+
### >b
323+
324+
_(note lower case)_
307325
executed on button state change
308326

309327
`bt[x]`
@@ -325,10 +343,12 @@ read button state (x = `1.. MAX_KEYS`)
325343
endif
326344
```
327345

328-
`>J`
346+
### >J
347+
329348
The lines in this section are published via MQTT in a JSON payload on [TelePeriod](Commands.md#teleperiod). ==Requires compiling with `#define USE_SCRIPT_JSON_EXPORT `.==
330349

331-
`>W`
350+
### >W
351+
332352
The lines in this section are displayed in the web UI main page. ==Requires compiling with `#define USE_SCRIPT_WEB_DISPLAY`.==
333353

334354
You may put any html code here.
@@ -339,11 +359,14 @@ You may put any html code here.
339359
- HTML statements preceded with a `$` are displayed in the main section
340360
- USER IO elements are displayed at the top of the page
341361

342-
optionally these sections may be used
343-
`>WS`
362+
## optionally these sections may be used
363+
364+
### >WS
365+
344366
- HTML statements are displayed in the sensor section of the main page
345367

346-
`>WM`
368+
### >WM
369+
347370
- HTML statements are displayed in the main section of the main page
348371

349372
for next loops are supported to repeat HTML code (precede with % char)
@@ -364,35 +387,41 @@ insa(array) in any position insert all elements from an array comma separated
364387
A web user interface may be generated containing any of the following elements:
365388

366389
remark: state variable names used for IO in the web interface may not contain an underscore.
367-
**Button:**
390+
391+
#### Button
392+
368393
`bu(vn txt1 txt2)` (up to 4 buttons may be defined in one row)
369394
`vn` = name of variable to hold button state
370395
`txt1` = text of ON state of button
371396
`txt2` = text of OFF state of button
372397

373-
**Pulldown:**
398+
#### Pulldown
399+
374400
`pd(vn label (xs) txt1 txt2 ... txtn)`
375401
`vn` = name of variable to hold selected state
376402
`label` = label text
377403
`xs` = optional xs (default 200)
378404
`txt1` = text of 1. entry
379405
`txt2` = text of 2. entry and so on
380406

381-
**Radio button:**
407+
#### Radio button
408+
382409
`rb(vn label (xs) txt1 txt2 ... txtn)`
383410
`vn` = name of variable to hold selected state
384411
`label` = label text
385412
`xs` = optional xs (default 200)
386413
`txt1` = text of 1. entry
387414
`txt2` = text of 2. entry and so on
388415

389-
**Checkbox:**
416+
#### Checkbox
417+
390418
`ck(vn txt (xs))`
391419
`vn` = name of variable to hold checkbox state
392420
`txt` = label text
393421
`xs` = optional xs (default 200)
394422

395-
**Slider:**
423+
#### Slider
424+
396425
`sl(min max vn ltxt mtxt rtxt)`
397426
`min` = slider minimum value
398427
`max` = slider maximum value
@@ -401,20 +430,20 @@ remark: state variable names used for IO in the web interface may not contain an
401430
`mtxt` = label middle of slider
402431
`rtxt` = label right of slider
403432

404-
**Text Input:**
433+
#### Text Input
405434
`tx(vn lbl (xs) (type min max))`
406435
`vn` = name of string variable to hold text state
407436
`lbl` = label text
408437
`xs` = optional xs (default 200)
409438
`type min max` = optional strings type = e.g "datetime-local" for date+time selector, min, max = date-time min max range
410439

411-
**Time Input:**
440+
#### Time Input
412441
`tm(vn lbl (xs))`
413442
`vn` = name of number variable to hold time HHMM as number e.g. 1900 means 19:00
414443
`lbl` = label text
415444
`xs` = optional xs (default 70)
416445

417-
**Number Input:**
446+
#### Number Input
418447
`nm(min max step vn txt (xs) (prec))`
419448
`min` = number minimum value
420449
`max` = number maximum value
@@ -424,14 +453,14 @@ remark: state variable names used for IO in the web interface may not contain an
424453
`xs` = optional xs (default 200)
425454
`prec` = optional number precision (default 1)
426455

427-
**special html options:**
456+
#### special html options
428457
`so(flags)`
429458
`WSO_NOCENTER` = 1 force elements not centered
430459
`WSO_NODIV` = 2 force elements not in extra \<div\>
431460
`WSO_FORCEPLAIN` = 4 send line in plain (no table elements)
432461
`WSO_FORCEMAIN` = 8 send lines in main mode ($ mode)
433462

434-
**Google Charts:**
463+
#### Google Charts
435464
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`
436465

437466
draws a google chart with up to 4 data sets per chart

0 commit comments

Comments
 (0)