commandref_frame.html 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <title>FHEM reference</title>
  5. <script type="text/javascript" src="fhemdoc.js"></script>
  6. <noscript>
  7. <link rel="stylesheet" type="text/css" href="../www/pgm2/style.css" />
  8. </noscript>
  9. <meta http-equiv="Content-type" content="text/html; charset=UTF-8">
  10. <link rel="shortcut icon" href="/fhem/icons/favicon.ico"/>
  11. </head>
  12. <body style="word-wrap: break-word;">
  13. <div id="menuScrollArea">
  14. <div id="logo"></div>
  15. <div id="menu">
  16. <h3>fhem.pl reference</h3>
  17. Version: <b>EN</b>&nbsp;<a href="commandref_DE.html">DE</a>
  18. <br><br>
  19. <a href="#doctop">Scroll to top</a>
  20. <br><br>
  21. <a style="display:none" href="#" name="loadAll">Load complete doc</a>
  22. <br><br>
  23. <a id="otherLang" style="display:none" href="#" name="otherLang">
  24. Load <span style="display:none" lang="DE">german</span>
  25. <span style="display:none" lang="EN">english</span>
  26. doc for <span class="mod"></span>
  27. </a>
  28. </div>
  29. </div>
  30. <div id="right">
  31. <a name="doctop"></a>
  32. <h3>Contents</h3>
  33. <ul>
  34. <a href="#intro">Introduction</a><br>
  35. <a href="#command">FHEM command types</a><br>
  36. <a href="#devspec">Device specification</a><br>
  37. <a href="#attributes">Attributes</a><br>
  38. <br>
  39. <b>FHEM commands</b>
  40. <ul>
  41. <!-- header:command -->
  42. <a href="#apptime">apptime</a> &nbsp; <!-- provides information about execution times -->
  43. <a href="#attr">attr</a> &nbsp; <!-- set an attribute for a FHEM device -->
  44. <a href="#cancel">cancel</a> &nbsp; <!-- cancel sleep -->
  45. <a href="#createlog">createlog</a> &nbsp; <!-- add a FileLog and an SVG to an existing device -->
  46. <a href="#define">define</a> &nbsp; <!-- define/create a FHEM device -->
  47. <a href="#defmod">defmod</a> &nbsp; <!-- define or modify a FHEM device -->
  48. <a href="#delete">delete</a> &nbsp; <!-- delete a FHEM device -->
  49. <a href="#deleteattr">deleteattr</a> &nbsp; <!-- delete an attribute -->
  50. <a href="#deletereading">deletereading</a> &nbsp; <!-- delete a reading -->
  51. <a href="#displayattr">displayattr</a> &nbsp; <!-- show attributes -->
  52. <a href="#get">get</a> &nbsp; <!-- retrieve a value from a FHEM device -->
  53. <a href="#IF">IF</a> &nbsp; <!-- conditionally execute FHEM commands -->
  54. <a href="#include">include</a> &nbsp; <!-- read in a file with FHEM commands -->
  55. <a href="#inform">inform</a> &nbsp; <!-- show events in a telnet connection -->
  56. <a href="#list">list</a> &nbsp; <!-- display definition,readings and attributes of a FHEM device -->
  57. <a href="#modify">modify</a> &nbsp; <!-- change the definition of a FHEM device -->
  58. <a href="#notice">notice</a> &nbsp; <!-- view and confirm of system messages -->
  59. <a href="#quit">quit</a> &nbsp; <!-- end a telnet connection to FHEM -->
  60. <a href="#reload">reload</a> &nbsp; <!-- reload a FHEM module (program definition) -->
  61. <a href="#rename">rename</a> &nbsp; <!-- rename a FHEM device -->
  62. <a href="#rereadcfg">rereadcfg</a> &nbsp; <!-- reread the FHEM configuration -->
  63. <a href="#save">save</a> &nbsp; <!-- save the FHEM configuration -->
  64. <a href="#set">set</a> &nbsp; <!-- set a value in a FHEM device -->
  65. <a href="#setdefaultattr">setdefaultattr</a> &nbsp; <!-- define a default attribute -->
  66. <a href="#setreading">setreading</a> &nbsp; <!-- set a reading for a FHEM device -->
  67. <a href="#setstate">setstate</a> &nbsp; <!-- set the main state of a FHEM device -->
  68. <a href="#shutdown">shutdown</a> &nbsp; <!-- shut down (terminate) FHEM -->
  69. <a href="#sleep">sleep</a> &nbsp; <!-- sleep (delay execution) for a while -->
  70. <a href="#trigger">trigger</a> &nbsp; <!-- generate a FHEM event -->
  71. <a href="#usb">usb</a> &nbsp; <!-- discover USB devices -->
  72. </ul>
  73. <br>
  74. <b>Device modules</b>
  75. <ul>
  76. <a href="#global">global</a><br>
  77. <!-- header:device -->
  78. </ul>
  79. <br>
  80. <b>Helper modules</b>
  81. <ul>
  82. <!-- header:helper -->
  83. <a href="#CustomReadings">CustomReadings</a> &nbsp;
  84. <a href="#DOIF">DOIF</a> &nbsp;
  85. <a href="#Dashboard">Dashboard</a> &nbsp;
  86. <a href="#dewpoint">dewpoint</a> &nbsp;
  87. <a href="#FLOORPLAN">FLOORPLAN</a> &nbsp;
  88. <a href="#HCS">HCS</a> &nbsp;
  89. <a href="#Heating_Control">Heating_Control</a> &nbsp;
  90. <a href="#HMinfo">HMinfo</a> &nbsp;
  91. <a href="#HourCounter">HourCounter</a> &nbsp;
  92. <a href="#MaxScanner">MaxScanner</a> &nbsp;
  93. <a href="#PachLog">PachLog</a> &nbsp;
  94. <a href="#RandomTimer">RandomTimer</a> &nbsp;
  95. <a href="#rain">rain</a> &nbsp;
  96. <a href="#remotecontrol">remotecontrol</a> &nbsp;
  97. <a href="#statistics">statistics</a> &nbsp;
  98. <a href="#Twilight">Twilight</a> &nbsp;
  99. <a href="#THRESHOLD">THRESHOLD</a> &nbsp;
  100. <a href="#WeekdayTimer">WeekdayTimer</a> &nbsp;
  101. <a href="#WOL">WOL</a> &nbsp;
  102. <!-- header end -->
  103. </ul>
  104. <br>
  105. <a href="#perl">Perl specials</a><br>
  106. <a href="#gnuplot-syntax">gnuplot file syntax</a><br>
  107. </ul>
  108. <a name="intro"></a>
  109. <h3>Introduction</h3>
  110. <ul>
  111. FHEM is mainly used for home automation, but it is suitable for other tasks
  112. too, where notification, timers and logging plays an important role.<br>
  113. <br>
  114. It supports different hardware devices to interface with certain protocols
  115. (e.g. FHZ1000PC to interface FS20 and HMS, CM11 to access X10), and logical
  116. devices like FS20 or FHT to digest the messages for a certain device type using
  117. this protocol.<br>
  118. <br>
  119. FHEM is modular. The different devices are represented through modules which
  120. implement certain functions (e.g. define, get, set). Even seemingly integral
  121. parts of FHEM like triggers (<a href="#notify">notify</a>) and timers (<a
  122. href="#at">at</a>) are implemented this way, giving the possibility to
  123. replace/extend this functionality.<br> <br>
  124. FHEM is controlled through readable / ascii commands, which are specified in
  125. files (e.g. the configuration file), or issued over a TCP/IP connection, either
  126. directly in a telnet session, with a fhem.pl in client mode or from one of the
  127. web frontends.<br> <br>
  128. When starting the server you have to specify a configuration file:<br>
  129. <ul>
  130. <code>perl fhem.pl fhem.cfg</code>
  131. </ul>
  132. <br>
  133. A reasonable minimal configuration file looks like: <pre>
  134. attr global <a href="#logfile">logfile</a> log/fhem.log
  135. attr global <a href="#modpath">modpath</a> .
  136. attr global <a href="#statefile">statefile</a> log/fhem.save
  137. define telnetPort <a href="#telnet">telnet</a> 7072 global
  138. define WEB <a href="#FHEMWEB">FHEMWEB</a> 8083 global</pre>
  139. Note: the last two lines are optional and assume you wish to use the
  140. builtin telnet and WEB interface.<br>
  141. <br>
  142. The web interface can be reached at
  143. <ul>
  144. http://&lt;fhemhost&gt;:8083
  145. </ul>
  146. <br>
  147. TCP/IP communication with FHEM can either happen in a "session" (via
  148. telnet) or single client command (via fhem.pl). Example:
  149. <ul>
  150. <code>telnet &lt;fhemhost&gt; 7072<br>
  151. &lt;NL&gt; </code>(This newline switches into "prompt" mode)<code><br>
  152. &lt;command&gt;...<br>
  153. quit</code><br>
  154. </ul>
  155. or
  156. <ul>
  157. <code>fhem.pl &lt;fhemhost&gt;:7072 "&lt;fhem-command&gt" "..."</code>
  158. </ul>
  159. <br>
  160. If a OS-user called fhem exists, and FHEM is started as root, FHEM will
  161. automatically change to to this user via setuid. <br>
  162. </ul>
  163. <!-- intro end - diese Zeile nicht entfernen! -->
  164. <a name="command"></a>
  165. <h3>FHEM command types</h3>
  166. <ul>
  167. There are three types of commands: "fhem" commands (described in this
  168. document), shell commands (they must be enclosed in double quotes ") and perl
  169. expressions (enclosed in curly brackets {}). shell commands or perl expressions
  170. are needed for complex <a href="#at">at</a> or <a href="#notify">notify</a>
  171. arguments, but can also issued as a "normal" command.<br>
  172. <br>
  173. E.g. the following three commands all do the same when issued from a telnet
  174. prompt:<br>
  175. <ul>
  176. set lamp off<br>
  177. "fhem.pl 7072 "set lamp off""<br>
  178. {fhem("set lamp off")}<br>
  179. </ul>
  180. <br>
  181. Shell commands will be executed in the background, perl expressions and
  182. FHEM commands will be executed in the main "thread". In order to make perl
  183. expressions easier to write, some special functions and variables are
  184. available. See the section <a href="#perl">Perl special</a> for a description.
  185. To trigger FHEM commands from a shell script (this is the "other way round"),
  186. use the client form of fhem.pl (described above).<br>
  187. <br>
  188. Multiple FHEM commands are separated by semicolon (;). In order to use semicolon
  189. in perl code or shell programs, they have to be escaped by the double semicolon
  190. (;;). See the <b>Notes</b> section of the <a href="#notify">notify</a>
  191. chapter on command parameters and escape rules.<br>
  192. E.g. the following first command switches Lamp1 off at 07:00 and Lamp2
  193. immediately (at the point of definition), the second one switches both lamps
  194. off at 07:00.<br>
  195. <ul>
  196. define lampoff at 07:00 set Lamp1 off; set Lamp2 off<br>
  197. define lampoff at 07:00 set Lamp1 off;; set Lamp2 off<br>
  198. </ul>
  199. For every further indirection you need to double the semicolons:, e.g. to
  200. switch on every day 2 devices at 7:00 for 10 minutes you have to write:<br>
  201. <ul>
  202. define onAt at 07:00 set Lamp1 on;;set Lamp2 on;; define offAt at +00:10 set Lamp1 off;;;;set Lamp2 off
  203. </ul>
  204. Don't dispair, the previous example can also be written as
  205. <ul>
  206. define onAt at 07:00 set Lamp1,Lamp2 on-for-timer 600
  207. </ul>
  208. <br>
  209. Commands can be either typed in plain, or read from a file (e.g. the
  210. configuration file at startup). The commands are either executed directly, or
  211. later if they are arguments to the <a href="#at">at</a> and <a
  212. href="#notify">notify</a> FHEM commands.<br>
  213. <br>
  214. A line ending with \ will be concatenated with the next one, so long lines
  215. (e.g. multiple perl commands) can be split in multiple lines. Some web fronteds
  216. (e.g. webpgm2) make editing of multiline commands transparent for you (i.e. there is no need for \) .<br>
  217. <br>
  218. </ul>
  219. <!-- command end - diese Zeile nicht entfernen! -->
  220. <a name="devspec"></a>
  221. <h3>Device specification (devspec)</h3>
  222. <ul>
  223. The commands
  224. <a href="#attr">attr</a>,
  225. <a href="#deleteattr">deleteattr</a>,
  226. <a href="#displayattr">displayattr</a>,
  227. <a href="#delete">delete</a>,
  228. <a href="#get">get</a>,
  229. <a href="#list">list</a>,
  230. <a href="#set">set</a>,
  231. <a href="#setreading">setreading</a>,
  232. <a href="#setstate">setstate</a>,
  233. <a href="#trigger">trigger</a>
  234. can take a more complex device specification as argument, which will be
  235. expanded to a list of devices. A device specification (short devspec) can be:
  236. <ul>
  237. <li>a single device name. This is the most common case.</li>
  238. <li>a list of devices, separated by comma (,)</li>
  239. <li>a regular expression</li>
  240. <li>a NAME=VALUE pair, where NAME can be an internal value like TYPE, a
  241. Reading-Name or an attribute. VALUE is a regexp. To negate the
  242. comparison, use NAME!=VALUE. To restrict the search, use i: as prefix
  243. for internal values, r: for readings and a: for attributes. See the
  244. example below.</li>
  245. <li>if the spec is followed by the expression :FILTER=NAME=VALUE, then the
  246. values found in the first round are filtered by the second expression.
  247. </ul>
  248. Examples:
  249. <ul>
  250. <code>set lamp1 on</code><br>
  251. <code>set lamp1,lamp2,lamp3 on</code><br>
  252. <code>set lamp.* on</code><br>
  253. <code>set room=kitchen off</code><br>
  254. <code>set room=kitchen:FILTER=STATE=on off</code><br>
  255. <code>set room=kitchen:FILTER=STATE!=off off</code><br>
  256. <code>list disabled=</code><br>
  257. <code>list TYPE=FS20 STATE</code><br>
  258. <code>list i:TYPE=FS20 STATE</code><br>
  259. </ul>
  260. Notes:
  261. <ul>
  262. <li>the spec may not contain space characters.</n>
  263. <li>if there is a device which exactly corresponds to the spec, then
  264. no special processing is done.</li>
  265. <li>first the spec is separated by comma, then the regular expression and
  266. filter operations are executed.</li>
  267. <li>the returned list can contain the same device more than once, so
  268. "set lamp3,lamp3 on" switches lamp3 twice.</li>
  269. <li>for more complex structuring demands see the <a href="#structure">
  270. structure</a> device.
  271. </ul>
  272. </ul>
  273. <!-- devspec end - diese Zeile nicht entfernen! -->
  274. <a name="attributes"></a>
  275. <h3>Attributes</h3>
  276. All devices have attributes. These can be set by means of the <a
  277. href="#attr">attr</a> command, displayed with the <a
  278. href="#displayattr">displayattr</a> command, and deleted by the <a
  279. href="#deleteattr">deleteattr</a> command.<p>
  280. There are global attributes that are used by all devices and local attributes
  281. that apply to individual device classes only.<p>
  282. Some devices (like <a href="#FHEMWEB">FHEMWEB</a>) automatically define new
  283. global attributes on the first definition of a device of such type.<p>
  284. You can use the command <p><code>attr global userattr
  285. &lt;attributelist&gt;</code><p> for the <a href="#global">global</a> device to
  286. declare new global attributes and <p><code>attr &lt;devicespec&gt; userattr
  287. &lt;attributelist&gt;</code><p> for individual devices according to <a
  288. href="#devspec">devspec</a> to declare new local attributes.
  289. <code>&lt;attributelist&gt;</code> is a space-separated list which contains the
  290. names of the additional attributes. See the documentation of the <a
  291. href="#attr">attr</a> command for examples.<p>
  292. Be careful not to overwrite additional global attributes previously defined by
  293. yourself or a device. Use the <code>attr global userattr
  294. &lt;attributelist&gt;</code> as early in your configuration as possible.
  295. <h4>Device specific attributes</h4>
  296. Device specific attributes are documented in the corresponding device section.
  297. <h4>Global attributes used by all devices</h4>
  298. <ul>
  299. <a name="alias"></a>
  300. <li>alias<br>
  301. Used by FHEMWEB to display a device with another name e.g. when using
  302. special characters/spaces not accepted by device definition.
  303. </li><br>
  304. <a name="comment"></a>
  305. <li>comment<br>
  306. Add an arbitrary comment.
  307. </li><br>
  308. <a name="eventMap"></a>
  309. <li>eventMap<br>
  310. Replace event names and set arguments. The value of this attribute
  311. consists of a list of space separated values, each value is a colon
  312. separated pair. The first part specifies the "old" value, the second
  313. the new/desired value. If the first character is slash(/) or comma(,)
  314. then split not by space but by this character, enabling to embed spaces.
  315. You can specify a widgetOverride after an additional colon (e.g.
  316. on-for-timer:OnFor:texField), the default widget is :noArg to avoid
  317. extra input fields in cmdList.
  318. Examples:<ul><code>
  319. attr store eventMap on:open off:closed<br>
  320. attr store eventMap /on-for-timer 10:open/off:closed/<br>
  321. set store open
  322. </code></ul>
  323. The explicit variant of this attribute has the following syntax:
  324. <ul><code>
  325. attr store eventMap { dev=>{"on"=>"open"}, usr=>{"open"=>"on"} }<br>
  326. attr store eventMap { dev=>{"^on(-for-timer)?(.*)"=>"open$2"},
  327. usr=>{"^open(.*)"=>"on$1"},
  328. fw=>{"^open(.*)"=>"open"} }
  329. </code></ul>
  330. This variant must be used, if the mapping is not symmetrical, the first
  331. part (dev) representing the device to user mapping, i.e. if the device
  332. reports on 100 or on-for-timer 100, the user will see open 100. The
  333. second part (usr) is the other direction, if the user specified open
  334. 10, the device will receive on 10. On both occasions the key will be
  335. first compared directly with the text, and if it is not equal, then it
  336. will be tried to match it as a regexp. When using regexps in the usr
  337. part with wildcards, the fw part must be filled with the exact same
  338. keys to enable a correct display in the FHEMWEB set dropdown list in
  339. the detail view.
  340. </li><br>
  341. <a name="genericDisplayType"></a>
  342. <li>genericDisplayType<br>
  343. used by some frontends (but not FHEMWEB) to offer a default image or
  344. appropriate commands for this device. Currently the following values
  345. are supported: switch,outlet,light,blind,speaker,thermostat
  346. </li><br>
  347. <a name="group"></a>
  348. <li>group<br>
  349. Group devices. Recognized by web-pgm2 (module <a
  350. href="#FHEMWEB">FHEMWEB</a>), it makes
  351. devices in the same group appear in the same box).
  352. This is used to further group
  353. devices together. A device can appear in more than one group, in this
  354. case the groups have to be specified comma-separated.<br>
  355. If this attribute is not set then the device type is used as the
  356. grouping attribute.
  357. </li><br>
  358. <a name="room"></a>
  359. <li>room<br>
  360. Filter/group devices. Recognized by web-pgm2 and web-pgm3. A device
  361. can appear in more than one room, in this case the rooms have to be
  362. specified comma-separated.<br>
  363. Devices in the room hidden will not appear in the web output, or set
  364. the <a href="#hiddenroom"> FHEMWEB attribute to selectively disable
  365. rooms for certain FHEMWEB instances.
  366. </li><br>
  367. <a name="suppressReading"></a>
  368. <li>suppressReading<br>
  369. Used to eliminate unwanted readings. The value is a regular expression,
  370. with ^ and $ added. Only necessary in exceptional cases.
  371. </li><br>
  372. <a name="showtime"></a>
  373. <li>showtime<br>
  374. Used in the webfrontend pgm2 to show the time of last activity
  375. instead of the state in the summary view. Useful e.g. for FS20 PIRI
  376. devices.
  377. </li><br>
  378. <a name="verbose"></a>
  379. <li>verbose<br>
  380. Set the verbosity level. Possible values:
  381. <ul>
  382. <li>0 - server start/stop</li>
  383. <li>1 - error messages or unknown packets</li>
  384. <li>2 - major events/alarms.</li>
  385. <li>3 - commands sent out will be logged.</li>
  386. <li>4 - you'll see whats received by the different devices.</li>
  387. <li>5 - debugging.</li>
  388. </ul>
  389. The value for the <a href="#global">global</a> device is a default for
  390. other devices without own verbose attribute set.
  391. </li></br>
  392. </ul>
  393. <a name="readingFnAttributes"></a>
  394. <h4>readingFnAttributes</h4><p>
  395. The following global attributes are honored by the modules that make use of the
  396. standardized readings updating mechanism in fhem.pl. Check the module's
  397. attribute list if you want to know if a device supports these attributes. <br>
  398. <ul>
  399. <a name="stateFormat"></a>
  400. <li>stateFormat<br>
  401. Modifies the STATE of the device, shown by the list command or in the room
  402. overview in FHEMWEB. If not set, its value is taken from the state reading.
  403. If set, then every word in the argument is replaced by the value of the
  404. reading if such a reading for the current device exists. If the value of
  405. this attribute is enclused in {}, then it is evaluated. This attribute is
  406. evaluated each time a reading is updated.<br>
  407. The "set magic" described <a href="#set">here</a> is also applied.
  408. </li>
  409. <p>
  410. <a name="event-on-update-reading"></a>
  411. <li>event-on-update-reading<br>
  412. If not set, every update of any reading creates an event, which e.g. is
  413. handled by <a href="#notify">notify</a> or <a href="#FileLog">FileLog</a>.
  414. The attribute takes a comma-separated list of readings. You may use regular
  415. expressions in that list. If set, only updates of the listed readings
  416. create events.
  417. </li>
  418. <p>
  419. <a name="event-on-change-reading"></a>
  420. <li>event-on-change-reading<br>
  421. The attribute takes a comma-separated list of readings. You may use regular
  422. expressions in that list. If set, only changes of the listed readings
  423. create events. In other words, if a reading listed here is updated with the
  424. new value identical to the old value, no event is created. If an optional [:threshold]
  425. is given after a reading name events are only generated if the change is >= threshold.
  426. </li>
  427. The precedence of event-on-update-reading and event-on-change-reading is as
  428. follows:
  429. <ol>
  430. <li>If both attributes are not set, any update of any reading of the device
  431. creates an event.</li>
  432. <li>If any of the attributes is set, no events occur for updates or changes
  433. of readings not listed in any of the attributes.</li>
  434. <li>If a reading is listed in event-on-update-reading, an update of the
  435. reading creates an event no matter whether the reading is also listed
  436. in event-on-change-reading.</li>
  437. </ol>
  438. <p>
  439. <a name="timestamp-on-change-reading"></a>
  440. <li>timestamp-on-change-reading<br>
  441. The attribute takes a comma-separated list of readings. You may use regular
  442. expressions in that list. If set, the timestamps of the listed readings will
  443. not be changed if event-on-change-reading is also set and it would not create
  444. an event for this reading.
  445. </li>
  446. <p>
  447. <a name="event-aggregator"></a>
  448. <li>event-aggregator</li>
  449. The primary uses of this attribute are to calculate (time-weighted) averages of
  450. readings over time periods and to throttle the update rate of readings and thus
  451. the amount of data written to the logs.<p>
  452. This attribute takes a comma-separated list of <code>reading:interval:method:function:holdTime</code>
  453. quintuples. You may use regular expressions for <code>reading</code>. If set, updates for the
  454. listed readings are ignored and associated events are suppressed for a black-out period of at
  455. least <code>interval</code> seconds (downsampling). After the black-out period has expired, the reading is
  456. updated with a value that is calculated from the values and timestamps of the previously ignored
  457. updates within the black-out period as follows:
  458. <table>
  459. <tr><th>function</th><th>description</th></tr>
  460. <tr><td>v</td><td>the last value encountered</td></tr>
  461. <tr><td>v0</td><td>the first value encountered</td></tr>
  462. <tr><td>min</td><td>the smallest value encountered</td></tr>
  463. <tr><td>max</td><td>the largest value encountered</td></tr>
  464. <tr><td>mean</td><td>the arithmetic mean of all values</td></tr>
  465. <tr><td>sd</td><td>the standard deviation from the mean</td></tr>
  466. <tr><td>median</td><td>the median of all values (requires holdTime and function none)</td></tr>
  467. <tr><td>integral</td><td>the arithmetic sum (if not time-weighted) or integral area (if time-weighted) of all values</td></tr>
  468. <tr><td>n</td><td>number of samples</td></tr>
  469. <tr><td>t</td><td>timestamp of the last value</td></tr>
  470. <tr><td>t0</td><td>timestamp of the first value</td></tr>
  471. </table>
  472. <p>
  473. If <code>method</code> is <code>none</code>, then that's all there is. If <code>method</code>
  474. is <code>const</code> or <code>linear</code>, the time-weighted series of values is taken into
  475. account instead. The weight is the timespan between two subsequent updates.
  476. With the <code>const</code> method, the value is the value of the reading at the beginning of
  477. the timespan; with the <code>linear</code> method, the value is the arithmetic average of
  478. the values at the beginning and the end of the timespan.
  479. Rollovers of black-out periods are handled as one would expect it.<p>
  480. One would typically use the <code>linear</code> method with the <code>mean</code> function for
  481. quantities continuously varying over time like electric power consumption, temperature or speed.
  482. For cumulative quantities like energy consumed, rain fallen or distance covered,
  483. the <code>none</code> method with the <code>v</code> function is used. The <code>constant</code>
  484. method is for discrete quantities that stay constant until the corresponding reading is updated,
  485. e.g. counters, switches and the like.<p>
  486. If the <code>holdTime</code> in seconds is defined, the samples will be kept in memory allowing
  487. the calculation of floating statistics instead of blocked statistics. With <code>holdTime</code>
  488. defined the <code>interval</code> can be kept undefined so that the readings update rate is unchanged
  489. or it can be set to a value less then <code>holdTime</code> for downsampling as described above
  490. with a full history of the readings in memory. Note that the historic samples are not persistent
  491. and will be lost when restarting FHEM.<p>
  492. The event aggregator only takes into consideration those updates that remain after preprocessing
  493. according to the <code>event-on-update-reading</code> and <code>event-on-change-reading</code>
  494. directives. Besides which, any update of a reading that occurs within a timespan from the preceding
  495. update that is smaller than the resolution of FHEM's time granularity is ditched.<p>
  496. When more than one function should be calculated for the same reading, the original reading must be
  497. multiplied (e.g. by using a notify) before applying the event-aggregator to the derived readings.<p>
  498. Examples:<br>
  499. <code>attr myPowerMeter event-aggregator EP_POWER_METER:300:linear:mean,EP_ENERGY_METER:300:none:v</code><br>
  500. <code>attr myBadSensor event-aggregator TEMP::none:median:300</code><br>
  501. <code>attr mySunMeter event-aggregator SUN_INTENSITY_24H::const:integral:86400</code>
  502. </li>
  503. <p>
  504. <a name="event-min-interval"></a>
  505. <li>event-min-interval<br>
  506. This attribute takes a comma-separated list of reading:minInterval pairs.
  507. You may use regular expressions for reading. Events will only be
  508. generated, if at least minInterval seconds elapsed since the last reading
  509. of the matched type. If event-on-change-reading is also specified, they are
  510. combined with OR: if one of them is true, the event is generated.
  511. </li>
  512. <p>
  513. <a name="userReadings"></a>
  514. <li>userReadings<br>
  515. A comma-separated list of definitions of user-defined readings. Each
  516. definition has the form:
  517. <ul>
  518. <code>
  519. &lt;reading&gt;[:&lt;trigger&gt;] [&lt;modifier&gt;] { &lt;perl code&gt; }
  520. </code>
  521. </ul>
  522. After a single or bulk readings update, the user-defined readings are set
  523. by evaluating the <a href="#perl">perl code</a><code> { &lt;perl code&gt;
  524. }</code> for all definitions and setting the value of the respective
  525. user-defined reading <code>&lt;reading&gt;</code> to the result. If
  526. &lt;trigger&gt; is given, then all processing for this specific user
  527. reading is only done if one of the just updated "reading: value"
  528. combinations matches &lt;trigger&gt;, which is treated as a regexp.
  529. <br>
  530. Examples:<br>
  531. <ul><code>
  532. attr myEnergyMeter userReadings energy
  533. { ReadingsVal("myEnergyMeter","counters.A",0)/1250.0;; }<br>
  534. attr myMultiMeter userReadings
  535. energy1:counters.A.* { ReadingsVal("myMultiMeter","counters.A",0)/1250.0;; },
  536. energy2:counters.B.* { ReadingsVal("myMultiMeter","counters.B",0)/1250.0;; }
  537. </code></ul>
  538. <code>&lt;modifier&gt;</code> can take one of these values:
  539. <ul>
  540. <li>none: the same as it would not have been given at all.</li>
  541. <li>difference: the reading is set to the difference between the current
  542. and the previously evaluated value.</li>
  543. <li>differential: the reading is set to the difference between the
  544. current and the previously evaluated value divided by the time in
  545. seconds between the current and the previous evaluation. Granularity
  546. of time is one second. No value is calculated if the time past is
  547. below one second. Useful to calculate rates.</li>
  548. <li>integral: reverse function of differential. The result is incremented
  549. by the product of the time difference between the last two readings
  550. and the avarage of the last two readings. <br>
  551. result += (time - timeold) * (oldval + value) / 2
  552. </li>
  553. <li>offset: if the current evaluated value is smaler than the previously
  554. evaluated value the reading is incremented by the previous value.
  555. the reading can then be used as an offset correct for a counter that
  556. is reset for example due to a power loss.</li>
  557. <li>monotonic: if the difference between the current and the previously
  558. evaluated value is positive the reading is incremented by this difference.
  559. this allows to derive a monotonic growing counter from an original counter
  560. even if the original will be rest by a power loss</li>
  561. </ul>
  562. Example:<br>
  563. <ul><code>attr myPowerMeter userReadings power
  564. differential { ReadingsVal("myPowerMeter","counters.A",0)/1250.0;; }
  565. </code></ul>
  566. Notes:
  567. <ul>
  568. <li>user readings with modifiers difference and differential store the
  569. calculated values internally. The user reading is set earliest at the
  570. second evaluation. Beware of stale values when changing
  571. definitions!</li>
  572. <li>the name of the defined Readings consists of alphanumeric characters
  573. with underscore (_) and the minus (-) sign.</li>
  574. </ul>
  575. </li>
  576. </ul>
  577. <h4>Common attributes</h4>
  578. The following local attributes are used by a wider range of devices:
  579. <ul>
  580. <a name="IODev"></a>
  581. <li>IODev<br>
  582. Set the IO or physical device which should be used for sending signals
  583. for this "logical" device. An example for the physical device is an FHZ
  584. or a CUL. Note: Upon startup FHEM assigns each logical device
  585. (FS20/HMS/KS300/etc) the last physical device which can receive data
  586. for this type of device. The attribute IODev needs to be used only if
  587. you attached more than one physical device capable of receiving signals
  588. for this logical device.</li><br>
  589. <li>Special: attribute disable can be toggled<br/>
  590. Attribute "disable" can be toggled by issuing the following command:<br/>
  591. <br/>
  592. <code>attr &lt;device&gt; disable toggle</code><br/>
  593. <br/>
  594. Attribute "disable" must be offered by the corresponding module</li>
  595. </ul>
  596. <!-- attributes end - diese Zeile nicht entfernen! -->
  597. <br><br>
  598. <a name="commands"></a>
  599. <a name="attr"></a>
  600. <h3>attr</h3>
  601. <ul>
  602. <code>attr &lt;devspec&gt; &lt;attrname&gt; [&lt;value&gt;] </code><br>
  603. <br>Set an attribute for a device defined by <a href="#define">define</a>.
  604. You can define your own <a href="#attributes">attributes</a> too to use them
  605. in other applications.
  606. Use "attr &lt;name&gt; ?" to get a list of possible attributes.
  607. See the <a href="#devspec">Device specification</a> section for details on
  608. &lt;devspec&gt;.
  609. After setting the attribute, the global event "ATTR" will be generated.
  610. <br><br>
  611. Examples:
  612. <ul>
  613. <code>attr global verbose 3</code><br>
  614. <code>attr lamp room kitchen</code><br>
  615. <code>attr lamp group lights</code><br>
  616. <code>attr lamp loglevel 6</code><br>
  617. <code>attr weatherstation event-on-update-reading wind,temperature,humidity</code><br>
  618. <code>attr weatherstation event-on-change-reading israining</code><br>
  619. <code>attr weatherstation event-on-change-reading israining,state</code><br>
  620. <code>attr heating stateFormat Temp:measured-temp, Valve:actuator</code><br>
  621. </ul>
  622. <br>
  623. Notes:<br>
  624. <ul>
  625. <li>See <a href="#deleteattr">deleteattr</a> to delete attributes.</li>
  626. </ul>
  627. </ul>
  628. <a name="cancel"></a>
  629. <h3>cancel</h3>
  630. <ul>
  631. <code>cancel [&lt;id&gt; [quiet]]</code>
  632. <br><br>
  633. Cancels a named <a href="#sleep">sleep</a>.
  634. </ul>
  635. <!-- cancel end -->
  636. <a name="define"></a>
  637. <h3>define</h3>
  638. <ul>
  639. <code>define [option] &lt;name&gt; &lt;type&gt; &lt;type-specific&gt;</code><br>
  640. <br>
  641. Define a device. You need devices if you want to manipulate them (e.g.
  642. set on/off), and the logfile is also more readable if it contains e.g.
  643. "lamp off" instead of "Device 5673, Button 00, Code 00 (off)". <br>
  644. After definition, the global event "DEFINED" will be generated, see the
  645. notify section for details.<br>
  646. <br><br>
  647. Each device takes different additional arguments at definition, see the
  648. corresponding device section for details.<br>
  649. <br>
  650. Options:<br>
  651. <ul>
  652. <li>-temporary<br>
  653. Add the TEMPORARY flag to the definition, which will prevent saving the
  654. device to fhem.cfg.
  655. </li><br>
  656. <li>-ignoreErr<br>
  657. Reduce the number of errors displayed when a certain FHEM-module cannot
  658. be loaded. Used by fhem.cfg.demo, as using the RSS example requires the
  659. installation of several uncommon perl modules.
  660. </li><br>
  661. </ul>
  662. </ul>
  663. <!-- define end -->
  664. <a name="defmod"></a>
  665. <h3>defmod</h3>
  666. <ul>
  667. <code>defmod &lt;name&gt; &lt;type&gt; &lt;type-specific&gt;</code><br>
  668. <br>
  669. Define a device or modify it, if it already exists. E.g. to switch off a lamp
  670. 10 Minutes after the last message from the motion detector, you may use
  671. <ul><code>
  672. define mdNtfy notify motionDetector defmod mdOff at +00:10 set lamp off
  673. </code></ul>
  674. Using define here for the mdOff will generate an error if the motion detector
  675. triggers within the 10 minutes after the first event, as the mdOff at
  676. definition still exists.
  677. <br>
  678. </ul>
  679. <!-- defmod end -->
  680. <a name="delete"></a>
  681. <h3>delete</h3>
  682. <ul>
  683. <code>delete &lt;devspec&gt;</code> <br>
  684. <br>
  685. Delete something created with the <a href="#define">define</a> command.
  686. See the <a href="#devspec">Device specification</a> section for details on
  687. &lt;devspec&gt;.<br>
  688. After deletion, the global event "DELETED" will be generated, see the notify
  689. section for details.<br>
  690. Examples:
  691. <ul>
  692. <code>delete lamp</code><br>
  693. </ul>
  694. <br>
  695. </ul>
  696. <!-- delete end -->
  697. <a name="deleteattr"></a>
  698. <h3>deleteattr</h3>
  699. <ul>
  700. <code>deleteattr &lt;devspec&gt; [&lt;attrname&gt;]</code> <br>
  701. <br>
  702. Delete either a single attribute (see the <a href="#attr">attr</a> command)
  703. or all attributes for a device (if no &lt;attrname&gt; is defined).
  704. See the <a href="#devspec">Device specification</a> section for details on
  705. &lt;devspec&gt;.<br>
  706. After deleting the attribute, the global event "DELETEATTR" will be generated.
  707. <br>
  708. Examples:
  709. <ul>
  710. <code>deleteattr lamp follow-on-for-timer</code><br>
  711. <code>deleteattr lamp</code><br>
  712. </ul>
  713. <br>
  714. </ul>
  715. <!-- deleteattr end -->
  716. <a name="deletereading"></a>
  717. <h3>deletereading</h3>
  718. <ul>
  719. <code>deletereading &lt;devspec&gt; &lt;readingname&gt;</code> <br>
  720. <br>
  721. Delete the reading &lt;readingname&gt;
  722. for a device. &lt;readingname&gt; is a perl regular expression that must match the whole name of the reading.
  723. Use with greatest care! FHEM might crash if you delete vital readings of a device.
  724. See the <a href="#devspec">Device specification</a> section for details on
  725. &lt;devspec&gt;.<br>
  726. <br>
  727. Examples:
  728. <ul>
  729. <code>deletereading mySensor temp1</code><br>
  730. <code>deletereading mySensor temp\d+</code><br>
  731. </ul>
  732. <br>
  733. </ul>
  734. <!-- deletereading end -->
  735. <a name="displayattr"></a>
  736. <h3>displayattr</h3>
  737. <ul>
  738. <code>displayattr &lt;devspec&gt; [&lt;attrname&gt;]</code> <br>
  739. <br>
  740. Display either the value of a single attribute (see the <a href="#attr">attr</a> command)
  741. or all attributes for a device (if no &lt;attrname&gt; is defined).
  742. See the <a href="#devspec">Device specification</a> section for details on
  743. &lt;devspec&gt;.<br>
  744. If more then one device is specified, then the device name will also included
  745. in the output.
  746. <br>
  747. Examples:
  748. <ul>
  749. <code>
  750. fhem&gt; di WEB<br>
  751. menuEntries AlarmOn,/fhem?cmd=set%20alarm%20on<br>
  752. room Misc.<br>
  753. fhem&gt di WEB room<br>
  754. Misc.<br>
  755. </code>
  756. </ul>
  757. <br>
  758. </ul>
  759. <!-- displayattr end -->
  760. <a name="get"></a>
  761. <h3>get</h3>
  762. <ul>
  763. <code>get &lt;devspec&gt; &lt;type-specific&gt;</code>
  764. <br><br>
  765. Ask a value directly from the device, and wait for an answer. In general, you
  766. can get a list of possible parameters by
  767. <ul>
  768. <code>get &lt;device&gt; ?</code>
  769. </ul>
  770. See the <a href="#devspec">Device specification</a> section for details on
  771. &lt;devspec&gt;.<br>
  772. <br>
  773. Each device has different get parameters, see the corresponding device
  774. section for details.<br>
  775. <br>
  776. </ul>
  777. <!-- get end -->
  778. <a name="include"></a>
  779. <h3>include</h3>
  780. <ul>
  781. <code>include &lt;filename&gt;</code> <br>
  782. <br>
  783. Read in the file, and process every line as a FHEM command.
  784. Note: only experts should use this command.
  785. <br>
  786. </ul>
  787. <!-- include end -->
  788. <a name="inform"></a>
  789. <h3>inform</h3>
  790. <ul>
  791. <code>inform {on|off|timer|raw} [regexp]</code> <br>
  792. <br>
  793. If set to on, and a device state changes, send a notification to the current
  794. client. This command can be used by other programs/modules to receive a
  795. notification.<br>
  796. The option timer prepends a timerstamp to the line. Note: this command is
  797. a nice way to check which events are generated, to help you when creating
  798. <a href="#notify">notify</a> or <a href="#FileLog">FileLog</a> entries.
  799. <br>
  800. </ul>
  801. <!-- inform end -->
  802. <a name="list"></a>
  803. <h3>list</h3>
  804. <ul>
  805. <code>list [devspec] [value]</code><br>
  806. or<br>
  807. <code>list {-r|-R} devspec</code><br>
  808. <br><br>
  809. Output a list of all definitions, all notify settings and all at
  810. entries. This is one of the few commands which return a string in a
  811. normal case.
  812. See the <a href="#devspec">Device specification</a> section for details on
  813. &lt;devspec&gt;.
  814. <br>
  815. If value is specified, then output this property (like DEF, TYPE, etc) or
  816. reading (actuator, measured-temp) for all devices from the devspec.
  817. <br><br>
  818. Example:
  819. <pre><code> fhem> list
  820. Type list <name> for detailed info.
  821. Internal:
  822. global (Internal)
  823. FHZ:
  824. FHZ (fhtbuf: 23)
  825. FS20:
  826. Btn4 (on-old-for-timer)
  827. Roll1 (on)
  828. Stehlampe (off)
  829. FHT:
  830. fl (measured-temp: 21.1 (Celsius))
  831. KS300:
  832. out1 (T: 2.9 H: 74 W: 2.2 R: 8.2 IR: no)
  833. at:
  834. at_rollup (Next: 07:00:00)
  835. notify:
  836. ntfy_btn4 (active)
  837. FileLog:
  838. avglog (active)
  839. </code></pre>
  840. If specifying <code>name</code>, then a detailed status for <code>name</code>
  841. will be displayed, e.g.:
  842. <pre><code> fhem> list fl
  843. Internals:
  844. CODE 5102
  845. DEF 5102
  846. NAME fl
  847. NR 15
  848. STATE measured-temp: 21.1 (Celsius)
  849. TYPE FHT
  850. IODev FHZ
  851. Attributes:
  852. room Heizung
  853. Readings:
  854. 2006-11-02 09:45:56 actuator 19%
  855. [...]
  856. </code></pre>
  857. With the -r (raw) option output the device definition in a format suitable
  858. for inclusion in fhem.cfg and fhem.state. -R returns the definition of the
  859. device itself, together with the definition of probably associated devices.
  860. Note: the algorithm to select associated devices is known to be imperfect.
  861. </ul>
  862. <!-- list end -->
  863. <a name="modify"></a>
  864. <h3>modify</h3>
  865. <ul>
  866. <code>modify &lt;name&gt; &lt;type-dependent-options&gt;</code>
  867. <br><br>
  868. Used to modify some definitions. Useful for changing some <a
  869. href="#at">at</a> or <a href="#notify">notify</a> definitions. If specifying
  870. one argument to an at type definition, only the time part will be changed. In
  871. case of a notify type definition, only the regex part will be changed. All
  872. other values (state, attributes, etc) will remain intact.
  873. After modify, the global event "MODIFIED" will be generated.
  874. <br><br>
  875. Example:
  876. <ul>
  877. <code>define lampon at 19:00 set lamp on</code><br>
  878. <code>modify lampon *19:00</code><br>
  879. <code>modify lampon 19:00 set lamp on-for-timer 16</code><br>
  880. </ul>
  881. </ul>
  882. <!-- modify end -->
  883. <a name="quit"></a>
  884. <h3>quit</h3>
  885. <ul>
  886. <code>quit</code>
  887. <br><br>
  888. If used in a TCP/IP session, terminate the client session.<br>
  889. If used in a script, terminate the parsing of the current script.
  890. <br><br>
  891. Example:
  892. <ul>
  893. <code>quit</code>
  894. </ul>
  895. </ul>
  896. <!-- quit end -->
  897. <a name="reload"></a>
  898. <h3>reload</h3>
  899. <ul>
  900. <code>reload &lt;module&gt;</code>
  901. <br><br>
  902. Reload the given module from the module directory. It is a convenient way to
  903. test modules whithout restarting the program.
  904. <br><br>
  905. Example:
  906. <ul>
  907. <code>reload 99_PRIV</code>
  908. </ul>
  909. </ul>
  910. <!-- reload end -->
  911. <a name="rename"></a>
  912. <h3>rename</h3>
  913. <ul>
  914. <code>rename &lt;oldname&gt; &lt;newname&gt;</code>
  915. <br><br>
  916. Rename a device from the &lt;oldname&gt; to &lt;newname&gt;, together with
  917. its attributes. The global event RENAMED will be generated, see the notify
  918. section for details.
  919. <br><br>
  920. Example:
  921. <ul>
  922. <code>rename FHT_1234 fht.kitchen</code>
  923. </ul>
  924. </ul>
  925. <!-- rename end -->
  926. <a name="rereadcfg"></a>
  927. <h3>rereadcfg</h3>
  928. <ul>
  929. <code>rereadcfg [fhem-config-file]</code>
  930. <br><br>
  931. Re-read the active configuration file, or the optionally specified file.<br>
  932. The sequence: the <a href="#statefile">statefile</a> will be saved first,
  933. then all devices will be deleted, then the currently active config file (or
  934. the specified file) will be read and at last the statefile will be
  935. reloaded.<br>
  936. Upon completion it triggers the global:REREADCFG event. All existing
  937. connections up to the one issuing the rereadcfg will be closed.
  938. <br><br>
  939. Example:
  940. <ul>
  941. <code>rereadcfg</code>
  942. </ul>
  943. </ul>
  944. <!-- rereadcfg end -->
  945. <a name="save"></a>
  946. <h3>save</h3>
  947. <ul>
  948. <code>save [&lt;configfile&gt;]</code>
  949. <br><br>
  950. Save first the <a href="#statefile">statefile</a>, then the
  951. <a href="#configfile">configfile</a> information. If a parameter is specified,
  952. it will be used instead the global configfile attribute.<br><br>
  953. Notes:
  954. <ul>
  955. <li>save only writes out definitions and attributes, but no (set/get)
  956. commands which were previously part of the config file. If you need such
  957. commands after the initialization (e.g. <a href="#FHZset">FHTcode</a>), you
  958. should trigger them via <a href="#notify">notify</a>, when receiving the
  959. INITIALIZED event.</li>
  960. <li>save tries to preserve comments (lines starting with #) and include
  961. structures, but it won't work correctly if some of these files are not
  962. writeable.</li>
  963. <li>before overwriting the files, the old version will be saved, see the <a
  964. href="#restoreDirs">restoreDirs</a> global attribute for details.
  965. </ul>
  966. </ul>
  967. <!-- save end -->
  968. <a name="set"></a>
  969. <h3>set</h3>
  970. <ul>
  971. <code>set &lt;devspec&gt; &lt;type-specific&gt;</code>
  972. <br><br>
  973. Set parameters of a device / send signals to a device. You can
  974. get a list of possible parameters by
  975. <ul>
  976. <code>set &lt;name&gt; ?</code>
  977. </ul>
  978. See the <a href="#devspec">Device specification</a> section for details on
  979. &lt;devspec&gt;. The set command returns only a value on error.<br>
  980. <br>
  981. Each device has different set parameters, see the corresponding device
  982. section for details.<br>
  983. <br><br>
  984. From featurelevel 5.7 on the set and setreading command replaces:
  985. <ul>
  986. <li>[device:name] with the reading, internal or attribute of the device, if
  987. both device and the reading, internal or attribute exists.
  988. <ul>
  989. <li>You can use the r:, i: or a: prefix to restrict the search to one
  990. type, analogue to the devspec filtering.</li>
  991. <li>The suffix :d retrieves the first number</li>
  992. <li>The suffix :i retrieves the integer part of the first number.</li>
  993. <li>The suffix :r&lt;n&gt; retrieves the first number and rounds it to
  994. &lt;n&gt; decimal places. If &lt;n&gt; is missing, then rounds it to
  995. one decimal place.</li>
  996. <li>The suffix :t returns the timestamp (works only for readings)</li>
  997. <li>The suffix :sec returns the number of seconds since the reading was
  998. set.</li>
  999. </ul>
  1000. Example:
  1001. <ul>
  1002. set Lamp blink [blinkDummy:number] [r:blinkDummy:duration:d]
  1003. </ul>
  1004. </li>
  1005. <li>[device:name:d] same as above, but only the number is retrieved</li>
  1006. <li>[device:name:sec] same as above, but only the number is retrieved</li>
  1007. <li>{(perlExpression)} with the result of perlExpression.
  1008. The $DEV variable is additionally available, designating the set device
  1009. name.
  1010. </li>
  1011. </ul>
  1012. These replacements are also known as "set magic".
  1013. <br><br>
  1014. <a name="setExtensions"></a>
  1015. Some modules support a common list of <b>set extensions</b>, and point in
  1016. their documentation to this section. If the module itself implements one of
  1017. the following commands, then the module-implementation takes precedence.
  1018. <ul>
  1019. <li>on-for-timer &lt;seconds&gt<br>
  1020. Issue the on command for the device, and after &lt;seconds&gt; the off
  1021. command. For issuing the off command an internal timer will be
  1022. scheduled, which is deleted upon a restart. To delete this internal
  1023. timer without restart specify 0 as argument.</li>
  1024. <li>off-for-timer &lt;seconds&gt<br>
  1025. see on-for-timer above.</li>
  1026. <li>on-till &lt;timedet&gt<br>
  1027. Issue the on command for the device, and create an at definition with
  1028. &lt;timedet&gt; (in the form HH:MM[:SS]) to set it off. This definition
  1029. is visible, and its name is deviceName+"_till". To cancel the scheduled
  1030. off, delete the at definition. Note: on-till is not active, if the
  1031. specified time is after the current time, in order to make things like
  1032. <ul><code>
  1033. define morningLight at *06:00 set Lamp on-till {sunrise()}
  1034. </code></ul>
  1035. easy.</li>
  1036. <li>on-till-overnight &lt;timedet&gt<br>
  1037. Like on-till, but wont compare the current time with the timespec, so
  1038. following will work:
  1039. <ul><code>
  1040. define nightLight at *{sunset()} set Lamp on-till-overnight 01:00
  1041. </code></ul>
  1042. </li>
  1043. <li>off-till &lt;timedet&gt<br>
  1044. see on-till above.</li>
  1045. <li>off-till-overnight &lt;timedet&gt<br>
  1046. see on-till-overnight above.</li>
  1047. <li>blink &lt;number&gt; &lt;blink-period&gt;<br>
  1048. set the device on for &lt;blink-period&gt; then off for
  1049. &lt;blink-period&gt; and repeat this &lt;number&gt; times.
  1050. To stop blinking specify "0 0" as argument.</li>
  1051. <li>intervals &lt;from1&gt;-&lt;till1&gt; &lt;from2&gt;-&lt;till2&gt;...
  1052. </br>
  1053. set the device on for the specified intervals, which are all timespecs
  1054. in the form HH:MM[:SS]. The intervals are space separated.</li>
  1055. </ul>
  1056. Examples:
  1057. <ul>
  1058. <code>
  1059. set switch on-for-timer 12.5<br>
  1060. set switch on-till {sunset()}<br>
  1061. set switch blink 3 1<br>
  1062. set switch intervals 08:00-12:00 13:00-18:00<br>
  1063. </code>
  1064. </ul>
  1065. </ul>
  1066. <!-- set end -->
  1067. <a name="setdefaultattr"></a>
  1068. <h3>setdefaultattr</h3>
  1069. <ul>
  1070. <code>setdefaultattr [&lt;attrname&gt; [&lt;value&gt;]] </code><br>
  1071. <br>Add a default attribute. Each device defined from now on will receive
  1072. this attribute.<br> If no attrname is specified, then the default attribute
  1073. list will be deleted.
  1074. <br><br>
  1075. Example to set the attribute "room kitchen" and "loglevel 4" to
  1076. each of the lamps:
  1077. <ul>
  1078. <code>setdefaultattr room kitchen</code><br>
  1079. <code>setdefaultattr loglevel 4</code><br>
  1080. <code>define lamp1 FS20 1234 11</code><br>
  1081. <code>define lamp2 FS20 1234 12</code><br>
  1082. <code>define lamp3 FS20 1234 13</code><br>
  1083. <code>setdefaultattr</code><br>
  1084. </ul>
  1085. <br>
  1086. Notes:<br>
  1087. <ul>
  1088. <li>There is no way to delete a single default-attribute from the list</li>
  1089. </ul>
  1090. </ul>
  1091. <!-- setdefaultattr end -->
  1092. <a name="setreading"></a>
  1093. <h3>setreading</h3>
  1094. <ul>
  1095. <code>setreading &lt;devspec&gt; &lt;reading&gt; &lt;value&gt;</code>
  1096. <br><br>
  1097. Set the reading &lt;reading&gt; for the device <code>&lt;name&gt;</code> to
  1098. &lt;value&gt; without sending out commands to the device, but triggering
  1099. events and eventMap/stateFormat transformations as usual. See the set
  1100. command documentation for replacement description.
  1101. <br><br>
  1102. Examples:
  1103. <ul>
  1104. setreading lamp state on
  1105. </ul>
  1106. Note: setreading won't generate an event for device X, if it is called from a
  1107. notify for device X. Use "sleep 0.1; setreading X Y Z" in this case.
  1108. </ul>
  1109. <!-- setreading end -->
  1110. <a name="setstate"></a>
  1111. <h3>setstate</h3>
  1112. <ul>
  1113. <code>setstate &lt;devspec&gt; &lt;value&gt;</code>
  1114. <br><br>
  1115. Set the STATE entry for the device specified by <code>&lt;devspec&gt;</code>,
  1116. which is used for displaying the device state in different frontends.
  1117. No signals will be sent to the device, no events will be generated, and no
  1118. eventMap or stateFormat translation will be done either.
  1119. This command is also used in the <a href="#statefile">statefile</a>.
  1120. See the <a href="#devspec">Device specification</a> section for details on
  1121. &lt;devspec&gt;.
  1122. <br><br>
  1123. Examples:
  1124. <ul>
  1125. setstate lamp on
  1126. </ul>
  1127. </ul>
  1128. <!-- setstate end -->
  1129. <a name="shutdown"></a>
  1130. <h3>shutdown</h3>
  1131. <ul>
  1132. <code>shutdown [restart|exitValue]</code>
  1133. <br><br>
  1134. Shut down the server (after saving the <a href="#statefile">state information
  1135. </a>). It triggers the global:SHUTDOWN event. If the optional restart
  1136. parameter is specified, FHEM tries to restart itself. exitValue may be
  1137. important for start scripts.
  1138. <br><br>
  1139. Example:
  1140. <ul>
  1141. <code>shutdown</code><br>
  1142. <code>shutdown restart</code><br>
  1143. <code>shutdown 1</code><br>
  1144. </ul>
  1145. </ul>
  1146. <!-- shutdown end -->
  1147. <a name="sleep"></a>
  1148. <h3>sleep</h3>
  1149. <ul>
  1150. <code>sleep &lt;sec&gt; [&lt;id&gt;] [quiet]</code>
  1151. <br><br>
  1152. sleep followed by another command is comparable to a nameless <a
  1153. href="#at">at</a>, it executes the following commands after waiting the
  1154. specified time. The unit is seconds, with millisecond accuracy, as you can
  1155. specify decimal places.<br><br>
  1156. A sleep with an &lt;id&gt; will replace a sleep with the same &lt;id&gt;
  1157. and can be canceled by <a href="#cancel">cancel</a>.
  1158. When called in a notify/at/etc, then nonempty return values of the following
  1159. commands are logged to the global logfile with loglevel 2.<br> If quiet is
  1160. specified, then skip this logging.
  1161. <br><br>
  1162. Example:
  1163. <ul>
  1164. define n3 notify btn3.* set lamp on;;sleep 1.5;;set lamp off<br>
  1165. define a3 at +*00:05 set Windsensor 1w_measure;; sleep 2 quiet;; get
  1166. Windsensor 1w_temp
  1167. </ul>
  1168. <br>
  1169. Note: a sleep not followed by any command will block FHEM, is deprecated, and
  1170. it issues a WARNING in the FHEM log.
  1171. <br>
  1172. </ul>
  1173. <!-- sleep end -->
  1174. <a name="trigger"></a>
  1175. <h3>trigger</h3>
  1176. <ul>
  1177. <code>trigger &lt;devspec&gt; &lt;state&gt;</code>
  1178. <br><br>
  1179. Trigger a <a href="#notify">notify</a> definition.
  1180. See the <a href="#devspec">Device specification</a> section for details on
  1181. &lt;devspec&gt;.
  1182. <br><br>
  1183. Example:
  1184. <ul>
  1185. <code>trigger btn3 on</code>
  1186. </ul>
  1187. </ul>
  1188. <!-- trigger end -->
  1189. <!-- commands end - diese Zeile nicht entfernen! -->
  1190. <a name="global"></a>
  1191. <h3>global</h3>
  1192. <ul>
  1193. The global device is used to set different global attributes. It will be
  1194. automatically defined, it cannot be deleted or renamed and has no set or get
  1195. parameters<br>
  1196. <br>
  1197. <b>Define</b><ul>N/A</ul><br>
  1198. <b>Set </b><ul>N/A</ul><br>
  1199. <b>Get</b><ul>N/A</ul><br>
  1200. <b>Attributes</b>
  1201. <ul>
  1202. <li><a href="#archivedir">archivedir</a></li>
  1203. <li><a href="#archivecmd">archivecmd</a></li>
  1204. <li><a href="#nrarchive">nrarchive</a></li>
  1205. <a name="archivesort"></a>
  1206. <li>archivesort<br>
  1207. archivesort may be set to the (default) alphanum or timestamp, and
  1208. specifies how the last files are computed for the nrarchive attribute.
  1209. </li><br>
  1210. <a name="autoload_undefined_devices"></a>
  1211. <li>autoload_undefined_devices<br>
  1212. If set, automatically load the corresponding module when a message
  1213. of this type is received. This is used by the <a href="#autocreate">
  1214. autocreate</a> device, to automatically create a FHEM device upon
  1215. receiving a corresponding message.
  1216. </li><br>
  1217. <a name="autosave"></a>
  1218. <li>autosave<br>
  1219. enable some modules to automatically trigger save after a configuration
  1220. change, e.g. after a new device was created. Default is 1 (true), you
  1221. can deactivate this feature by setting the value to 0.
  1222. </li>
  1223. <a name="backupcmd"></a>
  1224. <li>backupcmd<br>
  1225. You could pass the backup to your own command / script by using this attribute.
  1226. If this attribute is specified, then it will be started as a shell command and
  1227. passes a space separated list of files / directories as <strong>one</strong>
  1228. argument to the command, like e.g.:
  1229. <br>
  1230. <ul>
  1231. <code>"/etc/fhem.cfg /var/log/fhem/fhem.save /usr/share/fhem/contrib
  1232. /usr/share/fhem/FHEM /usr/share/fhem/foo /usr/share/fhem/foobar
  1233. /usr/share/fhem/www"</code>
  1234. </ul>
  1235. Note: Your command / script has to return the string "backup done" or
  1236. everything else to report errors, to work properly with update!<br>
  1237. This Attribute is used by the <a href="#backup">backup</a> command.<br>
  1238. Example:<br>
  1239. <ul>
  1240. attr global backupcmd /usr/local/bin/myBackupScript.sh
  1241. </ul>
  1242. </li><br>
  1243. <a name="backupdir"></a>
  1244. <li>backupdir<br>
  1245. A folder to store the compressed backup file.
  1246. This Attribute is used by the <a href="#backup">backup</a> command.<br>
  1247. Example:<br>
  1248. <ul>
  1249. attr global backupdir /Volumes/BigHD
  1250. </ul>
  1251. </li><br>
  1252. <a name="backupsymlink"></a>
  1253. <li>backupsymlink<br>
  1254. If this attribute is set to everything else as "no", the archive
  1255. command tar will support symlinks in your backup. Otherwise, if this
  1256. attribute is set to "no" symlinks are ignored by tar.
  1257. This Attribute is used by the <a href="#backup">backup</a> command.<br>
  1258. Example:<br>
  1259. <ul>
  1260. attr global backupsymlink yes
  1261. </ul>
  1262. </li><br>
  1263. <a name="blockingCallMax"></a>
  1264. <li>blockingCallMax<br>
  1265. Limit the number of parallel running processes started by the
  1266. BlockingCall FHEM helper routine. Useful on limited hardware.
  1267. </li><br>
  1268. <a name="configfile"></a>
  1269. <li>configfile<br>
  1270. Contains the name of the FHEM configuration file. If <a
  1271. href="#save">save</a> is called without argument, then the output will
  1272. be written to this file.
  1273. </li><br>
  1274. <a name="commandref"></a>
  1275. <li>commandref<br>
  1276. If set to "full" (default), then a full commandref will be generated
  1277. after each update. If set to modular, there is only a short description
  1278. at the beginning, and the module documentation is loaded from FHEM
  1279. dynamically.
  1280. </li><br>
  1281. <a name="dnsHostsFile"></a>
  1282. <li>dnsHostsFile<br>
  1283. If dnsServer is set, check the contents of the file specified as
  1284. argument. To use the system hosts file, set it to /etc/hosts on
  1285. Linux/Unix/OSX and C:\windows\system32\drivers\etc\hosts on Windows.
  1286. Note: only IPv4 is supported.
  1287. </li><br>
  1288. <a name="dnsServer"></a>
  1289. <li>dnsServer<br>
  1290. Contains the IP address of the DNS Server. If some of the modules or
  1291. user code calls the HttpUtils_NonblockingGet function, and this
  1292. attribute is set, then FHEM specific nonblocking code will be used to
  1293. resolve the given address. If this attribute is not set, the blocking
  1294. OS implementation (inet_aton and gethostbyname) will be used.
  1295. </li><br>
  1296. <a name="holiday2we"></a>
  1297. <li>holiday2we<br>
  1298. If this attribute is set, then the <a href="#perl">$we</a> variable
  1299. will be true, if the value of the <a href="#holiday">holiday</a>
  1300. variable referenced by this attribute is not none.<br>
  1301. Example:<br>
  1302. <ul>
  1303. attr global holiday2we hessen
  1304. </ul>
  1305. </li><br>
  1306. <a name="featurelevel"></a>
  1307. <li>featurelevel<br>
  1308. Enable/disable old or new features, based on FHEM version.
  1309. E.g. the $value hash for notify is only set for featurelevel up to 5.6,
  1310. as it is deprecated, use the Value() function instead.
  1311. </li><br>
  1312. <a name="logdir"></a>
  1313. <li>logdir<br>
  1314. If set, the %L attribute in the logfile attribute (or in the FileLog
  1315. modules file definition) is replaced wth the value of the attribute.
  1316. Note: changing the value won't result in moving the files and may cause
  1317. other problems.
  1318. </li><br>
  1319. <a name="logfile"></a>
  1320. <li>logfile<br>
  1321. Specify the logfile to write. You can use "-" for
  1322. stdout, in this case the server won't background itself.<br>
  1323. The logfile name can also take wildcards for easier logfile rotation,
  1324. see the <a href="#FileLog">FileLog</a> section. Just apply the
  1325. <code>archivecmd / archivedir / nrarchive</code> attributes to the
  1326. <code>global</code> device as you would do for a FileLog device.<br>
  1327. You can access the current name of the logfile with
  1328. <code>{ $currlogfile }</code>.
  1329. </li><br>
  1330. <a name="modpath"></a>
  1331. <li>modpath<br>
  1332. Specify the path to the modules directory <code>FHEM</code>. The path
  1333. does <b>not</b> contain the directory FHEM. Upon setting the
  1334. attribute, the directory will be scanned for filenames of the form
  1335. NN_&lt;NAME&gt;.pm, and make them available for device definition under
  1336. &lt;NAME&gt;. If the first device of type &lt;NAME&gt; is defined, the
  1337. module will be loaded, and its function with the name
  1338. &lt;NAME&gt;_Initialize will be called. Exception to this rule are
  1339. modules with NN=99, these are considered to be utility modules
  1340. containing only perl helper functions, they are loaded at startup (i.e.
  1341. modpath attribute definition time).
  1342. </li><br>
  1343. <a name="motd"></a>
  1344. <li>motd<br>
  1345. Message Of The Day. Displayed on the homescreen of the FHEMWEB package,
  1346. or directly after the telnet logon, before displaying the fhem> prompt.
  1347. SecurityCheck is setting motd if it is not defined upon startup, to
  1348. avoid this set the motd value to none. motd is also used to show
  1349. collected error messages upon FHEM start.
  1350. </li><br>
  1351. <a name="mseclog"></a>
  1352. <li>mseclog<br>
  1353. If set, the timestamp in the logfile will contain a millisecond part.
  1354. </li><br>
  1355. <a name="nofork"></a>
  1356. <li>nofork<br>
  1357. If set and the logfile is not "-", do not try to background. Needed on
  1358. some Fritzbox installations, and it will be set automatically for
  1359. Windows.
  1360. </li><br>
  1361. <a name="pidfilename"></a>
  1362. <li>pidfilename<br>
  1363. Write the process id of the perl process to the specified file. The
  1364. server runs as a daemon, and some distributions would like to check by
  1365. the pid if we are still running. The file will be deleted upon
  1366. shutdown.
  1367. </li><br>
  1368. <a name="proxy"></a>
  1369. <li>proxy<br>
  1370. IP:PORT of the proxy server to be used by HttpUtils.
  1371. </li><br>
  1372. <a name="proxyAuth"></a>
  1373. <li>proxyAuth<br>
  1374. Base64 encoded username:password
  1375. </li><br>
  1376. <a name="proxyExclude"></a>
  1377. <li>proxyExclude<br>
  1378. regexp for hosts to exclude when using a proxy
  1379. </li><br>
  1380. <a name="restoreDirs"></a>
  1381. <li>restoreDirs<br>
  1382. update saves each file before overwriting it with the new version from
  1383. the Web. For this purpose update creates a directory restoreDir in the
  1384. global modpath directory, then a subdirectory with the current date,
  1385. where the old version of the currently replaced file is stored.
  1386. The default value of this attribute is 3, meaning that 3 old versions
  1387. (i.e. date-directories) are kept, and the older ones are deleted.<br>
  1388. fhem.cfg and fhem.state will be also copied with this method before
  1389. executing save. To restore the files, you can use the restore FHEM
  1390. command.<br>
  1391. <br>If the attribute is set to 0, the feature is deactivated.
  1392. </li><br>
  1393. <li><a href="#fheminfo">sendStatistics</a><br>
  1394. <a name="statefile"></a>
  1395. <li>statefile<br>
  1396. Set the filename where the state and certain <a href="#at">at</a>
  1397. information will be saved before shutdown. If it is not specified, then
  1398. no information will be saved.
  1399. </li><br>
  1400. <li><a href="#title">title</a><br>
  1401. <li><a href="#fheminfo">uniqueID</a><br>
  1402. <a name="useInet6"></a>
  1403. <li>useInet6<br>
  1404. try to use IPv6 in HttpUtils for communication. If the server does not
  1405. have an IPv6 address, fall back to IPv4. Note: IO::Socket::INET6 is
  1406. required.
  1407. </li><br>
  1408. <a name="userattr"></a>
  1409. <li>userattr<br>
  1410. A space separated list which contains the names of additional
  1411. attributes for all devices. Without specifying them you will not be
  1412. able to set them (in order to prevent typos).<br>
  1413. userattr can also specified for other devices, in this case
  1414. these additinal attribute names are only valid for this device.
  1415. </li><br>
  1416. <a name="dupTimeout"></a>
  1417. <li>dupTimeout<br>
  1418. Define the timeout for which 2 identical events from two different
  1419. receiver are considered a duplicate. Default is 0.5 seconds.
  1420. </li><br>
  1421. <a name="showInternalValues"></a>
  1422. <li>showInternalValues<br>
  1423. Show data used for internal computations. If the name of an internal
  1424. value, reading or attribute starts with dot (.), then it is normally
  1425. hidden, and will only be visible, if this attribute is set to 1.
  1426. The attribute is checked by the list command, by the FHEMWEB room
  1427. overview and by xmllist.
  1428. </li><br>
  1429. <a name="sslVersion"></a>
  1430. <li>sslVersion<br>
  1431. Specifies the accepted cryptography algorithms by all modules using the
  1432. TcpServices helper module. The current default TLSv12:!SSLv3 is thought
  1433. to be more secure than the previously used SSLv23:!SSLv3:!SSLv2, but it
  1434. causes problems with some not updated web services.
  1435. </li><br>
  1436. <a name="stacktrace"></a>
  1437. <li>stacktrace<br>
  1438. if set (to 1), dump a stacktrace to the log for each "PERL WARNING".
  1439. </li><br>
  1440. <a name="restartDelay"></a>
  1441. <li>restartDelay<br>
  1442. set the delay for shutdown restart, default is 2 (seconds).
  1443. </li><br>
  1444. </ul>
  1445. <br>
  1446. <b>Events:</b>
  1447. <ul>
  1448. <li>INITIALIZED<br>after initialization is finished.</li>
  1449. <li>REREADCFG<br>after the configuration is reread.</li>
  1450. <li>SAVE<br>before the configuration is saved.</li>
  1451. <li>SHUTDOWN<br>before FHEM is shut down.</li>
  1452. <li>DEFINED &lt;devname&gt;<br>after a device is defined.</li>
  1453. <li>DELETED &lt;devname&gt;<br>after a device was deleted.</li>
  1454. <li>RENAMED &lt;old&gt; &lt;new&gt;<br>after a device was renamed.</li>
  1455. <li>UNDEFINED &lt;defspec&gt;<br>upon reception of a message for an
  1456. undefined device.</li>
  1457. <li>MODIFIED &lt;defspec&gt;</br> after a device modification.</li>
  1458. <li>UPDATE</br> after an update is completed.</li>
  1459. </ul>
  1460. </ul>
  1461. <!-- global end - do not remove this line! -->
  1462. <a name="perl"></a>
  1463. <h3>Perl specials</h3>
  1464. If you want to automate some tasks via FHEM, then you'll probably use <a
  1465. href="#at">at</a> or <a href="#notify">notify</a>. For more complex tasks
  1466. you'll use either a shell-script or a perl "oneliner" as the at/notify
  1467. argument. This chapter gives some tips in using the perl oneliners.<br><br>
  1468. <li>To test the following perl oneliners, type them on the telnet prompt (or
  1469. FHEMWEB text input) by enclosing it in {}, one line at once. The last line
  1470. will only write something in the logfile, the output of the other lines is
  1471. directly visible.
  1472. <ul>
  1473. { "Hello" }<br>
  1474. { 1+3*4 }<br>
  1475. { `ls /etc` }<br>
  1476. { Log 1, "Hello" }<br>
  1477. </ul>
  1478. <br>
  1479. <li>
  1480. Perl expressions are separated by ;, in FHEM oneliners they have to
  1481. escaped with ;;<br>
  1482. <ul>
  1483. { my $a = 1+1;; Log 1, "Hello $a" }
  1484. </ul>
  1485. <br>
  1486. <li>To use FHEM commands from the perl expression, use the function fhem(),
  1487. which takes a string argument, this string will be evaluated as a FHEM
  1488. command:<br>
  1489. <ul>
  1490. { fhem "set light on" }<br>
  1491. define n1 notify piri:on { fhem "set light on" }
  1492. </ul>
  1493. Note: if this function returns a value, it will also be logged into the
  1494. global FHEM log. Use 1 as a second argument to disable this logging, this
  1495. makes sense when obtainig some values via FHEM "get...".
  1496. <br>
  1497. <br>
  1498. <li>Notify can be used to store macros for manual execution. Use the <a
  1499. href="#trigger">trigger</a> command to execute the macro:<br>
  1500. <ul>
  1501. define MyMacro notify MyMacro { Log 1, "Hello"}<br>
  1502. trigger MyMacro<br>
  1503. define MacroWithArg notify MyMacro { Log 1, "Hello %"}<br>
  1504. trigger MyMacro MyArg<br>
  1505. </ul>
  1506. <br>
  1507. <li>To make date and time handling easier, the variables $sec, $min, $hour,
  1508. $mday, $month, $year, $wday, $yday, $isdst are available in the perl
  1509. oneliners (see also perldoc -f localtime). Exceptions: $month is in the
  1510. range of 1 to 12, and $year is corrected by 1900 (as I would expect).
  1511. Additionally the variable $hms contains the time in the HH:MM:SS format and
  1512. $today the current date in YYYY-MM-DD format.
  1513. <br>
  1514. Additionally the variabe $we is 1 if it is weekend (i.e $wday == 0 or
  1515. $wday == 6), and 0 otherwise. If the <a href="#holiday2we">holida2we</a>
  1516. global attribute is set, $we is 1 for holidays too.<br>
  1517. <ul>
  1518. define n2 notify piri:on { if($hour &gt; 18 || $hour &lt; 5) {
  1519. fhem "set light on" } }<br>
  1520. define roll_en *07:45:00 { fhem "trigger SwitchAllRoll on" if(!$we) }<br>
  1521. define roll_en *08:30:00 { fhem "trigger SwitchAllRoll on" if($we) }<br>
  1522. </ul>
  1523. <br>
  1524. <li>
  1525. The following helper functions are defined in 99_Util.pm (which will
  1526. be loaded automatically, as every module with prefix 99):
  1527. <ul>
  1528. <li>min(a,b), max(a,b)</li>
  1529. <li>time_str2num("YYYY-MM-DD HH:MM:SS") returns a numerical value,
  1530. which makes computation of time differences easier</li>
  1531. <li>abstime2rel("HH:MM:SS") converts an absolute time to a relative one
  1532. </li>
  1533. </ul>
  1534. </li>
  1535. <li>
  1536. To access the device states/attributes, use the following functions:
  1537. <br>
  1538. <ul>
  1539. <li>Value(&lt;devicename&gt;)<br>
  1540. returns the state of the device (the string you see in paranthesis in
  1541. the output of the list command).
  1542. </li><br>
  1543. <li>OldValue(&lt;devicename&gt;)
  1544. <li>OldTimestamp(&lt;devicename&gt;)<br>
  1545. returns the old value/timestamp of the device.
  1546. </li><br>
  1547. <li>
  1548. ReadingsVal(&lt;devicename&gt;,&lt;reading&gt;,&lt;defaultvalue&gt;)<br>
  1549. Return the reading (the value in the Readings section of "list device")
  1550. </li><br>
  1551. <li>
  1552. ReadingsNum(&lt;devicename&gt;,&lt;reading&gt;,
  1553. &lt;defaultvalue&gt;,&lt;round&gt;)<br>
  1554. Return the first number from a reading value.
  1555. Round id to &lt;round&gt; devimal places (optional parameter).
  1556. </li><br>
  1557. <li>ReadingsTimestamp(&lt;devicename&gt;,&lt;reading&gt;,&lt;
  1558. defaultvalue&gt;)<br>
  1559. returns the timestamp of the reading.
  1560. </li><br>
  1561. <li>ReadingsAge(&lt;devicename&gt;,&lt;reading&gt;,&lt;defaultvalue&gt;)
  1562. <br>
  1563. returns the age of the reading in seconds.
  1564. </li><br>
  1565. <li>
  1566. AttrVal(&lt;devicename&gt;,&lt;attribute&gt;,&lt;defaultvalue&gt;)<br>
  1567. Return the attribute of the device
  1568. <br><br>
  1569. { Value("wz") }<br>
  1570. { OldValue("wz") }<br>
  1571. { time_str2num(OldTimestamp("wz")) }<br>
  1572. { ReadingsVal("wz", "measured-temp", "20")+0 }<br>
  1573. { ReadingsTimestamp("wz", "measured-temp", 0)}<br>
  1574. { AttrVal("wz", "room", "none") }<br>
  1575. </li><br>
  1576. <li>
  1577. AttrNum(&lt;devicename&gt;,&lt;attribute&gt;,
  1578. &lt;defaultvalue&gt;,&lt;round&gt;)<br>
  1579. Return the first number from an attribute value.
  1580. Round id to &lt;round&gt; devimal places (optional parameter).
  1581. </li><br>
  1582. <li>
  1583. InternalVal(&lt;devicename&gt;,&lt;property&gt;,&lt;defaultvalue&gt;)
  1584. <br>
  1585. Return the internal value (the value in the Internals section of "list
  1586. device").
  1587. </li><br>
  1588. <li>
  1589. InternalNum(&lt;devicename&gt;,&lt;property&gt;,
  1590. &lt;defaultvalue&gt;,&lt;round&gt;)<br>
  1591. Return the first number from an internal value.
  1592. Round id to &lt;round&gt; devimal places (optional parameter).
  1593. </li><br>
  1594. </ul>
  1595. <li>
  1596. By using the 99_SUNRISE_EL.pm module, you have access to the following
  1597. functions: <br>
  1598. <ul>
  1599. sunset($offset, $min, $max)<br>
  1600. sunrise($offset, $min, $max)<br>
  1601. isday()<br>
  1602. </ul>
  1603. offset is in seconds, and the format of min/max is "HH:MM" or "HH:MM:SS".
  1604. isday returns 1 if the sun is visible, and 0 else.
  1605. </li>
  1606. <br>
  1607. <br>
  1608. <!-- perl end - diese Zeile nicht entfernen! -->
  1609. <a name="gnuplot-syntax"></a>
  1610. <h3>gnuplot file syntax</h3>
  1611. The .gplot files are also used by the <a href="#FHEMWEB">FHEMWEB</a>/SVG module
  1612. when the <a href="#plotmode">plotmode</a> attribute is set to SVG. In this case
  1613. only a subset of the .gnuplot attributes are used, and some lines have special
  1614. meanings: the difference will be explained in this chapter. See also <a
  1615. href="http://wiki.fhem.de/wiki/Creating_Plots">this</a> FHEM Wiki entry on
  1616. creating logs.<br>
  1617. Following is a minimal .gplot definition (valid only for plotmode SVG):<br>
  1618. <pre>
  1619. set terminal size &lt;SIZE&gt;
  1620. #FileLog 4:::
  1621. plot title 'Temperature' with lines
  1622. </pre>
  1623. The .gnuplot file consists of 3 parts:
  1624. <ul>
  1625. <li>set commands<br>
  1626. Following sets are recognized:
  1627. <ul>
  1628. <li>terminal, only the size parameter.<br>
  1629. This is usually set to &lt;SIZE&gt;, which is replaced by the <a
  1630. href="#plotsize">plotsize</a> attribute of the FHEMWEB or weblink
  1631. instance.</li>
  1632. <li>title<br>
  1633. Usually set to &lt;TL&gt; which is replace by the weblink <a
  1634. href="#title">title</a> attribute, or to &lt;Lx&gt;, which is replaced
  1635. by the weblink <a href="#label">label</a> attribute.</li>
  1636. <li>ylabel,y2label<br>
  1637. Left and right labels, printed vertically. Are also subject to label
  1638. replacement.</li>
  1639. <li>yrange,y2range<br>
  1640. Specify the range of the left and right axis. Examples:<br>
  1641. <ul>
  1642. set yrange [-0.1:1.1]<br>
  1643. set y2range [0:]<br>
  1644. </ul>
  1645. </li>
  1646. <li>ytics,y2tics<br>
  1647. the label for the left/right axis tics. Examples:<br>
  1648. <ul>
  1649. set ytics ("on" 0, "off" 1)<br>
  1650. set y2tics<br>
  1651. </ul>
  1652. </li>
  1653. </ul>
  1654. </li>
  1655. <br>
  1656. <li>#FileLog entries<br>
  1657. Each line from the plot section must have one corresponding #FileLog
  1658. line. For the syntax see the column_spec paragraph of the <a
  1659. href="#FileLogget">Filelog get</a> description.
  1660. Note that for SVG plots the first column of the input file always has to
  1661. be in the standard fhem timestamp format (YYYY-MM-DD_HH:MM:SS)
  1662. </li>
  1663. <br>
  1664. <li>plot entries<br>
  1665. There is always one plot command with comma separated argument-blocks.
  1666. Each argument-block represents one line, and has its own parameters.
  1667. Following parameters are recognized:
  1668. <ul>
  1669. <li>axes x1y1 / x1y2<br>
  1670. tells the program to assign the current line to one of the two axes
  1671. (left or right).
  1672. </li>
  1673. <li>title<br>
  1674. Caption of the line. Whan clicking on this title, a small javascript
  1675. program will change the title to the min/max and last values of the plot,
  1676. will enable copying this line or pasting an already copied one (the
  1677. existing scale of the plot wont'be changed, only the pasted line will
  1678. be scaled), and other lines of the plot will temporarily be hidden.
  1679. </li>
  1680. <li>with &lt;linetype&gt;<br>
  1681. Specify the line type. Following types are recognized: points,
  1682. steps, fsteps, histeps and lines. Everything unknown will be mapped to
  1683. the type lines.
  1684. SVG special: cubic and quadratic, are mapped to the SVG path types C,
  1685. and Q respectively.
  1686. </li>
  1687. <li>ls &lt;linestyle&gt;<br>
  1688. The linestyle defaults to l0 for the first line, l1 for the second, and
  1689. so on. It is defined in the svg_style.css file. There are two sets
  1690. defined here: l0-l8 and l0fill-l6fill. The second set must be specified
  1691. explicitly. If the name of the linestyle contains the word fill, then
  1692. plots of the lineytype "lines" will have an additional starting and
  1693. ending segment, so that filling is done correctly.<br>
  1694. See the SVG spec for details of this CSS file.
  1695. Note: if you plan to use this attribute, you have to specify it for all
  1696. the lines (attribute-blocks) in the plot command.
  1697. </li>
  1698. <li>lw &lt;linewidth&gt;<br>
  1699. Sets the stroke-width style of the line. This attribute is deprecated,
  1700. the corresponding feature of the CSS file / (attribute ls) should be
  1701. used instead.
  1702. </li>
  1703. </ul>
  1704. </ul>
  1705. </li>
  1706. </div> <!-- right -->
  1707. </body>
  1708. </html>