95_PostMe.pm 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665
  1. ########################################################################################
  2. #
  3. # PostMe.pm
  4. #
  5. # FHEM module to set up a system of sticky notes, similar to Post-Its
  6. #
  7. # Prof. Dr. Peter A. Henning
  8. #
  9. # $Id: 95_PostMe.pm 15213 2017-10-08 17:25:19Z phenning $
  10. #
  11. # Not named Post-It, which is a trademark of 3M
  12. #
  13. ########################################################################################
  14. #
  15. # This programm is free software; you can redistribute it and/or modify
  16. # it under the terms of the GNU General Public License as published by
  17. # the Free Software Foundation; either version 2 of the License, or
  18. # (at your option) any later version.
  19. #
  20. # The GNU General Public License can be found at
  21. # http://www.gnu.org/copyleft/gpl.html.
  22. # A copy is found in the textfile GPL.txt and important notices to the license
  23. # from the author is found in LICENSE.txt distributed with these scripts.
  24. #
  25. # This script is distributed in the hope that it will be useful,
  26. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28. # GNU General Public License for more details.
  29. #
  30. ########################################################################################
  31. package main;
  32. use strict;
  33. use warnings;
  34. use vars qw(%defs); # FHEM device/button definitions
  35. use vars qw(%intAt); # FHEM at definitions
  36. use vars qw($FW_RET); # Returned data (html)
  37. use vars qw($FW_RETTYPE); # image/png or the like
  38. use vars qw($FW_wname); # Web instance
  39. use Time::Local;
  40. #########################
  41. # Global variables
  42. my $postmeversion = "2.04";
  43. my $FW_encoding = "UTF-8";
  44. #########################################################################################
  45. #
  46. # PostMe_Initialize
  47. #
  48. # Parameter hash = hash of device addressed
  49. #
  50. #########################################################################################
  51. sub PostMe_Initialize ($) {
  52. my ($hash) = @_;
  53. my $devname = $hash->{NAME};
  54. $hash->{DefFn} = "PostMe_Define";
  55. $hash->{SetFn} = "PostMe_Set";
  56. $hash->{GetFn} = "PostMe_Get";
  57. $hash->{UndefFn} = "PostMe_Undef";
  58. $hash->{InitFn} = "PostMe_Init";
  59. $hash->{AttrFn} = "PostMe_Attr";
  60. $hash->{AttrList} = "postmeTTSFun postmeTTSDev postmeMsgFun postme[0-9]+MsgRec postmeMailFun postme[0-9]+MailRec ".
  61. "postmeStd postmeIcon postmeStyle:test,jQuery,HTML,SVG postmeClick:0,1 listseparator ".$readingFnAttributes;
  62. $hash->{FW_detailFn} = "PostMe_detailFn";
  63. $data{FWEXT}{"/PostMe_widget"}{FUNC} = "PostMe_widget";
  64. $data{FWEXT}{"/PostMe_widget"}{FORKABLE} = 1;
  65. return undef;
  66. }
  67. #########################################################################################
  68. #
  69. # PostMe_Define - Implements DefFn function
  70. #
  71. # Parameter hash = hash of device addressed, def = definition string
  72. #
  73. #########################################################################################
  74. sub PostMe_Define ($$) {
  75. my ($hash, $def) = @_;
  76. my @a = split("[ \t][ \t]*", $def);
  77. my $now = time();
  78. my $devname = $hash->{NAME};
  79. $modules{PostMe}{defptr}{$a[0]} = $hash;
  80. readingsBeginUpdate($hash);
  81. readingsBulkUpdate($hash,"state","Initialized");
  82. readingsEndUpdate($hash,1);
  83. InternalTimer(gettimeofday()+2, "PostMe_Init", $hash,0);
  84. return undef;
  85. }
  86. #########################################################################################
  87. #
  88. # PostMe_Undef - Implements Undef function
  89. #
  90. # Parameter hash = hash of device addressed, def = definition string
  91. #
  92. #########################################################################################
  93. sub PostMe_Undef ($$) {
  94. my ($hash,$arg) = @_;
  95. RemoveInternalTimer($hash);
  96. return undef;
  97. }
  98. #########################################################################################
  99. #
  100. # PostMe_Attr - Implements Attr function
  101. #
  102. # Parameter hash = hash of device addressed, ???
  103. #
  104. #########################################################################################
  105. sub PostMe_Attr($$$) {
  106. my ($cmd, $listname, $attrName, $attrVal) = @_;
  107. return;
  108. }
  109. #########################################################################################
  110. #
  111. # PostMe_Init - Check, if default PostMes have been defined
  112. #
  113. # Parameter hash = hash of device addressed
  114. #
  115. #########################################################################################
  116. sub PostMe_Init($) {
  117. my ($hash) = @_;
  118. my $devname = $hash->{NAME};
  119. my $now = time();
  120. my $err = 0;
  121. #-- current number of PostMes
  122. my $cnop = ReadingsVal($devname,"postmeCnt",0);
  123. my @std = split(',',AttrVal("$devname","postmeStd",""));
  124. for( my $i=0;$i<int(@std);$i++ ){
  125. my $pmn = PostMe_Check($hash,$std[$i]);
  126. if( !$pmn || ($pmn-1)!=$i ){
  127. $err = 1;
  128. Log 1,"[PostMe_Init] PostMe ".$std[$i]." not properly defined";
  129. }
  130. }
  131. #-- no write operation if everything is ok
  132. return undef
  133. if( $err==0 );
  134. #-- must be improved: Enforce first PostMes to be the standard ones
  135. for( my $i=0;$i<int(@std);$i++ ){
  136. PostMe_Create($hash,$std[$i]);
  137. }
  138. readingsSingleUpdate($hash,"state","OK",1);
  139. }
  140. #########################################################################################
  141. #
  142. # PostMe_Check - Check, if a PostMe exists with this name and return its number
  143. #
  144. # Parameter hash = ash of device addressed
  145. # listname = name of PostMe
  146. #
  147. #########################################################################################
  148. sub PostMe_Check($$) {
  149. my ($hash,$listname) = @_;
  150. my $devname = $hash->{NAME};
  151. my ($loop,$res);
  152. #-- current number of PostMes
  153. my $cnop = ReadingsVal($devname,"postmeCnt",0);
  154. for( $loop=1;$loop<=$cnop;$loop++){
  155. $res = ReadingsVal($devname, sprintf("postme%02dName",$loop), undef);
  156. last
  157. if($res eq $listname);
  158. }
  159. #-- no PostMe with this name
  160. if( $res ne $listname ){
  161. return undef;
  162. }else{
  163. return $loop;
  164. }
  165. }
  166. #########################################################################################
  167. #
  168. # PostMe_Create - Create a new PostMe
  169. #
  170. # Parameter hash = hash of device addressed
  171. # listname = name of PostMe
  172. #
  173. #########################################################################################
  174. sub PostMe_Create($$) {
  175. my ($hash,$listname) = @_;
  176. my $devname = $hash->{NAME};
  177. if( PostMe_Check($hash,$listname) ){
  178. my $mga = "Error, a PostMe named $listname does already exist";
  179. Log 1,"[PostMe_Create] $mga";
  180. return "$mga";
  181. }
  182. #-- current number of PostMes
  183. my $cnop = ReadingsVal($devname,"postmeCnt",0);
  184. $cnop++;
  185. readingsBeginUpdate($hash);
  186. readingsBulkUpdate($hash, sprintf("postme%02dName",$cnop),$listname);
  187. readingsBulkUpdate($hash, sprintf("postme%02dCont",$cnop),"");
  188. readingsBulkUpdate($hash, "postmeCnt",$cnop);
  189. readingsEndUpdate($hash,1);
  190. Log3 $devname,3,"[PostMe] Added a new PostMe named $listname";
  191. return undef;
  192. }
  193. #########################################################################################
  194. #
  195. # PostMe_Delete - Delete an existing PostMe
  196. #
  197. # Parameter hash = hash of device addressed
  198. # listname = name of PostMe
  199. #
  200. #########################################################################################
  201. sub PostMe_Delete($$) {
  202. my ($hash,$listname) = @_;
  203. my $devname = $hash->{NAME};
  204. my $loop;
  205. if( index(AttrVal("$devname","postmeStd",""),$listname) != -1){
  206. my $mga = "Error, the PostMe named $listname is a standard PostMe and cannot be deleted";
  207. Log 1,"[PostMe_Delete] $mga";
  208. return "$mga";
  209. }
  210. my $pmn=PostMe_Check($hash,$listname);
  211. if( !$pmn ){
  212. my $mga = "Error, a PostMe named $listname does not exist";
  213. Log 1,"[PostMe_Delete] $mga";
  214. return "$mga";
  215. }
  216. #-- current number of PostMes
  217. my $cnop = ReadingsVal($devname,"postmeCnt",0);
  218. readingsBeginUpdate($hash);
  219. #-- re-ordering
  220. for( $loop=$pmn;$loop<$cnop;$loop++){
  221. readingsBulkUpdate($hash, sprintf("postme%02dName",$loop),
  222. ReadingsVal($devname, sprintf("postme%02dName",$loop+1),""));
  223. readingsBulkUpdate($hash, sprintf("postme%02dCont",$loop),
  224. ReadingsVal($devname, sprintf("postme%02dCont",$loop+1),""));
  225. }
  226. $cnop--;
  227. readingsBulkUpdate($hash, "postmeCnt",$cnop);
  228. readingsEndUpdate($hash,1);
  229. fhem("deletereading $devname ".sprintf("postme%02dName",$cnop+1));
  230. fhem("deletereading $devname ".sprintf("postme%02dCont",$cnop+1));
  231. Log3 $devname,3,"[PostMe] Deleted PostMe named $listname";
  232. return undef;
  233. }
  234. #########################################################################################
  235. #
  236. # PostMe_Rename - Renames an existing PostMe
  237. #
  238. # Parameter hash = hash of device addressed
  239. # listname = name of PostMe
  240. # newname = newname of PostMe
  241. #
  242. #########################################################################################
  243. sub PostMe_Rename($$$) {
  244. my ($hash,$listname,$newname) = @_;
  245. my $devname = $hash->{NAME};
  246. my $loop;
  247. if( index(AttrVal("$devname","postmeStd",""),$listname) != -1){
  248. my $mga = "Error, the PostMe named $listname is a standard PostMe and cannot be renamed";
  249. Log 1,"[PostMe_Rename] $mga";
  250. return "$mga";
  251. }
  252. my $pmn=PostMe_Check($hash,$listname);
  253. if( !$pmn ){
  254. my $mga = "Error, a PostMe named $listname does not exist";
  255. Log 1,"[PostMe_Rename] $mga";
  256. return "$mga";
  257. }
  258. my $pnn=PostMe_Check($hash,$newname);
  259. if( $pnn ){
  260. my $mga = "Error, a PostMe named $newname does already exist and is not empty";
  261. Log 1,"[PostMe_Rename] $mga";
  262. return "$mga";
  263. }
  264. readingsSingleUpdate($hash,sprintf("postme%02dName",$pmn),$newname,1);
  265. Log3 $devname,3,"[PostMe] Renamed PostMe named $listname into $newname";
  266. return undef;
  267. }
  268. #########################################################################################
  269. #
  270. # PostMe_Add - Add something to a PostMe
  271. #
  272. # Parameter hash = hash of device addressed
  273. #
  274. #########################################################################################
  275. sub PostMe_Add($$@) {
  276. my ($hash,$listname,@args) = @_;
  277. my $devname = $hash->{NAME};
  278. my $pmn=PostMe_Check($hash,$listname);
  279. if( !$pmn ){
  280. my $mga = "Error, a PostMe named $listname does not exist";
  281. Log 1,"[PostMe_Add] $mga";
  282. return "$mga";
  283. }
  284. my $raw = join(' ',@args);
  285. #-- remove meta data
  286. my $item = $raw;
  287. $item =~ s/\[.*\]//g;
  288. $item =~ s/\]//g;
  289. $item =~ s/\[//g;
  290. #-- safety catch: No action when item empty
  291. if( $item eq "" ){
  292. my $mga = "Error, empty item given";
  293. Log 1,"[PostMe_Add] $mga";
  294. return "$mga";
  295. }
  296. #-- check old content
  297. my $old = ReadingsVal($devname, sprintf("postme%02dCont",$pmn),"");
  298. my $ind = index($old,$item);
  299. if( $ind >= 0 ){
  300. my $mga = "Error, item $item is already present in PostMe $listname";
  301. Log 1,"[PostMe_Add] $mga";
  302. return "$mga";
  303. }
  304. $old .= AttrVal($devname,"listseparator",',')
  305. if($old ne "");
  306. #-- TODO: META DATA MISSING
  307. readingsSingleUpdate($hash, sprintf("postme%02dCont",$pmn),$old.$item,1);
  308. Log3 $devname,3,"[Postme] Added item $item to PostMe named $listname";
  309. return undef;
  310. }
  311. #########################################################################################
  312. #
  313. # PostMe_Remove - Remove something from a PostMe
  314. #
  315. # Parameter hash = hash of device addressed
  316. #
  317. #########################################################################################
  318. sub PostMe_Remove($$@) {
  319. my ($hash,$listname,@args) = @_;
  320. my $devname = $hash->{NAME};
  321. my $pmn=PostMe_Check($hash,$listname);
  322. if( !$pmn ){
  323. my $mga = "Error, a PostMe named $listname does not exist";
  324. Log 1,"[PostMe_Remove] $mga";
  325. return "$mga";
  326. }
  327. my $raw = join(' ',@args);
  328. my $listsep = AttrVal($devname,"listseparator",',');
  329. #-- remove meta data
  330. my $item = $raw;
  331. $item =~ s/\[.*\]//g;
  332. #-- safety catch: No action when item empty
  333. if( $item eq "" ){
  334. my $mga = "Error, empty item given";
  335. Log 1,"[PostMe_Remove] $mga";
  336. return "$mga";
  337. }
  338. #-- get old content
  339. my $new = "";
  340. my $old = ReadingsVal($devname, sprintf("postme%02dCont",$pmn),"");
  341. my @lines= split($listsep,$old);
  342. #-- item may be of type item\d\d
  343. if( $item =~ /item(\d+)/ ){
  344. $item = $lines[$1];
  345. }
  346. #-- check old content
  347. my $ind = index($old,$item);
  348. if( $ind < 0 ){
  349. my $mga = "Error, item $item is not present in PostMe $listname";
  350. Log 1,"[PostMe_Remove] $mga";
  351. return "$mga";
  352. }
  353. #-- item may be a short version of the real entry
  354. for( my $loop=0;$loop<int(@lines);$loop++){
  355. $ind = index($lines[$loop],$item);
  356. #-- cleanup reminders
  357. if( $ind >= 0 ){
  358. my $line = $lines[$loop];
  359. my $itex = $line;
  360. my $meta = $line;
  361. $itex =~ s/\s*\[.*//;
  362. #-- only if attributes present
  363. if( $line =~ /.*\[.*\].*/){
  364. $meta =~ s/.*\[//;
  365. $meta =~ s/\]//;
  366. my @lines2 = split('" ',$meta);
  367. for( my $loop2=0;$loop2<int(@lines2);$loop2++){
  368. my $attr = $lines2[$loop2];
  369. $attr =~ /(.*)="(.*)/;
  370. $attr = $1;
  371. my $val = $2;
  372. PostMe_cleanSpecial($hash,$listname,$itex,$attr);
  373. }
  374. }
  375. #-- different item
  376. }else{
  377. $new .= $lines[$loop].$listsep;
  378. }
  379. }
  380. $new =~ s/$listsep$listsep/$listsep/;
  381. $new =~ s/^$listsep//;
  382. $new =~ s/$listsep$//;
  383. readingsSingleUpdate($hash, sprintf("postme%02dCont",$pmn),$new,1);
  384. Log3 $devname,3,"[Postme] Removed item $item from PostMe named $listname";
  385. return undef;
  386. }
  387. #########################################################################################
  388. #
  389. # PostMe_Clear - clear a PostMe
  390. #
  391. # Parameter hash = hash of device addressed
  392. # name = name of PostMe
  393. #
  394. #########################################################################################
  395. sub PostMe_Clear($$) {
  396. my ($hash,$listname) = @_;
  397. my $devname = $hash->{NAME};
  398. my $pmn=PostMe_Check($hash,$listname);
  399. if( !$pmn ){
  400. my $mga = "Error, a PostMe named $listname does not exist";
  401. Log 1,"[PostMe_Clear] $mga";
  402. return "$mga";
  403. }
  404. PostMe_Special($hash,$listname,1);
  405. readingsSingleUpdate($hash, sprintf("postme%02dCont",$pmn),"",1 );
  406. Log3 $devname,3,"[PostMe_Clear] Cleared PostMe named $listname";
  407. return undef;
  408. }
  409. #########################################################################################
  410. #
  411. # PostMe_Modify - Annotate an item from a PostMe with meta data
  412. #
  413. # Parameter hash = hash of device addressed
  414. #
  415. #########################################################################################
  416. sub PostMe_Modify($$@) {
  417. my ($hash,$listname,@args) = @_;
  418. my $devname = $hash->{NAME};
  419. my $pmn=PostMe_Check($hash,$listname);
  420. if( !$pmn ){
  421. my $mga = "Error, a PostMe named $listname does not exist";
  422. Log 1,"[PostMe_Remove] $mga";
  423. return "$mga";
  424. }
  425. my $listsep = AttrVal($devname,"listseparator",',');
  426. #-- difficult to separate item from new meta data. For now, first term is the item,
  427. # second term is the attribute and remaining terms are the value
  428. my $item = $args[0];
  429. my $attr = $args[1];
  430. splice(@args,0,2);
  431. my $val = join(' ',@args);
  432. #-- safety catch: No action when item empty
  433. if( $item eq "" ){
  434. my $mga = "Error, empty item given";
  435. Log 1,"[PostMe_Modify] $mga";
  436. return "$mga";
  437. }
  438. #-- check old content
  439. my $old = ReadingsVal($devname, sprintf("postme%02dCont",$pmn),"");
  440. my $ind = index($old,$item);
  441. if( $ind < 0 ){
  442. my $mga = "Error, item $item is not present in PostMe $listname";
  443. Log 1,"[PostMe_Remove] $mga";
  444. return "$mga";
  445. }
  446. #-- item
  447. my @lines = split($listsep,$old);
  448. my $new = "";
  449. for( my $loop=0;$loop<int(@lines);$loop++){
  450. $old = $lines[$loop];
  451. $ind = index($old,$item);
  452. #-- different item
  453. if( $ind < 0 ){
  454. $new .= $old.$listsep;
  455. #-- correct item
  456. }elsif( $ind == 0 ){
  457. #-- item may be a short version of the real entry, or may consist of several words
  458. my $fullitem = $old;
  459. $fullitem =~ s/\s*\[.*//;
  460. $item = $fullitem
  461. if( $fullitem ne $item );
  462. $new .= $item.' [';
  463. #-- no attributes present so far
  464. if( ($old !~ /.*\[.*\].*/) && ($val) ){
  465. #PostMe_cleanSpecial($hash,$listname,$item,$attr);
  466. PostMe_procSpecial($hash,$listname,$item,$attr,$val);
  467. $new .= $attr.'="'.$val.'"';
  468. #-- attributes present already
  469. }else{
  470. $old =~ s/.*\[//;
  471. $old =~ s/\]//;
  472. #-- particular attribute not yet present
  473. if( index($old,$attr) < 0){
  474. if( $val ){
  475. #PostMe_cleanSpecial($hash,$listname,$item,$attr);
  476. PostMe_procSpecial($hash,$listname,$item,$attr,$val);
  477. $new .= $old.' '.$attr.'="'.$val.'"'
  478. }
  479. #-- particular attribute already present
  480. }else{
  481. my @lines2 = split('" ',$old);
  482. for( my $loop2=0;$loop2<int(@lines2);$loop2++){
  483. my $ind2 = index($lines2[$loop2],$attr);
  484. #-- different attribute
  485. if( $ind2 < 0){
  486. $new .= $lines2[$loop2].'" ';
  487. #-- correct attribute
  488. }else{
  489. #-- overwrite, if val ist given
  490. if( $val ){
  491. PostMe_cleanSpecial($hash,$listname,$item,$attr);
  492. PostMe_procSpecial($hash,$listname,$item,$attr,$val);
  493. $new .= $attr.'="'.$val.'" ';
  494. #-- remove, if no val is given
  495. }
  496. }
  497. }
  498. }
  499. }
  500. $new .= ']'.$listsep;
  501. }
  502. }
  503. #-- correction of sloppy formatting above
  504. $new =~ s/\s\[\]//g;
  505. $new =~ s/\s\]/\]/g;
  506. $new =~ s/\[\s/\[/g;
  507. $new =~ s/""/"/g;
  508. $new =~ s/$listsep$//g;
  509. readingsSingleUpdate($hash, sprintf("postme%02dCont",$pmn),$new,1);
  510. Log3 $devname,3,"[Postme] Modified item $item in PostMe named $listname";
  511. return undef;
  512. }
  513. ########################################################################################
  514. #
  515. # PostMe_Special - process all special annotations of a PostMe
  516. #
  517. # Parameter hash = hash of device addressed
  518. # listanem = name of the PostMe
  519. # clean = 0 normal processing, = 1 clean all reminders
  520. #
  521. #########################################################################################
  522. sub PostMe_Special($$$) {
  523. my ($hash,$listname,$clean) = @_;
  524. my $devname = $hash->{NAME};
  525. my $pmn=PostMe_Check($hash,$listname);
  526. if( !$pmn ){
  527. my $mga = "Error, a PostMe named $listname does not exist";
  528. Log 1,"[PostMe_Special] $mga";
  529. return "$mga";
  530. }
  531. my $listsep = AttrVal($devname,"listseparator",',');
  532. #-- check content
  533. my $cont = ReadingsVal($devname, sprintf("postme%02dCont",$pmn),"");
  534. #-- item
  535. my @lines = split($listsep,$cont);
  536. for( my $loop=0;$loop<int(@lines);$loop++){
  537. my $line = $lines[$loop];
  538. my $item = $line;
  539. my $meta = $line;
  540. $item =~ s/\s*\[.*//;
  541. #-- only if attributes present
  542. if( $line =~ /.*\[.*\].*/){
  543. $meta =~ s/.*\[//;
  544. $meta =~ s/\]//;
  545. my @lines2 = split('" ',$meta);
  546. for( my $loop2=0;$loop2<int(@lines2);$loop2++){
  547. my $attr = $lines2[$loop2];
  548. $attr =~ /(.*)="(.*)/;
  549. $attr = $1;
  550. my $val = $2;
  551. PostMe_cleanSpecial($hash,$listname,$item,$attr);
  552. PostMe_procSpecial($hash,$listname,$item,$attr,$val)
  553. if( $clean==0 );
  554. }
  555. }
  556. }
  557. }
  558. #########################################################################################
  559. #
  560. # PostMe_procSpecial - process special annotations
  561. # Parameter hash = hash of device addressed
  562. # name = name of the PostMe
  563. # item = item content
  564. # attr = attribute name
  565. # val = attribute value
  566. #
  567. #########################################################################################
  568. sub PostMe_procSpecial($$$$$){
  569. my($hash,$listname,$item,$attr,$val) =@_;
  570. my $devname=$hash->{NAME};
  571. #-- get the number of this list
  572. my $pmn = PostMe_Check($hash,$listname);
  573. if( !$pmn ){
  574. my $mga = "Error, a PostMe named $listname does not exist";
  575. Log 1,"[PostMe_procSpecial] $mga";
  576. return "$mga";
  577. }
  578. if( $attr eq "at" ){
  579. my ($timeraw,$year,$mon,$day,$hour,$min,$sec,$delta,$deltah,$deltam,$repeat);
  580. my ($secn,$minn,$hourn,$dayn,$monn,$yearn) = localtime(time);
  581. my $str = "{";
  582. if( $val =~ /((\d\d\:\d\d)|(\d\d\:\d\d\:\d\d)|(\d\d\d\d-\d\d-\d\dT\d\d\:\d\d\:\d\d))(\-(\d\d:\d\d)(P(\d+))?)/ ){
  583. $timeraw = $1;
  584. $delta = $6;
  585. $repeat = ($8)?$8:1;
  586. $timeraw =~ /((\d\d\d\d)-(\d\d)-(\d\d)T)?(\d\d)\:(\d\d)\:?(\d\d)?/;
  587. #($year,$mon,$day,$hour,$min,$sec) = ($2,$3-1,$4,$5,$6,$7);
  588. $year =($2)?$2 : $yearn+1900;
  589. $mon =($3)?$3-1: $monn;
  590. $mon = ( ($mon>=0)&&($mon<=11) )? $mon:0;
  591. $day =($4)?$4 : $dayn;
  592. $day = ( ($day>=1)&&($day<=31) )? $day:0;
  593. $hour =($5)?$5 : $hourn;
  594. $hour = ( ($hour>=0)&&($hour<=23) )? $hour:0;
  595. $min =($6)?$6 : $minn;
  596. $min = ( ($min>=0)&&($min<=59) )? $min:0;
  597. $sec =($7)?$7 : "00";
  598. $sec = ( ($sec>=0)&&($sec<=59) )? $sec:0;
  599. $delta =~ /(\d\d):(\d\d)/;
  600. ($deltah,$deltam)=($1,$2);
  601. my $deltas = min(3600*$deltah+60*$deltam,86400);
  602. $repeat = ( ($repeat>=0)&&($repeat<=10) )? $repeat:0;
  603. my $ftime = timelocal($sec,$min,$hour,$day,$mon,$year);
  604. my $ftimel= localtime($ftime);
  605. #-- determine send strings
  606. my $mrcpt = AttrVal($devname,sprintf("postme%02dMailRec",$pmn),undef);
  607. my $mfun = AttrVal($devname,"postmeMailFun",undef);
  608. if( $mrcpt && $mfun ){
  609. $str .= "$mfun('$mrcpt','$listname','$item => $ftimel');;";
  610. }
  611. my $trcpt = AttrVal($devname,sprintf("postme%02dMsgRec",$pmn),undef);
  612. my $tfun = AttrVal($devname,"postmeMsgFun",undef);
  613. if( $trcpt && $tfun ){
  614. $str .= "$tfun('$trcpt','$listname','$item => $ftimel');;";
  615. }
  616. $str .="}";
  617. #-- define name for timer
  618. my $safename = PostMe_safeItem($hash,$listname,$item,"at");
  619. fhem("define ".$safename."_00 at $ftime $str");
  620. fhem("attr ".$safename."_00 room hidden");
  621. if( $delta ){
  622. for(my $i=1;$i<=$repeat;$i++){
  623. my $stime = $ftime-$i*$deltas;
  624. my $sname = $safename.sprintf("_%02d",$i);
  625. fhem("define ".$sname." at $stime $str");
  626. fhem("attr ".$sname." room hidden");
  627. }
  628. }
  629. }
  630. }elsif( $attr eq "notify" ){
  631. return
  632. if( !$val);
  633. my $str = "{";
  634. #-- determine send strings
  635. my $mrcpt = AttrVal($devname,sprintf("postme%02dMailRec",$pmn),undef);
  636. my $mfun = AttrVal($devname,"postmeMailFun",undef);
  637. if( $mrcpt && $mfun ){
  638. $str .= "$mfun('$mrcpt','$listname','$item');;";
  639. }
  640. my $trcpt = AttrVal($devname,sprintf("postme%02dMsgRec",$pmn),undef);
  641. my $tfun = AttrVal($devname,"postmeMsgFun",undef);
  642. if( $trcpt && $tfun ){
  643. $str .= "$tfun('$trcpt','$listname','$item');;";
  644. }
  645. $str .="}";
  646. #-- define name for notify
  647. my $safename = PostMe_safeItem($hash,$listname,$item,"notify");
  648. fhem("define ".$safename." notify $val $str");
  649. fhem("attr ".$safename." room hidden");
  650. }
  651. }
  652. #########################################################################################
  653. #
  654. # PostMe_cleanSpecial - process special annotations by cleaning leftover procedures
  655. # Parameter hash = hash of device addressed
  656. # name = name of the PostMe
  657. # item = item content
  658. # attr = attribute name
  659. #
  660. #########################################################################################
  661. sub PostMe_cleanSpecial($$$$){
  662. my($hash,$listname,$item,$attr) =@_;
  663. my $devname=$hash->{NAME};
  664. if( $attr eq "at" ){
  665. #-- define name for timer
  666. my $safename = PostMe_safeItem($hash,$listname,$item,"at");
  667. fhem("delete ".$safename.".*");
  668. }elsif( $attr eq "notify" ){
  669. #-- define name for notify
  670. my $safename = PostMe_safeItem($hash,$listname,$item,"notify");
  671. fhem("delete ".$safename.".*");
  672. }
  673. }
  674. #########################################################################################
  675. #
  676. # PostMe_safeItem - transform an item content into a FHEM name
  677. # Parameter hash = hash of device addressed
  678. # name = name of the PostMe
  679. # item = item content
  680. # attr = attribute name
  681. #
  682. #########################################################################################
  683. sub PostMe_safeItem($$$$){
  684. my($hash,$listname,$item,$attr) =@_;
  685. my $devname=$hash->{NAME};
  686. my $safeitem=join('_',split(' ',$item));
  687. $safeitem = substr($safeitem,0,4);
  688. $safeitem =~ tr/äöüÄÖÜß'/a_o_u_A_O_U_S__/;
  689. my $safelist=join('_',split(' ',$listname));
  690. $safelist = substr($safelist,0,4);
  691. $safelist =~ tr/äöüÄÖÜß'/a_o_u_A_O_U_S__/;
  692. my $safeattr = substr($attr,0,2);
  693. return $devname."rem_".$safelist."_".$safeitem."_".$safeattr;
  694. }
  695. #########################################################################################
  696. #
  697. # PostMe_LineIn - format a single PostMe line from input
  698. #
  699. # Parameter hash = hash of device addressed
  700. # line = raw data in the form item [att1="val1" att2="val2"]
  701. #
  702. #########################################################################################
  703. sub PostMe_LineIn($$) {
  704. my ($hash,$line) = @_;
  705. my $devname = $hash->{NAME};
  706. }
  707. #########################################################################################
  708. #
  709. # PostMe_LineOut - format a single PostMe line for output
  710. #
  711. # Parameter line = raw data in the form item [att1="val1" att2="val2"]
  712. # (multiple items separated by comma)
  713. # format = 0 - item only
  714. #
  715. #########################################################################################
  716. sub PostMe_LineOut($$$$) {
  717. my ($hash,$listname,$line,$format) = @_;
  718. my $devname = $hash->{NAME};
  719. my ($i,$line2,$item,$meat,$new,@lines,%meta);
  720. #Log 1,"LINEOUT format = $format, line=$line";
  721. #-- format == 0 - single item line
  722. if( $format < 10){
  723. $item = $line;
  724. $item =~ s/\s+\[.*//;
  725. $line =~ s/.*\[//;
  726. $line =~ s/\]//;
  727. my @list1 = split(/ /,$line);
  728. foreach my $item2(@list1) {
  729. my ($i,$j)= split(/=/, $item2);
  730. $meta{$i} = $j;
  731. }
  732. #Log 1,"line=$line, item=$item";
  733. return $item;
  734. #-- formats >= 10 for all items in a PostMe
  735. }elsif( $format >= 10){
  736. my $listsep = AttrVal($devname,"listseparator",',');
  737. my @lines = split($listsep,$line);
  738. #-- format 13, return array
  739. return \@lines
  740. if( $format==14 );
  741. my $new = "";
  742. my $item;
  743. my $meat;
  744. for( my $loop=0;$loop<int(@lines);$loop++){
  745. $line2 = $lines[$loop];
  746. $i = index($line2,'[');
  747. if( $i >=0 ){
  748. $item = substr($line2,0,$i);
  749. $meat = substr($line2,$i);
  750. $item =~ s/\s*$//;
  751. $meat =~ s/.*\[//;
  752. $meat =~ s/\]//;
  753. my @list1 = split('" ',$meat);
  754. foreach my $item2(@list1) {
  755. my ($i,$j)= split(/=/, $item2);
  756. $j =~ s/^"//;
  757. $meta{$i} = $j;
  758. #Log 1,"Setting META $i to VALUE $j";
  759. }
  760. }else{
  761. $item = $line2;
  762. $meat = "";
  763. $item =~ s/\s*$//;
  764. }
  765. #-- format 10: plain format, item only
  766. $new .= $item.','
  767. if( $format == 10);
  768. #-- format 11: meta data in brackets
  769. if( $format == 11){
  770. if( $meat ne "" ){
  771. $new .= $item.'('.$meat.'),';
  772. }else{
  773. $new .= $item.',';
  774. }
  775. }
  776. #-- format 13: Telegram format item w indexing
  777. $new .= '('.$item.sprintf(':%sitem%02d) ',$listname,$loop)
  778. if( $format == 13);
  779. #-- json format by hand
  780. if( $format == 15 ){
  781. $new .= '{"item": "'.$item.'"';
  782. if( $meat ne "" ){
  783. $new .= ',"meta": {';
  784. foreach my $k (keys %meta){
  785. $new .= '"'.$k.'": "'.$meta{$k}.'",';
  786. }
  787. $new .= '}';
  788. }
  789. $new .= '},';
  790. }
  791. }
  792. $new =~ s/""/"/g;
  793. $new =~ s/,}/}/g;
  794. $new =~ s/,$//;
  795. return $new;
  796. }
  797. }
  798. #########################################################################################
  799. #
  800. # PostMe_tgi - format a single PostMe as inline keyboard for telegram (items w. indexing)
  801. #
  802. # Parameter devname = device name
  803. # listname = list name
  804. #
  805. #########################################################################################
  806. sub PostMe_tgi($$) {
  807. my ($devname,$listname) = @_;
  808. my $pmn;
  809. my $res = "";
  810. my $hash = $defs{$devname};
  811. if( !$hash ){
  812. my $mga = "Error, a PostMe device named $devname does not exist";
  813. Log 1,"[PostMe_tgi] $mga";
  814. return "$mga";
  815. }
  816. #Log 1,"[PostMe_Get] with name=$listname key=$key args=@args";
  817. $pmn = PostMe_Check($hash,$listname);
  818. if( !$pmn ){
  819. my $mga = "Error, a PostMe named $listname does not exist";
  820. Log 1,"[PostMe_tgi] $mga";
  821. return "$mga";
  822. }
  823. $res = PostMe_LineOut($hash,$listname,ReadingsVal($devname, sprintf("postme%02dCont",$pmn),""),13);
  824. $res.= " ".$listname;
  825. return $res;
  826. }
  827. #########################################################################################
  828. #
  829. # PostMe_tgj - format a single PostMe as simple array
  830. #
  831. # Parameter devname = device name
  832. # listname = list name
  833. #
  834. ###########################################################################k##############
  835. sub PostMe_tgj($$) {
  836. my ($devname,$listname) = @_;
  837. my $pmn;
  838. my $hash = $defs{$devname};
  839. if( !$hash ){
  840. my $mga = "Error, a PostMe device named $devname does not exist";
  841. Log 1,"[PostMe_tgk] $mga";
  842. return "$mga";
  843. }
  844. #Log 1,"[PostMe_Get] with name=$listname key=$key args=@args";
  845. $pmn = PostMe_Check($hash,$listname);
  846. if( !$pmn ){
  847. my $mga = "Error, a PostMe named $listname does not exist";
  848. Log 1,"[PostMe_tgk] $mga";
  849. return "$mga";
  850. }
  851. my @ret=PostMe_LineOut($hash,$listname,ReadingsVal($devname, sprintf("postme%02dCont",$pmn),""),14);
  852. return \@ret;
  853. }
  854. #########################################################################################
  855. #
  856. # PostMe_Set - Implements the Set function
  857. #
  858. # Parameter hash = hash of device addressed
  859. #
  860. #########################################################################################
  861. sub PostMe_Set($@) {
  862. my ( $hash, $devname, $key, @args ) = @_;
  863. #-- for the selector: which values are possible
  864. if ($key eq "?"){
  865. #--prevent any default set
  866. return undef;
  867. #-- obsolete
  868. my @cmds = ("create","delete","rename","add","modify","remove","clear");
  869. return "Unknown argument $key, choose one of " .join(" ",@cmds);
  870. }
  871. my $listname = shift @args;
  872. if( $key eq "create"){
  873. PostMe_Create($hash,$listname);
  874. }elsif( $key eq "delete"){
  875. PostMe_Delete($hash,$listname);
  876. }elsif( $key eq "rename"){
  877. PostMe_Rename($hash,$listname,@args[0]);
  878. }elsif( $key eq "add"){
  879. PostMe_Add($hash,$listname,@args);
  880. }elsif( $key eq "modify"){
  881. PostMe_Modify($hash,$listname,@args);
  882. }elsif( $key eq "remove"){
  883. PostMe_Remove($hash,$listname,@args);
  884. }elsif( $key eq "clear"){
  885. PostMe_Clear($hash,$listname);
  886. }
  887. }
  888. #########################################################################################
  889. #
  890. # PostMe_Get - Implements the Get function
  891. #
  892. # Parameter hash = hash of device addressed
  893. #
  894. #########################################################################################
  895. sub PostMe_Get($$$@) {
  896. my ($hash, $devname, $key, @args) = @_;
  897. my $pmn;
  898. my $res = "";
  899. my $hasMail = defined(AttrVal($devname,"postmeMailFun",undef)) ? 1 : 0;
  900. my $hasMsgr = defined(AttrVal($devname,"postmeMsgFun",undef)) ? 1 : 0;
  901. my $hasTTS = defined(AttrVal($devname,"postmeTTSFun",undef)) ? 1 : 0;
  902. #-- for the selector: which values are possible
  903. if ($key eq "?"){
  904. #-- prevent any default get
  905. return undef;
  906. #-- obsolete
  907. #-- current number of PostMes
  908. my $cnop = ReadingsVal($devname,"postmeCnt",0);
  909. my $pml = "";
  910. for( my $i=1;$i<=$cnop;$i++){
  911. $pml .= ","
  912. if( $i >1);
  913. $pml .= ReadingsVal($devname, sprintf("postme%02dName",$i),"");
  914. }
  915. my @cmds = ("version:noArg","all:noArg","allspecial","list:".$pml,"special:".$pml);
  916. $res = "Unknown argument $key choose one of ".join(" ",@cmds);
  917. $res.= " mail:".$pml
  918. if($hasMail);
  919. $res.= " message:".$pml
  920. if($hasMsgr);
  921. $res.= " TTS:".$pml
  922. if($hasTTS);
  923. $res.= " JSON:".$pml;
  924. return $res;
  925. }
  926. my $listname = @args[0];
  927. if ($key eq "version") {
  928. return "PostMe.version => $postmeversion";
  929. #-- list one PostMe
  930. } elsif( ($key eq "list")||($key eq "special")||($key eq "JSON")||($key eq "mail")||($key eq "message")||($key eq "TTS") ){
  931. $pmn = PostMe_Check($hash,$listname);
  932. if( !$pmn ){
  933. my $mga = "Error, a PostMe named $listname does not exist";
  934. Log 1,"[PostMe_Get] $mga";
  935. return "$mga";
  936. }
  937. ##-- list
  938. if( $key eq "list" ){
  939. $res = ReadingsVal($devname, sprintf("postme%02dName",$pmn),"");
  940. $res .= ": ";
  941. $res .= PostMe_LineOut($hash,$listname,ReadingsVal($devname, sprintf("postme%02dCont",$pmn),"")."\n",10);
  942. return $res;
  943. ##-- list
  944. }elsif( $key eq "special" ){
  945. PostMe_Special($hash,$listname,0);
  946. ##-- JSON
  947. }elsif( $key eq "JSON" ){
  948. $res = PostMe_LineOut($hash,$listname,ReadingsVal($devname, sprintf("postme%02dCont",$pmn),""),15);
  949. return '{"'.$listname.'": ['.$res.']}';
  950. ##-- send by mail
  951. }elsif( $key eq "mail" ){
  952. my $rcpt = AttrVal($devname,sprintf("postme%02dMailRec",$pmn),undef);
  953. my $text = PostMe_LineOut($hash,$listname,ReadingsVal($devname, sprintf("postme%02dCont",$pmn),undef),11);
  954. my $fun = AttrVal($devname,"postmeMailFun",undef);
  955. if( $rcpt && $text && $fun ){
  956. my $ref = \&$fun;
  957. &$ref($rcpt,$listname,$text);
  958. }
  959. my $mga = "$listname sent by mail";
  960. readingsSingleUpdate($hash,"state",$mga,1 );
  961. Log3 $devname,3,"[PostMe] ".$mga;
  962. return undef;
  963. ##-- send by instant messenger
  964. }elsif( $key eq "message" ){
  965. my $rcpt = AttrVal($devname,sprintf("postme%02dMsgRec",$pmn),undef);
  966. my $text = PostMe_LineOut($hash,$listname,ReadingsVal($devname, sprintf("postme%02dCont",$pmn),undef),11);
  967. $text =~ s/,/,\n/g;
  968. my $fun = AttrVal($devname,"postmeMsgFun",undef);
  969. if( $rcpt && $text && $fun ){
  970. my $ref = \&$fun;
  971. &$ref($rcpt,$listname,$text);
  972. }
  973. my $mga = "$listname sent by messenger";
  974. readingsSingleUpdate($hash,"state",$mga,1 );
  975. Log3 $devname,3,"[PostMe] ".$mga;
  976. return undef;
  977. ##-- speak as TTS
  978. }elsif( $key eq "TTS" ){
  979. my $dev = AttrVal($devname,"postmeTTSDev",undef);
  980. my $text = $listname.": ".PostMe_LineOut($hash,$listname,ReadingsVal($devname, sprintf("postme%02dCont",$pmn),undef),10);
  981. my $fun = AttrVal($devname,"postmeTTSFun",undef);
  982. if( $text && $fun ){
  983. my $ref = \&$fun;
  984. &$ref($dev,$text);
  985. }
  986. my $mga = "$listname spoken by TTS";
  987. readingsSingleUpdate($hash,"state",$mga,1 );
  988. Log3 $devname,3,"[PostMe] ".$mga;
  989. return undef;
  990. }
  991. #-- list all PostMe
  992. } elsif ($key eq "all") {
  993. #-- current number of PostMes
  994. my $cnop = ReadingsVal($devname,"postmeCnt",0);
  995. for( my $loop=1;$loop<=$cnop;$loop++){
  996. $res .= ReadingsVal($devname, sprintf("postme%02dName",$loop),"");
  997. $res .= ": ".PostMe_LineOut($hash,$listname,ReadingsVal($devname, sprintf("postme%02dCont",$loop),"")."\n",10);
  998. $res .= "\n";
  999. }
  1000. return $res;
  1001. #-- process all PostMe special annotations
  1002. } elsif ($key eq "allspecial") {
  1003. #-- current number of PostMes
  1004. my $cnop = ReadingsVal($devname,"postmeCnt",0);
  1005. for( my $loop=1;$loop<=$cnop;$loop++){
  1006. $listname = ReadingsVal($devname, sprintf("postme%02dName",$loop),"");
  1007. PostMe_Special($hash,$listname,0);
  1008. }
  1009. return $res;
  1010. }
  1011. }
  1012. #########################################################################################
  1013. #
  1014. # PostMe_detailFn - Displays PostMes in detailed view of FHEM
  1015. #
  1016. # Parameter = web argument list
  1017. #
  1018. #########################################################################################
  1019. sub PostMe_detailFn(){
  1020. my ($FW_wname, $devname, $room, $pageHash) = @_; # pageHash is set for summaryFn.
  1021. my $hash = $defs{$devname};
  1022. $hash->{mayBeVisible} = 1;
  1023. my $pmname=$hash->{NAME};
  1024. my $pmfirst = ReadingsVal($devname, "postme01Name","");
  1025. my $pmlist="";
  1026. my $pmoption="";
  1027. #-- current number of PostMes
  1028. my $cnop = ReadingsVal($devname,"postmeCnt",0);
  1029. for( my $loop=1;$loop<=$cnop;$loop++){
  1030. my $n = ReadingsVal($devname, sprintf("postme%02dName",$loop),"");
  1031. $pmlist .= $n;
  1032. $pmlist .= ","
  1033. if( $loop != $cnop);
  1034. if( $loop == 1){
  1035. $pmoption .= '<option selected="selected" value="'.$n.'">'.$n.'</option>';
  1036. }else{
  1037. $pmoption .= '<option value="'.$n.'">'.$n.'</option>';
  1038. }
  1039. }
  1040. my $icon = AttrVal($devname, "icon", "");
  1041. $icon = FW_makeImage($icon,$icon,"icon") . "&nbsp;" if($icon);
  1042. my $html = '<div id="ddtable" class="makeTable wide"><table class="block wide"><tr class="odd">'.
  1043. '<td width="300px"><div>'.$icon.'</div></td>'.
  1044. '<td informId="'.$pmname.'"><div id="'.$pmname.'" title="Initialized" class="col2">'.ReadingsVal($devname,"state","").'</div></td>'.
  1045. '</tr></table></div>';
  1046. $html .= '<script type="text/javascript">function oc(){var p1=document.getElementById("val1_set'.$pmname.'").value;var p2=document.getElementById("val2_set'.$pmname.'").value;'.
  1047. 'var p3;if(document.getElementById("sel_set'.$pmname.'").selectedIndex == 3) p3=p2; else p3=p1+" "+p2;document.getElementById("val_set'.$pmname.'").value=p3;}'.
  1048. 'function dc1(i){if(i == 3)document.getElementById("val1_set'.$pmname.'").style.visibility = "hidden";'.
  1049. 'else document.getElementById("val1_set'.$pmname.'").style.visibility = "visible";'.
  1050. 'if(i > 4)document.getElementById("val2_set'.$pmname.'").style.visibility = "hidden"; else document.getElementById("val2_set'.$pmname.'").style.visibility = "visible";}'.
  1051. 'function dc2(i){if(i > 4)document.getElementById("val_get'.$pmname.'").style.visibility = "hidden";'.
  1052. 'else document.getElementById("val_get'.$pmname.'").style.visibility = "visible";};</script>';
  1053. $html .= '<table><tr><td>'.
  1054. '<form method="post" action="/fhem" autocomplete="off"><input type="hidden" name="detail" value="'.$pmname.'"/><input type="hidden" name="dev.set'.$pmname.'" value="'.$pmname.'"/>'.
  1055. '<input type="submit" name="cmd.set'.$pmname.'" value="set" class="set"/><div class="set downText">&nbsp;'.$pmname.'&nbsp;</div>'.
  1056. '<select id="sel_set'.$pmname.'" informId="sel_set'.$pmname.'" name="arg.set'.$pmname.'" class="set" style="width:100px;" '.
  1057. 'onchange="dc1(this.selectedIndex)">'.
  1058. '<option selected="selected" value="add">add</option><option value="modify">modify</option><option value="remove">remove</option><option value="create">create</option>'.
  1059. '<option value="rename">rename</option><option value="clear">clear</option><option value="delete">delete</option>'.
  1060. '</select>'.
  1061. '<select id="val1_set'.$pmname.'" informId="val1_set'.$pmname.'" name="val1.set'.$pmname.'" class="set" onchange="oc()">'.$pmoption.'</select>'.
  1062. '<input type="text" id="val2_set'.$pmname.'" informId="val2_set'.$pmname.'" name="val2.set'.$pmname.'" class="set" size="30" value="" onchange="oc()"/>'.
  1063. '<input type="hidden" id="val_set'.$pmname.'" informId="val_set'.$pmname.'" name="val.set'.$pmname.'" class="set" size="30" value="'.$pmfirst.'"/></form></td></tr>';
  1064. $html .= '<tr><td>'.
  1065. '<form method="post" action="/fhem" autocomplete="off"><input type="hidden" name="detail" value="'.$pmname.'"/><input type="hidden" name="dev.get'.$pmname.'" value="'.$pmname.'"/>'.
  1066. '<input type="submit" name="cmd.get'.$pmname.'" value="get" class="get"/><div class="get downText">&nbsp;'.$pmname.'&nbsp;</div>'.
  1067. '<select id="sel_get'.$pmname.'" informId="sel_get'.$pmname.'" name="arg.get'.$pmname.'" class="get" style="width:100px;" '.
  1068. 'onchange="dc2(this.selectedIndex)">'.
  1069. '<option selected="selected" value="list">list</option><option value="special">special</option><option value="mail">mail</option><option value="message">message</option><option value="TTS">TTS</option>'.
  1070. '<option value="JSON">JSON</option><option value="all">all</option><option value="allspecial">allspecial</option><<option value="version">version</option>'.
  1071. '</select>'.
  1072. '<select type="hidden" id="val_get'.$pmname.'" informId="val_get'.$pmname.'" name="val.get'.$pmname.'" class="get">'.$pmoption.'</select>'.
  1073. '</form></td></tr></table>';
  1074. return $html;
  1075. }
  1076. #########################################################################################
  1077. #
  1078. # PostMe_widget - Displays PostMes as widgets
  1079. #
  1080. # Parameter = web argument list
  1081. #
  1082. #########################################################################################
  1083. sub PostMe_widget($) {
  1084. my ($arg) = @_;
  1085. my $type = $FW_webArgs{type};
  1086. $type = "show"
  1087. if( !$type);
  1088. my $devname = $FW_webArgs{postit};
  1089. my $listname = $FW_webArgs{name};
  1090. my $pmn;
  1091. my $res = "";
  1092. #-- device name
  1093. if( !$devname ){
  1094. Log 1,"[PostMe_widget] Error, web argument postit=... is missing";
  1095. return undef;
  1096. }
  1097. my $hash = $defs{$devname};
  1098. my $style = AttrVal($devname,"postmeStyle","jQuery");
  1099. my $icon = AttrVal($devname,"postmeIcon","images/default/pin_red_32.png");
  1100. my $click = AttrVal($devname,"postmeClick","0");
  1101. my $css = '<link href="www/pgm2/'.AttrVal($FW_wname, "stylesheetPrefix", "").'style.css" rel="stylesheet"/>';
  1102. ##################################################-- type=pins => list with pins
  1103. if( $type eq "pins"){
  1104. #-- current number of Postmes
  1105. my $cnop = ReadingsVal($devname,"postmeCnt",0);
  1106. #-- jQuery rendering
  1107. if( $style eq "jQuery" ){
  1108. $FW_RETTYPE = "text/html";
  1109. $FW_RET="";
  1110. $res .= $css;
  1111. #-- we need our own jQuery object
  1112. $res .= '<script type="text/javascript" src="/fhem/pgm2/jquery.min.js"></script>';
  1113. $res .= '<script type="text/javascript" src="/fhem/pgm2/jquery-ui.min.js"></script>';
  1114. #-- this is for the selector
  1115. $res .= '<div id="postme" class="postmeclass">';
  1116. for( my $loop=1;$loop<=$cnop;$loop++){
  1117. my $name2 = ReadingsVal($devname, sprintf("postme%02dName",$loop),"");
  1118. my $sel = sprintf("sel%02d",$loop);
  1119. $res .= '<div id="'.$sel.'"><img src="'.$icon.'"/>'.$name2.'</div><br/>';
  1120. };
  1121. $res .= '</div>';
  1122. #-- this is the scripting for the dialog box
  1123. $res .= '<script type="text/javascript">';
  1124. $res .= 'var $jParent = window.parent.jQuery;';
  1125. $res .= '$jParent( ".roomBlock1" ).prepend( "<div id=\'postmedia\' style=\'width:200px\'></div>" );';
  1126. $res .= 'var dlg1 = $jParent("#postmedia");';
  1127. $res .= 'dlg1 = dlg1.dialog({width:300,autoOpen:false';
  1128. $res .= ',open:function(event, ui){$(".ui-dialog-titlebar-close").hide();}';
  1129. #-- button only when needed
  1130. $res .= ',buttons:[{text: "OK",click:function(){dlg1.dialog("close");}}]'
  1131. if ($click == 1);
  1132. $res .= '});';
  1133. #-- this is the scripting for the connection selector-dialog
  1134. for( my $loop=1;$loop<=$cnop;$loop++){
  1135. my $name2 = ReadingsVal($devname, sprintf("postme%02dName",$loop),"");
  1136. my $sel = sprintf("sel%02d",$loop);
  1137. if( $click == 0){
  1138. $res .= '$("#'.$sel.'").mouseover(function(){dlg1.load("/fhem/PostMe_widget?postit='.$devname.'&name='.$name2.'",';
  1139. $res .= 'function(){dlg1.dialog("open")})});';
  1140. $res .= '$("#'.$sel.'").mouseout(function(){dlg1.dialog("close")});';
  1141. }else{
  1142. $res .= '$("#'.$sel.'").click(function(){dlg1.load("/fhem/PostMe_widget?postit='.$devname.'&name='.$name2.'",';
  1143. $res .= 'function(){dlg1.dialog("open")})});';
  1144. }
  1145. }
  1146. $res .= '</script>';
  1147. FW_pO $res;
  1148. #-- HTML rendering
  1149. }elsif( $style eq "HTML"){
  1150. $FW_RETTYPE = "text/html; charset=$FW_encoding";
  1151. $FW_RET="";
  1152. $res .= $css;
  1153. $res .= '<div class="postmeclass">';
  1154. for( my $loop=1;$loop<=$cnop;$loop++){
  1155. my $name2 = ReadingsVal($devname, sprintf("postme%02dName",$loop),"");
  1156. if( $click == 0){
  1157. $res .= '<div onmouseover="postit=window.open(\'PostMe_widget?postit='.$devname.'&amp;name='.$name2.'\',\'postit\',\'height=200,width=200,top=400,left=400,menubar=no,toolbar=no,titlebar=no\');" ';
  1158. $res .= 'onmouseout="postit.close()"><img src="'.$icon.'"/>'.$name2.'</div><br/>';
  1159. }else{
  1160. $res .= '<div onclick="postit=window.open(\'PostMe_widget?postit='.$devname.'&amp;name='.$name2.'\',\'postit\',\'height=200,width=200,top=400,left=400,menubar=no,toolbar=no,titlebar=no\');">';
  1161. $res .= '<img src="'.$icon.'"/>'.$name2.'</div><br/>';
  1162. }
  1163. }
  1164. FW_pO $res.'</div>';
  1165. #-- SVG rendering
  1166. }else{
  1167. $FW_RETTYPE = "image/svg+xml";
  1168. $FW_RET="";
  1169. FW_pO '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100px" height="100px">';
  1170. for( my $loop=1;$loop<=$cnop;$loop++){
  1171. my $name2 = ReadingsVal($devname, sprintf("postme%02dName",$loop),"");
  1172. $res.= sprintf('<text x="10" y="%02d" fill="blue" style="font-family:Helvetica;font-size:12px;font-weight:bold" ',10+15*$loop);
  1173. $res.= 'onmouseover="postit=window.open(\'PostMe_widget?postit='.$devname.'&amp;name='.$name2.'\',\'postit\',\'height=200,width=200,top=400,left=400,menubar=no,toolbar=no,titlebar=no\');" ';
  1174. $res.= 'onmouseout="postit.close()">'.$name2.'</text>';
  1175. $res.= <g>
  1176. }
  1177. FW_pO $res.'</svg>';
  1178. }
  1179. return ($FW_RETTYPE, $FW_RET);
  1180. }
  1181. #-- PostMe name
  1182. if( !$listname ){
  1183. Log 1,"[PostMe_widget] Error, web argument name=... is missing";
  1184. return undef;
  1185. }
  1186. $pmn = PostMe_Check($hash,$listname);
  1187. if( !$pmn ){
  1188. Log 1,"[PostMe_widget] Error, a PostMe named $listname does not exist";
  1189. return undef;
  1190. }
  1191. ##################################################-- type=pin => single pin
  1192. if( $type eq "pin"){
  1193. #-- jQuery rendering
  1194. if( $style eq "jQuery"){
  1195. my $sel = sprintf("sel%02d",$pmn);
  1196. $FW_RETTYPE = "text/html";
  1197. $FW_RET="";
  1198. $res .= $css;
  1199. #-- we need our own jQuery object
  1200. $res .= '<script type="text/javascript" src="/fhem/pgm2/jquery.min.js"></script>';
  1201. $res .= '<script type="text/javascript" src="/fhem/pgm2/jquery-ui.min.js"></script>';
  1202. #-- this is for the selector
  1203. $res .= '<div id="postme" class="postmeclass">';
  1204. $res .= '<div id="'.$sel.'"><img src="'.$icon.'"/>'.$listname.'</div><br/>';
  1205. $res .= '</div>';
  1206. #-- this is the scripting for the dialog box
  1207. $res .= '<script type="text/javascript">';
  1208. $res .= 'var $jParent = window.parent.jQuery;';
  1209. $res .= '$jParent( ".roomBlock1" ).prepend( "<div id=\'postmedia\' style=\'width:200px\'></div>" );';
  1210. $res .= 'var dlg1 = $jParent("#postmedia");';
  1211. $res .= 'dlg1 = dlg1.dialog({width:300,autoOpen:false';
  1212. $res .= ',open:function(event, ui){$(".ui-dialog-titlebar-close").hide();}';
  1213. #-- button only when needed
  1214. $res .= ',buttons:[{text: "OK",click:function(){dlg1.dialog("close");}}]'
  1215. if ($click == 1);
  1216. $res .= '});';
  1217. #-- this is the scripting for the connection selector-dialog
  1218. if( $click == 0){
  1219. $res .= '$("#'.$sel.'").mouseover(function(){dlg1.load("/fhem/PostMe_widget?postit='.$devname.'&name='.$listname.'",';
  1220. $res .= 'function(){dlg1.dialog("open")})});';
  1221. $res .= '$("#'.$sel.'").mouseout(function(){dlg1.dialog("close")});';
  1222. }else{
  1223. $res .= '$("#'.$sel.'").click(function(){dlg1.load("/fhem/PostMe_widget?postit='.$devname.'&name='.$listname.'",';
  1224. $res .= 'function(){dlg1.dialog("open")})});';
  1225. }
  1226. $res .= '</script>';
  1227. FW_pO $res;
  1228. #-- HTML rendering
  1229. }elsif( $style eq "HTML"){
  1230. $FW_RETTYPE = "text/html";
  1231. $FW_RET="";
  1232. $res .= $css;
  1233. $res .= '<div class="postmeclass">';
  1234. if( $click == 0){
  1235. $res.= '<div onmouseover="postit=window.open(\'PostMe_widget?postit='.$devname.'&amp;name='.$listname.'\',\'postit\',\'height=200,width=200,top=400,left=400,menubar=no,toolbar=no,titlebar=no\');" ';
  1236. $res.= 'onmouseout="postit.close()">';
  1237. }else{
  1238. $res.= '<div onclick="postit=window.open(\'PostMe_widget?postit='.$devname.'&amp;name='.$listname.'\',\'postit\',\'height=200,width=200,top=400,left=400,menubar=no,toolbar=no,titlebar=no\');">';
  1239. }
  1240. FW_pO $res.'<img src="'.$icon.'"/>'.$listname.'</div>';
  1241. #-- SVG rendering
  1242. }else{
  1243. $FW_RETTYPE = "image/svg+xml";
  1244. $FW_RET="";
  1245. FW_pO '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100px" height="100px">';
  1246. $res.= '<text x="10" y="10" fill="blue" style="font-family:Helvetica;font-size:12px;font-weight:bold" ';
  1247. $res.= 'onmouseover="postit=window.open(\'PostMe_widget?postit='.$devname.'&amp;name='.$listname.'\',\'postit\',\'height=200,width=200,top=400,left=400,menubar=no,toolbar=no,titlebar=no\');" ';
  1248. $res.= 'onmouseout="postit.close()">'.$listname.'</text>';
  1249. FW_pO $res.'</svg>';
  1250. }
  1251. return ($FW_RETTYPE, $FW_RET);
  1252. }
  1253. ################################################## default (type missing) => content of a single postme
  1254. my @lines=split(AttrVal($devname,"listseparator",','),ReadingsVal($devname, sprintf("postme%02dCont",$pmn),""));
  1255. if( !(int(@lines)>0) ){
  1256. #Log 1,"[PostMe_widget] Asking to display empty PostMe $listname";
  1257. return undef;
  1258. }
  1259. #-- HTML rendering
  1260. if( $style ne "SVG"){
  1261. $FW_RETTYPE = "text/html; charset=$FW_encoding";
  1262. $FW_RET="";
  1263. $res .= $css;
  1264. $res .= '<div class="postmeclass2" style="width:200px">';
  1265. $res .= '<b>'.$listname.'</b><br/>';
  1266. for (my $i=0;$i<int(@lines);$i++){
  1267. #--special for meta data
  1268. my $line=PostMe_LineOut($hash,$listname,$lines[$i],0);
  1269. $res.= $line.'<br/>';
  1270. }
  1271. FW_pO $res.'</div>';
  1272. #--- SVG rendering
  1273. }else{
  1274. $FW_RETTYPE = "image/svg+xml";
  1275. $FW_RET="";
  1276. FW_pO '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100px" height="100px">';
  1277. $res = '<text x="10" y="10" fill="blue" style="font-family:Helvetica;font-size:12px;font-weight:bold">';
  1278. $res.= $listname.'</text>';
  1279. for (my $i=0;$i<int(@lines);$i++){
  1280. $res.= sprintf('<text x="10" y="%02d" fill="blue" style="font-family:Helvetica;font-size:10px">',25+$i*12);
  1281. $res.= PostMe_LineOut($hash,$listname,$lines[$i],0);
  1282. $res.= '</text>';
  1283. }
  1284. FW_pO $res.'</svg>';
  1285. }
  1286. return ($FW_RETTYPE, $FW_RET);
  1287. }
  1288. 1;
  1289. =pod
  1290. =item helper
  1291. =item summary to set up a system of sticky notes, similar to Post-Its&trade;
  1292. =begin html
  1293. <a name="PostMe"></a>
  1294. <h3>PostMe</h3>
  1295. <p> FHEM module to set up a system of sticky notes, similar to Post-Its&trade;</p>
  1296. <a name="PostMedefine"></a>
  1297. <h4>Define</h4>
  1298. <p>
  1299. <code>define &lt;postit&gt; PostMe</code>
  1300. <br />Defines the PostMe system, &lt;postit&gt; is an arbitrary name for the system. </p>
  1301. <a name="PostMeusage"></a>
  1302. <h4>Usage</h4>
  1303. See <a href="http://www.fhemwiki.de/wiki/Modul_PostMe">German Wiki page</a>
  1304. <br/>
  1305. An arbitrary number of lists may be added to the system with the <i>create</i> command.<br/>
  1306. List items may consist of one or more words, and are added/removed by the <i>add</i> and
  1307. <i>remove</i> command, but no separator characters are allowed in one item<br/>
  1308. Attention: A comma "," is the <i>default</i> separator for list items, see attributes below.</br/>
  1309. <p/>
  1310. Meta data for items (=annotations)may be included in the items by using "[" and "]"; characters, e.g.<br/>
  1311. <code>set &lt;postit&gt; add &lt;name&gt; &lt;item&gt; [&lt;attribute1&gt;="&lt;data1&gt;" ...</code><br/>
  1312. These attribute-value pairs may be added, modified and removed with the <i>modify</i> command.
  1313. <p/>
  1314. <b>Special annotations</b> will be evaluated further, either on creation or manually by executing the commands<br/>
  1315. <code>get &lt;postit&gt; special &lt;name&gt;</code> resp. <code>get &lt;postit&gt; allspecial</code>
  1316. <ul>
  1317. <li>The attribute <i>at="&lt;timespec/datespec&gt;"</i>, when given a timespec/datespec value, will result in a single or multiple
  1318. reminding messages for this item. The syntax for this timespec/datespec value is<br/>
  1319. <code>(&lt;HH:MM&gt;|&lt;HH:MM:SS&gt;|&lt;YYYY-MM-DD&gt;T&lt;HH:MM:SS&gt;)[-&lt;HH:MM&gt;[P&lt;number&gt;]]</code>
  1320. <br/>
  1321. The first part is the time/date specification when the item is <i>due</i>.
  1322. <br/>The second optional part beginning with a "-"-sign
  1323. denotes how much time befor this date you want to be alerted.
  1324. <br/>The third optional part beginning with a "P" character
  1325. allows to specify a &lt;number&gt; of periodic reminders, the period given by the second part.<br/>
  1326. Processing this attribute means, that several <i>at</i> devices will be set up in the room <i>hidden</i>
  1327. that are triggered when at the specified times.
  1328. See documentation in Wiki for examples.
  1329. </li>
  1330. <li>The attribute <i>notify="&lt;eventspec&gt;"</i>, when given an eventspec value, will result in a single or multiple
  1331. reminding messages for this item.<br/>
  1332. Processing this attribute means, that a <i>notify</i> device will be set up in the room <i>hidden</i>
  1333. that is triggered when the event is detected.</li>
  1334. </ul>
  1335. The sticky notes may be integrated into any Web page by simply embedding the following tags
  1336. <ul>
  1337. <li> <code>&lt;embed src="/fhem/PostMe_widget?type=pins&amp;postit=&lt;postit&gt;"/&gt;</code> <br/>
  1338. to produce an interactive list of all PostMe names with pins from system &lt;postit&gt;.</li>
  1339. <li> <code>&lt;embed src="/fhem/PostMe_widget?type=pin&amp;postit=&lt;postit&gt;&amp;name=&lt;name&gt;"/&gt;</code> <br/>
  1340. to produce an interactive entry for PostMe &lt;name&gt;from system &lt;postit&gt;</li>
  1341. </ul>
  1342. <br/>
  1343. The module provides interface routines that may be called from your own Perl programs, see documentation in the Wiki.
  1344. <br/>
  1345. <a name="PostMeset"></a>
  1346. <h4>Set</h4>
  1347. <ul>
  1348. <li><code>set &lt;postit&gt; create &lt;name&gt;</code>
  1349. <br />creates a sticky note named &lt;name&gt;</li>
  1350. <li><code>set &lt;postit&gt; rename &lt;name&gt; &lt;newname&gt;</code>
  1351. <br />renames the sticky note named &lt;name&gt; as &lt;newname&gt;</li>
  1352. <li><code>set &lt;postit&gt; delete &lt;name&gt;</code>
  1353. <br />deletes the sticky note named &lt;name&gt;</li>
  1354. <li><code>set &lt;postit&gt; add &lt;name&gt; &lt;item&gt;</code>
  1355. <br />adds to the sticky note named &lt;name&gt; an item &lt;item&gt;</li>
  1356. <li><code>set &lt;postit&gt; modify &lt;name&gt; &lt;item&gt; &lt;attribute&gt; &lt;data&gt;</code>
  1357. <br />adds/modifies/removes and attribute-value-pair &lt;attribute&gt;="&lt;data&gt;" to the item &lt;item&gt; on the sticky note named &lt;name&gt;<br/>
  1358. adding, if this attribute is not yet present; modification, if it is present - &lt;data&gt; will then be overwritten; removal, if no &lt;data&gt; is given</li>
  1359. <li><code>set &lt;postit&gt; remove &lt;name&gt; &lt;item&gt;</code><br />
  1360. <code>set &lt;postit&gt; remove &lt;name&gt; item&lt;number&gt;</code>
  1361. <br />removes from the sticky note named &lt;name&gt; an item &lt;item&gt; or the one numbered &lt;number&gt; (starting at 0)</li>
  1362. <li><code>set &lt;postit&gt; clear &lt;name&gt;</code>
  1363. <br />clears the sticky note named &lt;name&gt; from all items </li>
  1364. </ul>
  1365. <a name="PostMeget"></a>
  1366. <h4>Get</h4>
  1367. <ul>
  1368. <li><code>get &lt;postit&gt; list &lt;name&gt;</code>
  1369. <br />Show the sticky note named &lt;name&gt; and its content</li>
  1370. <li><code>get &lt;postit&gt; special &lt;name&gt;</code>
  1371. <br />Process the special annotations (see above) of the sticky note named &lt;name&gt;</li>
  1372. <li><code>get &lt;postit&gt; mail &lt;name&gt;</code>
  1373. <br />Send the sticky note named &lt;name&gt; and its content via eMail to a predefined
  1374. recipient (e.g. sticky note &lt;postme01Name&gt; is sent to &lt;postme01MailRec&gt;).<br/> The mailing
  1375. subroutine <postmeMsgFun> is called with three parameters for recipient, subject
  1376. and text. </li>
  1377. <li><code>get &lt;postit&gt; message &lt;name&gt;</code>
  1378. <br />Send the sticky note named &lt;name&gt; and its content via instant messenger to a predefined
  1379. recipient (e.g. sticky note &lt;postme01Name&gt; is sent to &lt;postme01MsgRec&gt;).<br/> The messenger
  1380. subroutine <postmeMsgFun> is called with three parameters for recipient, subject
  1381. and text. </li>
  1382. <li><code>get &lt;postit&gt; TTS &lt;name&gt;</code>
  1383. <br />Speak the sticky note named &lt;name&gt; and its content. The TTS
  1384. subroutine <postmeTTSFun> is called with one parameter text. </li>
  1385. <li><code>get &lt;postit&gt; JSON &lt;name&gt;</code>
  1386. <br />Return the sticky note named &lt;name&gt; in JSON format</li>
  1387. <li><code>get &lt;postit&gt; all</code>
  1388. <br />Show all sticky notes and their content</li>
  1389. <li><code>get &lt;postit&gt; allspecial</code>
  1390. <br />Process the special annotations (see above) of all sticky notes</li>
  1391. <li><code>get &lt;postit&gt; version</code>
  1392. <br />Display the version of the module</li>
  1393. </ul>
  1394. <a name="PostMeattr"></a>
  1395. <h4>Attributes</h4>
  1396. <ul>
  1397. <li><code>attr &lt;postit&gt; postmeStd &lt;name1,name2,...&gt;</code>
  1398. <br />Comma separated list of standard sticky notes that will be created on device start.</li>
  1399. <li><code>attr &lt;postit&gt; postmeClick 1|0 (default)</code>
  1400. <br />If 0, embedded sticky notes will pop up on mouseover-events and vanish on mouseout-events (default).<br/>
  1401. If 1, embedded sticky notes will pop up on click events and vanish after closing the note</li>
  1402. <li><code>attr &lt;postit&gt; postmeIcon &lt;string&gt;</code>
  1403. <br />Icon for display of a sticky note</li>
  1404. <li><code>attr &lt;postit&gt; postmeStyle SVG|HTML|jQuery (default)</code>
  1405. <br />If jQuery, embedded sticky notes will produce jQuery code (default) <br/>
  1406. If HTML, embedded sticky notes will produce HTML code <br/>
  1407. If SVG, embedded sticky notes will produce SVG code</li>
  1408. <li><code>attr &lt;postit&gt; listseparator &lt;character&gt;</code>
  1409. <br />Character used to separate list items (default ',')</li>
  1410. </ul>
  1411. Note, that in the parameters sent to the following functions, ":" serves as separator between list name and items,
  1412. and "," serves as separator between items. They may be exchanged with simple regular expression operations.
  1413. <ul>
  1414. <li><code>attr &lt;postit&gt; postmeMailFun &lt;string&gt;</code>
  1415. <br />Function name for the eMail function. This subroutine
  1416. is called with three parameters for recipient, subject
  1417. and text.</li>
  1418. <li><code>attr &lt;postit&gt; postmeMailRec(01|02|...) &lt;string&gt;</code>
  1419. recipient addresses for the above eMail function (per PostMe).</li>
  1420. <li><code>attr &lt;postit&gt; postmeMsgFun &lt;string&gt;</code>
  1421. <br />Function name for the instant messenger function. This subroutine
  1422. is called with three parameters for recipient, subject
  1423. and text.</li>
  1424. <li><code>attr &lt;postit&gt; postmeMsgRec(01|02|...) &lt;string&gt;</code>
  1425. recipient addresses for the above instant messenger function (per PostMe).</li>
  1426. <li><code>attr &lt;postit&gt; postmeTTSFun &lt;string&gt;</code>
  1427. <br />Function name for the text-to-speech function. This subroutine
  1428. is called with two parameters, the device name and the composite text.
  1429. </li>
  1430. <li><code>attr &lt;postit&gt; postmeTTSDev(01|02|...) &lt;string&gt;</code>
  1431. device name for the above TTS function.</li>
  1432. <li>Standard attributes <a href="#alias">alias</a>, <a href="#comment">comment</a>, <a
  1433. href="#event-on-update-reading">event-on-update-reading</a>, <a
  1434. href="#event-on-change-reading">event-on-change-reading</a>, <a href="#room"
  1435. >room</a>, <a href="#eventMap">eventMap</a>, <a href="#loglevel">loglevel</a>,
  1436. <a href="#webCmd">webCmd</a></li>
  1437. </ul>
  1438. =end html
  1439. =begin html_DE
  1440. <a name="PostMe"></a>
  1441. <h3>PostMe</h3>
  1442. <a href="https://wiki.fhem.de/wiki/Modul_PostMe">Deutsche Dokumentation im Wiki</a> vorhanden, die englische Version gibt es hier: <a href="/fhem/commandref.html#PostMe">PostMe</a>
  1443. =end html_DE
  1444. =cut