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

@ -29,6 +29,9 @@ USE_TOUCH_BUTTONS | enable virtual touch button support with touch displays
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**
- Up to 50 variables (45 numeric and 5 strings, maybe changed by #define)
- Freely definable variable names (all names are intentionally case sensitive)
@ -81,11 +84,15 @@ executed every 100 ms
executed every second
>`>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`
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)
`upsecs` = seconds since start
`uptime` = minutes since start
@ -153,14 +160,27 @@ A single percent sign must be given as `%%`
`->` is equivalent but doesn't send mqtt or any weblog (silent execute, usefull to reduce traffic)
**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.
`=\> print` prints to info log for debugging
- Example:
```
slider=Dimmer
power=POWER
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.
if upd[slider]>0
then
=>print slider updated %slider%
endif
There are two syntax alternatives for conditional statements. You may **_NOT_** mix both methods.
if upd[power]>0
then
=>print power updated %power%
endif
```
**Conditional Statements**
There are two syntax alternatives. You may **_NOT_** mix both formats.
```
if a==b
and x==y
@ -177,7 +197,7 @@ if a==b
and x==y
or k==i {
=> do this
} else {**
} else {
=> do that
}
```