You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Scripting-Language.md
+61-32Lines changed: 61 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -166,7 +166,9 @@ If you're used to working with Visual Studio Code, you can use [this extension](
166
166
## Script Sections
167
167
_Section descriptors (e.g., `>E`) are **case sensitive**_
168
168
a valid script must start with >D in the first line
169
-
`>D ssize`
169
+
170
+
### >D ssize
171
+
170
172
`ssize` = optional max string size (default=19, max=48 unless increased with `#define SCRIPT_MAXSSIZE`)
171
173
define and init variables here, must be the first section, no other code allowed
172
174
`p:vname`
@@ -199,29 +201,35 @@ therefore when specifing permanent variables, add newly defined ones always at t
199
201
Memory is dynamically allocated as a result of the D section.
200
202
Copying a string to a number or reverse is supported
201
203
202
-
`>B`
204
+
### >B
205
+
203
206
executed on BOOT time before sensors are initialized and on save script
204
207
205
-
`>BS`
208
+
### >BS
209
+
206
210
executed on BOOT time after sensors are initialized
207
211
208
-
`>E`
212
+
### >E
209
213
Executed when a Tasmota MQTT `RESULT` message is received, e.g., on `POWER` change. Also Zigbee reports to this section.
210
214
211
-
`>F`
215
+
### >F
212
216
Executed every 100 ms
213
217
214
-
`>S`
218
+
### >S
219
+
215
220
Executed every second
216
221
217
-
`>R`
222
+
### >R
223
+
218
224
Executed on restart. p vars are saved automatically after this call
219
225
220
-
`>T`
226
+
### >T
227
+
221
228
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
222
229
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.
223
230
224
-
`>H`
231
+
### >H
232
+
225
233
Alexa Hue interface (up to 32 virtual hue devices) *([example](#hue-emulation))*
226
234
`device`,`type`,`onVars`
227
235
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
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 `.==
330
349
331
-
`>W`
350
+
### >W
351
+
332
352
The lines in this section are displayed in the web UI main page. ==Requires compiling with `#define USE_SCRIPT_WEB_DISPLAY`.==
333
353
334
354
You may put any html code here.
@@ -339,11 +359,14 @@ You may put any html code here.
339
359
- HTML statements preceded with a `$` are displayed in the main section
340
360
- USER IO elements are displayed at the top of the page
341
361
342
-
optionally these sections may be used
343
-
`>WS`
362
+
## optionally these sections may be used
363
+
364
+
### >WS
365
+
344
366
- HTML statements are displayed in the sensor section of the main page
345
367
346
-
`>WM`
368
+
### >WM
369
+
347
370
- HTML statements are displayed in the main section of the main page
348
371
349
372
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
364
387
A web user interface may be generated containing any of the following elements:
365
388
366
389
remark: state variable names used for IO in the web interface may not contain an underscore.
367
-
**Button:**
390
+
391
+
#### Button
392
+
368
393
`bu(vn txt1 txt2)` (up to 4 buttons may be defined in one row)
369
394
`vn` = name of variable to hold button state
370
395
`txt1` = text of ON state of button
371
396
`txt2` = text of OFF state of button
372
397
373
-
**Pulldown:**
398
+
#### Pulldown
399
+
374
400
`pd(vn label (xs) txt1 txt2 ... txtn)`
375
401
`vn` = name of variable to hold selected state
376
402
`label` = label text
377
403
`xs` = optional xs (default 200)
378
404
`txt1` = text of 1. entry
379
405
`txt2` = text of 2. entry and so on
380
406
381
-
**Radio button:**
407
+
#### Radio button
408
+
382
409
`rb(vn label (xs) txt1 txt2 ... txtn)`
383
410
`vn` = name of variable to hold selected state
384
411
`label` = label text
385
412
`xs` = optional xs (default 200)
386
413
`txt1` = text of 1. entry
387
414
`txt2` = text of 2. entry and so on
388
415
389
-
**Checkbox:**
416
+
#### Checkbox
417
+
390
418
`ck(vn txt (xs))`
391
419
`vn` = name of variable to hold checkbox state
392
420
`txt` = label text
393
421
`xs` = optional xs (default 200)
394
422
395
-
**Slider:**
423
+
#### Slider
424
+
396
425
`sl(min max vn ltxt mtxt rtxt)`
397
426
`min` = slider minimum value
398
427
`max` = slider maximum value
@@ -401,20 +430,20 @@ remark: state variable names used for IO in the web interface may not contain an
401
430
`mtxt` = label middle of slider
402
431
`rtxt` = label right of slider
403
432
404
-
**Text Input:**
433
+
#### Text Input
405
434
`tx(vn lbl (xs) (type min max))`
406
435
`vn` = name of string variable to hold text state
407
436
`lbl` = label text
408
437
`xs` = optional xs (default 200)
409
438
`type min max` = optional strings type = e.g "datetime-local" for date+time selector, min, max = date-time min max range
410
439
411
-
**Time Input:**
440
+
#### Time Input
412
441
`tm(vn lbl (xs))`
413
442
`vn` = name of number variable to hold time HHMM as number e.g. 1900 means 19:00
414
443
`lbl` = label text
415
444
`xs` = optional xs (default 70)
416
445
417
-
**Number Input:**
446
+
#### Number Input
418
447
`nm(min max step vn txt (xs) (prec))`
419
448
`min` = number minimum value
420
449
`max` = number maximum value
@@ -424,14 +453,14 @@ remark: state variable names used for IO in the web interface may not contain an
424
453
`xs` = optional xs (default 200)
425
454
`prec` = optional number precision (default 1)
426
455
427
-
**special html options:**
456
+
#### special html options
428
457
`so(flags)`
429
458
`WSO_NOCENTER` = 1 force elements not centered
430
459
`WSO_NODIV` = 2 force elements not in extra \<div\>
431
460
`WSO_FORCEPLAIN` = 4 send line in plain (no table elements)
432
461
`WSO_FORCEMAIN` = 8 send lines in main mode ($ mode)
433
462
434
-
**Google Charts:**
463
+
#### Google Charts
435
464
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`
436
465
437
466
draws a google chart with up to 4 data sets per chart
0 commit comments