Debugging scripts

Michael Ingraham 2019-08-04 09:21:16 -04:00
parent e46ad96b4d
commit 37e4528869
1 changed files with 31 additions and 11 deletions

@ -27,7 +27,10 @@ USE_TOUCH_BUTTONS | enable virtual touch button support with touch displays
<BR><BR>To enter a script, go to `Configuration` =\> `Edit script` in the Tasmota web UI menu <BR><BR>To enter a script, go to `Configuration` =\> `Edit script` in the Tasmota web UI menu
The maximum script size is 1535 bytes (uses rule set buffers). The maximum script size is 1535 bytes (uses rule set buffers).
To save code space almost no error messages are provided. However it is taken care of that at least it should not crash on syntax errors.
<BR><BR>**Scripter Features** <BR><BR>**Scripter Features**
- Up to 50 variables (45 numeric and 5 strings, maybe changed by #define) - Up to 50 variables (45 numeric and 5 strings, maybe changed by #define)
@ -81,11 +84,15 @@ executed every 100 ms
executed every second executed every second
>`>E` >`>E`
executed e.g. on power change and mqtt **RESULT** Executed when a Tasmota MQTT `RESULT` message is received, e.g., on `POWER` change
>`>R` >`>R`
executed on restart, p vars are saved automatically after this call executed on restart, p vars are saved automatically after this call
If a variable does not exist, `???` is displayed for commands
If a Tasmota `SENSOR` or `STATUS` or `RESULT` message is not generated or a var does not exist the destination variable is NOT updated.
**Special variables** (read only) **Special variables** (read only)
`upsecs` = seconds since start `upsecs` = seconds since start
`uptime` = minutes since start `uptime` = minutes since start
@ -152,15 +159,28 @@ Within commands you can replace text with variables with `%varname%`
A single percent sign must be given as `%%` A single percent sign must be given as `%%`
`->` is equivalent but doesn't send mqtt or any weblog (silent execute, usefull to reduce traffic) `->` is equivalent but doesn't send mqtt or any weblog (silent execute, usefull to reduce traffic)
**Special** commands: **Special** commands:
`=\> print` prints to the log for debugging
A Tasmota MQTT RESULT message invokes the script's `>E` section. Add `=\> print` statements to debug a script.
- Example:
```
slider=Dimmer
power=POWER
if upd[slider]>0
then
=>print slider updated %slider%
endif
if upd[power]>0
then
=>print power updated %power%
endif
```
`=\> print` prints to info log for debugging **Conditional Statements**
There are two syntax alternatives. You may **_NOT_** mix both formats.
To save code space almost no error messages are provided. However it is taken care of that at least it should not crash on syntax errors.
If a variable does not exist, `???` is displayed for commands
If a `SENSOR` or `STATUS` or `RESULT` message or a var does not exist the destination variable is NOT updated.
There are two syntax alternatives for conditional statements. You may **_NOT_** mix both methods.
``` ```
if a==b if a==b
and x==y and x==y
@ -177,7 +197,7 @@ if a==b
and x==y and x==y
or k==i { or k==i {
=> do this => do this
} else {** } else {
=> do that => do that
} }
``` ```