From 49c89a643acfafed43d76d1f35b92e97b58001a6 Mon Sep 17 00:00:00 2001 From: joergkling Date: Tue, 2 Aug 2016 10:35:18 +0100 Subject: [PATCH] Rewrite of examples in chapter "Administration" so that they based on the demo setup (#52) Signed-off-by: Joerg Kling --- administration/console.md | 26 ++++++++++++++++++-- administration/logging.md | 52 ++++++++++++++++++++------------------- administration/runtime.md | 6 ++--- 3 files changed, 54 insertions(+), 30 deletions(-) diff --git a/administration/console.md b/administration/console.md index 2dadd84ea..f2ff66975 100644 --- a/administration/console.md +++ b/administration/console.md @@ -37,11 +37,12 @@ Hit '' or type 'system:shutdown' or 'logout' to shutdown openHAB. openhab> ``` -_Help_ is listing all available commands: +# Using the console + +**Help** is listing all available commands: ``` openhab> help -... ``` or describes a specific subsystem/command: @@ -54,6 +55,27 @@ openhab> help bundle:stop ... ``` +The console also supports auto-completion during input. Auto-Completion proposes possible commands based on the current input and is triggered by the **tab** key. So for example entering _bun_ and pressing the tab key will result in: + +``` +openhab> bundle +bundle bundle:capabilities bundle:classes bundle:diag bundle:dynamic-import +bundle:find-class bundle:headers bundle:id bundle:info bundle:install +bundle:list bundle:load-test bundle:refresh bundle:requirements bundle:resolve +bundle:restart bundle:services bundle:start bundle:start-level bundle:stop +bundle:tree-show bundle:uninstall bundle:update bundle:watch +``` + +Another useful feature the **\| (pipe)** and **grep** functionality which filters long output lists: + +``` +openhab> bundle:list | grep openHAB +164 | Active | 90 | 2.0.0.201607210102 | openHAB Core +165 | Active | 80 | 2.0.0.201607210102 | openHAB Karaf Integration +195 | Active | 80 | 2.0.0.201607210102 | openHAB 1.x Compatibility Layer +196 | Active | 80 | 2.0.0.201607210102 | openHAB REST Documentation +``` + The Karaf session is ended by using the logout command: ``` diff --git a/administration/logging.md b/administration/logging.md index d4756faea..d18f5ed3d 100644 --- a/administration/logging.md +++ b/administration/logging.md @@ -45,15 +45,17 @@ For example, following command enables the realtime monitoring of the default lo ``` openhab> log:tail -12:45:23.170 [INFO ] [marthome.event.ItemStateChangedEvent] - Sonos_Kueche_Controller changed from PLAY to PAUSE -14:29:52.648 [INFO ] [me.event.ThingStatusInfoChangedEvent] - 'hue:PAR16_50_TW:1:24' changed from ONLINE to OFFLINE: Bridge reports light as not reachable -14:29:76.348 [DEBUG] [ipse.smarthome.model.script.JK.Sonos] - This is a debug message! +20:38:00.031 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'Temperature_FF_Child' with state '19.1' in rrd4j database +20:38:00.032 [DEBUG] [sistence.rrd4j.internal.RRD4jService] - Stored 'Temperature_FF_Bed' with state '19.5' in rrd4j database +20:38:20.463 [DEBUG] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at 'items/Light_FF_Bath_Ceiling' with value 'ON'. +20:38:21.444 [DEBUG] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at 'items/Light_FF_Bath_Mirror' with value 'ON'. ``` An useful functionality is that also filters can be applied: ``` -openhab> log:tail org.eclipse.smarthome.model.script.JK -14:29:76.348 [DEBUG] [ipse.smarthome.model.script.JK.Sonos] - This is a debug message! +openhab> log:tail org.eclipse.smarthome.io.rest.core.item.ItemResource +20:36:52.879 [DEBUG] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at 'items/Light_FF_Bath_Ceiling' with value 'ON'. +20:36:53.545 [DEBUG] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at 'items/Light_FF_Bath_Ceiling' with value 'OFF'. ``` Please see the [Karaf documentation](http://karaf.apache.org/manual/latest/#_commands_2) for more examples and details. @@ -78,7 +80,7 @@ The **detail** of logging is defined by one of the following levels: The levels built a hierarchy with **Error** on the top and **Debug** on the bottom. So when setting the log level to **Debug**, all logs from levels 1-4 are shown. -Following example sets the logging for the SONOS binding to **Debug** +Following example sets the logging for the ZWAVE binding to **Debug** ``` log:set DEBUG org.openhab.binding.zwave @@ -90,25 +92,25 @@ Note that the log levels set using the log:set commands are not persistent and w It is also possible to create own log entries in rules. This is especially useful for debugging purposes. -For each log level there is an corresponding command for creating log entries. These commands require two parameters: the subpackage (here: **JK**) and the text which should appear in the log: +For each log level there is an corresponding command for creating log entries. These commands require two parameters: the subpackage (here: **Demo**) and the text which should appear in the log: ``` -logError("JK","This is a log entry of type Error!") -logWarn("JK","This is a log entry of type Warn!") -logInfo("JK","This is a log entry of type Info!") -logDebug("JK","This is a log entry of type Debug!") +logError("Demo","This is a log entry of type Error!") +logWarn("Demo","This is a log entry of type Warn!") +logInfo("Demo","This is a log entry of type Info!") +logDebug("Demo","This is a log entry of type Debug!") ``` In order to see the messages, logging for the message class has to be activated. The main package is predefined (org.eclipse.smarthome.model.script) and the subpackage needs to be concatenated: ``` -log:set DEBUG org.eclipse.smarthome.model.script.JK +log:set DEBUG org.eclipse.smarthome.model.script.Demo ``` The output for the above log statement of type **Debug** is: ``` -2016-06-04 16:28:39.482 [DEBUG] [.eclipse.smarthome.model.script.JK] - This is a log entry of type DEBUG! +2016-06-04 16:28:39.482 [DEBUG] [.eclipse.smarthome.model.script.Demo] - This is a log entry of type DEBUG! ``` ## Logging into a separate file @@ -117,24 +119,24 @@ Per default all log entries are saved in the file _openhab.log_ and event specif In order to create a new log file following two areas needs to be added to the [config file](#config-file): -1. A new file appender: +1. A new logger: ``` -# File appender - jk.log -log4j.appender.jk=org.apache.log4j.RollingFileAppender -log4j.appender.jk.layout=org.apache.log4j.PatternLayout -log4j.appender.jk.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n -log4j.appender.jk.file=${openhab.logdir}/jk.log -log4j.appender.jk.append=true -log4j.appender.jk.maxFileSize=10MB -log4j.appender.jk.maxBackupIndex=10 +# Logger - Demo.log +log4j.logger.org.eclipse.smarthome.model.script.Demo = DEBUG, Demo ``` -2. A new logger: +2. A new file appender: ``` -# Logger - jk.log -log4j.logger.org.eclipse.smarthome.model.script.JK = WARN, jk +# File appender - Demo.log +log4j.appender.Demo=org.apache.log4j.RollingFileAppender +log4j.appender.Demo.layout=org.apache.log4j.PatternLayout +log4j.appender.Demo.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n +log4j.appender.Demo.file=${openhab.logdir}/Demo.log +log4j.appender.Demo.append=true +log4j.appender.Demo.maxFileSize=10MB +log4j.appender.Demo.maxBackupIndex=10 ``` ## Config file diff --git a/administration/runtime.md b/administration/runtime.md index ac00ecc06..096af9116 100644 --- a/administration/runtime.md +++ b/administration/runtime.md @@ -23,14 +23,14 @@ __Please note: Some of the commands described here are executed on the internal Query an item's state: ``` -openhab> smarthome:status Sonos_Kitchen_Controller -PLAY +openhab> smarthome:status Heating_GF_Corridor +OFF ``` Changing an item's state: ``` -openhab> smarthome:send Light_Kueche_Innen1_Toggle ON +openhab> smarthome:send Heating_GF_Corridor ON Command has been sent successfully. ```