[exec] improve logging and documentation (#9282)
* explain usage of input channel * fix wording Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
This commit is contained in:
parent
e3a659e8d3
commit
a44f7f17cc
|
@ -67,6 +67,9 @@ All Things support the following channels:
|
|||
| run | Switch | Send ON to execute the command, the current state tells whether it is running or not |
|
||||
| lastexecution | DateTime | Time/Date the command was last executed, in yyyy-MM-dd'T'HH:mm:ss.SSSZ format |
|
||||
|
||||
**Attention:** Linking `input` to any other item type than `String` will result in erroneous behavior.
|
||||
If needed, please use a rule to convert your item's state to a string.
|
||||
Also note that only commands (e.g. `sendCommand`) to the `input` channel are recognized, updating the item's state will not work (e.g. `postUpdate`).
|
||||
|
||||
## Minimal Example
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.math.BigDecimal;
|
|||
import java.time.ZonedDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.IllegalFormatException;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -168,16 +169,17 @@ public class ExecHandler extends BaseThingHandler {
|
|||
// problem for external commands that generate a lot of output, but this will be dependent on the limits
|
||||
// of the underlying operating system.
|
||||
|
||||
Date date = Calendar.getInstance().getTime();
|
||||
try {
|
||||
if (lastInput != null) {
|
||||
commandLine = String.format(commandLine, Calendar.getInstance().getTime(), lastInput);
|
||||
commandLine = String.format(commandLine, date, lastInput);
|
||||
} else {
|
||||
commandLine = String.format(commandLine, Calendar.getInstance().getTime());
|
||||
commandLine = String.format(commandLine, date);
|
||||
}
|
||||
} catch (IllegalFormatException e) {
|
||||
logger.warn(
|
||||
"An exception occurred while formatting the command line with the current time and input values : '{}'",
|
||||
e.getMessage());
|
||||
"An exception occurred while formatting the command line '{}' with the current time '{}' and input value '{}': {}",
|
||||
commandLine, date, lastInput, e.getMessage());
|
||||
updateState(RUN, OnOffType.OFF);
|
||||
updateState(OUTPUT, new StringType(e.getMessage()));
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue