| 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
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;
// 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;