mirror of https://github.com/arendst/Tasmota.git
Debugging scripts
parent
e46ad96b4d
commit
37e4528869
|
@ -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).
|
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)
|
||||||
- Freely definable variable names (all names are intentionally case sensitive)
|
- Freely definable variable names (all names are intentionally case sensitive)
|
||||||
|
@ -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
|
||||||
|
@ -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)
|
`->` 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.
|
||||||
|
|
||||||
`=\> 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 upd[slider]>0
|
||||||
If a variable does not exist, `???` is displayed for commands
|
then
|
||||||
If a `SENSOR` or `STATUS` or `RESULT` message or a var does not exist the destination variable is NOT updated.
|
=>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
|
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
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue