75_msgConfig.pm 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. # $Id: 75_msgConfig.pm 12317 2016-10-10 23:12:02Z loredo $
  2. ##############################################################################
  3. #
  4. # 97_msgConfig.pm
  5. # Global configuration settings for FHEM msg command.
  6. #
  7. # Copyright by Julian Pawlowski
  8. # e-mail: julian.pawlowski at gmail.com
  9. #
  10. # This file is part of fhem.
  11. #
  12. # Fhem is free software: you can redistribute it and/or modify
  13. # it under the terms of the GNU General Public License as published by
  14. # the Free Software Foundation, either version 2 of the License, or
  15. # (at your option) any later version.
  16. #
  17. # Fhem is distributed in the hope that it will be useful,
  18. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. # GNU General Public License for more details.
  21. #
  22. # You should have received a copy of the GNU General Public License
  23. # along with fhem. If not, see <http://www.gnu.org/licenses/>.
  24. #
  25. #
  26. # Version: 1.0.0
  27. #
  28. # Major Version History:
  29. # - 1.0.0 - 2015-10-18
  30. # -- First release
  31. #
  32. ##############################################################################
  33. package main;
  34. use strict;
  35. use warnings;
  36. use Data::Dumper;
  37. sub msgConfig_Set($@);
  38. sub msgConfig_Get($@);
  39. sub msgConfig_Define($$);
  40. sub msgConfig_Undefine($$);
  41. ###################################
  42. sub msgConfig_Initialize($) {
  43. my ($hash) = @_;
  44. require "$attr{global}{modpath}/FHEM/msgSchema.pm";
  45. $hash->{DefFn} = "msgConfig_Define";
  46. $hash->{SetFn} = "msgConfig_Set";
  47. $hash->{GetFn} = "msgConfig_Get";
  48. $hash->{UndefFn} = "msgConfig_Undefine";
  49. # add attributes for configuration
  50. no warnings 'qw';
  51. my @attrList = qw(
  52. msgCmdAudio
  53. msgCmdAudioShort
  54. msgCmdAudioShortPrio
  55. msgCmdLight
  56. msgCmdLightHigh
  57. msgCmdLightLow
  58. msgCmdMail
  59. msgCmdMailHigh
  60. msgCmdMailLow
  61. msgCmdPush
  62. msgCmdPushHigh
  63. msgCmdPushLow
  64. msgCmdScreen
  65. msgCmdScreenHigh
  66. msgCmdScreenLow
  67. msgFwPrioAbsentAudio:-2,-1,0,1,2
  68. msgFwPrioAbsentLight:-2,-1,0,1,2
  69. msgFwPrioAbsentScreen:-2,-1,0,1,2
  70. msgFwPrioEmergencyAudio:-2,-1,0,1,2
  71. msgFwPrioEmergencyLight:-2,-1,0,1,2
  72. msgFwPrioEmergencyPush:-2,-1,0,1,2
  73. msgFwPrioEmergencyScreen:-2,-1,0,1,2
  74. msgFwPrioGoneAudio:-2,-1,0,1,2
  75. msgFwPrioGoneLight:-2,-1,0,1,2
  76. msgFwPrioGoneScreen:-2,-1,0,1,2
  77. msgLocationDevs
  78. msgPriorityAudio:-2,-1,0,1,2
  79. msgPriorityLight:-2,-1,0,1,2
  80. msgPriorityMail:-2,-1,0,1,2
  81. msgPriorityPush:-2,-1,0,1,2
  82. msgPriorityScreen:-2,-1,0,1,2
  83. msgPriorityText:-2,-1,0,1,2
  84. msgResidentsDev
  85. msgSwitcherDev
  86. msgThPrioHigh:-2,-1,0,1,2
  87. msgThPrioNormal:-2,-1,0,1,2
  88. msgThPrioAudioEmergency:-2,-1,0,1,2
  89. msgThPrioAudioHigh:-2,-1,0,1,2
  90. msgThPrioTextEmergency:-2,-1,0,1,2
  91. msgThPrioTextNormal:-2,-1,0,1,2
  92. msgThPrioGwEmergency:-2,-1,0,1,2
  93. msgTitleAudio
  94. msgTitleAudioShort
  95. msgTitleAudioShortPrio
  96. msgTitleLight
  97. msgTitleLightHigh
  98. msgTitleLightLow
  99. msgTitleMail
  100. msgTitleMailHigh
  101. msgTitleMailLow
  102. msgTitlePush
  103. msgTitlePushHigh
  104. msgTitlePushLow
  105. msgTitleScreen
  106. msgTitleScreenHigh
  107. msgTitleScreenLow
  108. msgTitleText
  109. msgTitleTextHigh
  110. msgTitleTextLow
  111. msgType
  112. );
  113. use warnings 'qw';
  114. $hash->{AttrList} = join( " ", @attrList ) . " " . $readingFnAttributes;
  115. # add global attributes
  116. foreach (
  117. "msgContactAudio", "msgContactMail", "msgContactPush",
  118. "msgContactScreen", "msgContactLight", "msgRecipient",
  119. "msgRecipientAudio", "msgRecipientMail", "msgRecipientPush",
  120. "msgRecipientScreen", "msgRecipientText", "msgRecipientLight",
  121. )
  122. {
  123. addToAttrList($_);
  124. }
  125. }
  126. ###################################
  127. sub msgConfig_Define($$) {
  128. my ( $hash, $def ) = @_;
  129. my @a = split( "[ \t]+", $def, 5 );
  130. return "Usage: define <name> msgConfig"
  131. if ( int(@a) < 2 );
  132. my $name = $a[0];
  133. return "Global configuration device already defined: "
  134. . $modules{msgConfig}{defptr}{NAME}
  135. if ( defined( $modules{msgConfig}{defptr} ) );
  136. # create global unique device definition
  137. $modules{msgConfig}{defptr} = $hash;
  138. # set default settings on first define
  139. if ( $init_done && !defined( $hash->{OLDDEF} ) ) {
  140. my $group = AttrVal( "global", "group", "Global" );
  141. my $room = AttrVal( "global", "room", "" );
  142. my $verbose = AttrVal( "global", "verbose", 3 );
  143. $attr{$name}{group} = $group;
  144. $attr{$name}{verbose} = $verbose;
  145. $attr{$name}{room} = $room if ( $room ne "" );
  146. $attr{$name}{comment} = "FHEM Global Configuration for command 'msg'";
  147. $attr{$name}{stateFormat} = "fhemMsgState";
  148. readingsBeginUpdate($hash);
  149. readingsBulkUpdate( $hash, "fhemMsgState", "initialized" );
  150. readingsEndUpdate( $hash, 1 );
  151. }
  152. return undef;
  153. }
  154. ###################################
  155. sub msgConfig_Undefine($$) {
  156. my ( $hash, $name ) = @_;
  157. # release global unique device definition
  158. delete $modules{msgConfig}{defptr};
  159. return undef;
  160. }
  161. ###################################
  162. sub msgConfig_Set($@) {
  163. my ( $hash, @a ) = @_;
  164. my $name = $hash->{NAME};
  165. shift @a;
  166. my $what = shift @a;
  167. Log3 $name, 5, "msgConfig $name: called function msgConfig_Set()";
  168. my @msgTypes = ( "audio", "light", "mail", "push", "screen" );
  169. # cleanReadings
  170. if ( lc($what) eq "cleanreadings" ) {
  171. my $device = defined( $a[0] ) ? $a[0] : ".*";
  172. return fhem( "deletereading $device fhemMsg.*", 1 );
  173. }
  174. # addLocation
  175. elsif ( lc($what) eq "addlocation" ) {
  176. my $location = join( " ", @a );
  177. my $group = AttrVal( $name, "group", "msgConfig" );
  178. my $room = AttrVal( $name, "room", "" );
  179. my $return = "";
  180. return "Missing argument 'location'"
  181. if ( $location eq "" );
  182. my $device = "msgRoom_" . $location;
  183. $device =~ s/[\s\t-]+/_/g;
  184. return "Device $device is already existing but not a dummy device"
  185. if ( defined( $defs{$device} ) && $defs{$device}{TYPE} ne "dummy" );
  186. if ( !defined( $defs{$device} ) ) {
  187. $return = fhem( "define $device dummy", 1 );
  188. $return .= "Device $device was created"
  189. if ( $return eq "" );
  190. }
  191. else {
  192. $return = "Existing dummy device $device was updated";
  193. }
  194. $attr{$device}{group} = $group if ( !defined( $attr{$device}{group} ) );
  195. $attr{$device}{room} = $room
  196. if ( !defined( $attr{$device}{room} ) && $room ne "" );
  197. $attr{$device}{comment} = "Auto-created by $name"
  198. if ( !defined( $attr{$device}{comment} ) );
  199. $attr{$device}{userattr} .= " msgLocationName"
  200. if ( defined( $attr{$device}{userattr} )
  201. && $attr{$device}{userattr} !~
  202. /^msgLocationName$|^msgLocationName\s|\smsgLocationName\s|\smsgLocationName$/
  203. );
  204. $attr{$device}{userattr} = "msgLocationName"
  205. if ( !defined( $attr{$device}{userattr} ) );
  206. $attr{$device}{msgLocationName} = $location;
  207. fhem("set $device $location");
  208. $attr{$name}{msgLocationDevs} .= "," . $device
  209. if ( defined( $attr{$name}{msgLocationDevs} )
  210. && $attr{$name}{msgLocationDevs} !~
  211. /^$device\$|^$device,|,$device,|,$device$/ );
  212. $attr{$name}{msgLocationDevs} = $device
  213. if ( !defined( $attr{$name}{msgLocationDevs} ) );
  214. return $return;
  215. }
  216. # createSwitcherDev
  217. elsif ( lc($what) eq "createswitcherdev" ) {
  218. my $device = AttrVal( $name, "msgSwitcherDev", "HouseAnn" );
  219. my $state = AttrVal( $device, "state", "???" );
  220. my $return = "";
  221. my $lang = "en";
  222. $lang = $a[0]
  223. if ( defined( $a[0] ) && $a[0] eq "de" );
  224. return "Device $device is already existing but not a dummy device"
  225. if ( defined( $defs{$device} ) && $defs{$device}{TYPE} ne "dummy" );
  226. if ( !defined( $defs{$device} ) ) {
  227. $return = fhem( "define $device dummy", 1 );
  228. $return .= "Device $device was created"
  229. if ( $return eq "" );
  230. }
  231. else {
  232. $return = "Existing dummy device $device was updated";
  233. }
  234. if ( $lang eq "de" ) {
  235. $attr{$device}{alias} = "Durchsagen";
  236. $attr{$device}{eventMap} =
  237. "active:aktiv long:lang short:kurz visual:visuell off:aus";
  238. $attr{$device}{room} = "Haus"
  239. if ( !defined( $attr{$device}{room} ) );
  240. $attr{$device}{setList} = "state:lang,kurz,visuell,aus";
  241. }
  242. else {
  243. $attr{$device}{alias} = "Announcements";
  244. $attr{$device}{room} = "House"
  245. if ( !defined( $attr{$device}{room} ) );
  246. $attr{$device}{setList} = "state:long,short,visual,off";
  247. delete $attr{$device}{eventMap}
  248. if ( defined( $attr{$device}{eventMap} ) );
  249. }
  250. $attr{$device}{comment} = "Auto-created by $name"
  251. if ( !defined( $attr{$device}{comment} )
  252. || $attr{$device}{comment} ne "Auto-created by $name" );
  253. $attr{$device}{devStateIcon} =
  254. 'aktiv:general_an@90EE90 active:general_an@90EE90 lang:general_an@green:off long:general_an@green:off aus:general_aus@red:long off:general_aus@red:long kurz:general_an@orange:long short:general_an@orange:long visuell:general_an@orange:long visual:general_an@orange:long';
  255. $attr{$device}{"event-on-change-reading"} = "state"
  256. if ( !defined( $attr{$device}{"event-on-change-reading"} ) );
  257. $attr{$device}{group} = "Automation"
  258. if ( !defined( $attr{$device}{group} ) );
  259. $attr{$device}{icon} = "audio_volume_mid";
  260. $attr{$device}{webCmd} = "state";
  261. fhem("set $device long") if ( $state eq "???" );
  262. $return .=
  263. "\nAttribute msgSwitcherDev at device $name was changed to $device"
  264. if ( defined( $attr{$name}{msgSwitcherDev} ) );
  265. $return .= "\nAdded attribute msgSwitcherDev to device $name"
  266. if ( !defined( $attr{$name}{msgSwitcherDev} ) );
  267. $attr{$name}{msgSwitcherDev} = $device;
  268. return $return;
  269. }
  270. # createResidentsDev
  271. elsif ( lc($what) eq "createresidentsdev" ) {
  272. my $device = AttrVal( $name, "msgResidentsDev", "rgr_Residents" );
  273. my $return = "";
  274. my $lang = "en";
  275. $lang = $a[0]
  276. if ( defined( $a[0] ) && $a[0] eq "de" );
  277. return
  278. "Device $device is already existing but not a RESIDENTS or ROOMMATE device"
  279. if (
  280. defined( $defs{$device} )
  281. && ( $defs{$device}{TYPE} ne "RESIDENTS"
  282. && $defs{$device}{TYPE} ne "ROOMMATE" )
  283. );
  284. if ( !defined( $defs{$device} ) ) {
  285. $return = fhem( "define $device RESIDENTS", 1 );
  286. $return .= "RESIDENTS device $device was created."
  287. if ( $return eq "" );
  288. }
  289. else {
  290. $return =
  291. "Existing "
  292. . $defs{$device}{TYPE}
  293. . " device $device was updated.";
  294. }
  295. if ( $lang eq "de" ) {
  296. $attr{$device}{alias} = "Bewohner";
  297. $attr{$device}{eventMap} =
  298. "home:zu_Hause absent:außer_Haus gone:verreist gotosleep:bettfertig asleep:schläft awoken:aufgestanden";
  299. $attr{$device}{group} = "Haus Status"
  300. if ( !defined( $attr{$device}{group} ) );
  301. $attr{$device}{room} = "Haus"
  302. if ( !defined( $attr{$device}{room} ) );
  303. $attr{$device}{widgetOverride} =
  304. "state:zu_Hause,bettfertig,außer_Haus,verreist";
  305. }
  306. else {
  307. $attr{$device}{alias} = "Residents";
  308. $attr{$device}{group} = "Home State"
  309. if ( !defined( $attr{$device}{group} ) );
  310. $attr{$device}{room} = "House"
  311. if ( !defined( $attr{$device}{room} ) );
  312. delete $attr{$device}{eventMap}
  313. if ( defined( $attr{$device}{eventMap} ) );
  314. delete $attr{$device}{widgetOverride}
  315. if ( defined( $attr{$device}{widgetOverride} ) );
  316. }
  317. $attr{$device}{comment} = "Auto-created by $name"
  318. if ( !defined( $attr{$device}{comment} )
  319. || $attr{$device}{comment} ne "Auto-created by $name" );
  320. $attr{$device}{devStateIcon} =
  321. '.*home:status_available@green .*absent:status_away_1@orange .*gone:status_standby .*none:control_building_empty .*gotosleep:status_night@green:asleep .*asleep:status_night@green .*awoken:status_available@green:home .*zu_Hause:user_available:absent .*außer_Haus:user_away:home .*verreist:user_ext_away:home .*bettfertig:scene_toilet:asleep .*schläft:scene_sleeping:awoken .*aufgestanden:scene_sleeping_alternat:home .*:user_unknown';
  322. $return .=
  323. "\nIf you would like this device to act as an overall presence device for ALL msg commands, please adjust attribute msgResidentsDev at device $name to $device."
  324. if ( defined( $attr{$name}{msgResidentsDev} )
  325. && $attr{$name}{msgResidentsDev} ne $device );
  326. $return .=
  327. "\nNext, set a device's msgResidentsDev attribute to '$device' (think of using 'userattr' to add 'msgResidentsDev' to the list of available attributes). \nIf you would like '$device' to act as an overall presence device for ALL msg commands, sett attribute msgResidentsDev at device $name to $device."
  328. if ( !defined( $attr{$name}{msgResidentsDev} ) );
  329. return $return;
  330. }
  331. else {
  332. return
  333. "Unknown argument $what, choose one of cleanReadings addLocation createSwitcherDev:de,en createResidentsDev:de,en";
  334. }
  335. }
  336. ###################################
  337. sub msgConfig_Get($@) {
  338. my ( $hash, @a ) = @_;
  339. my $name = $hash->{NAME};
  340. shift @a;
  341. my $what = shift @a;
  342. Log3 $name, 5, "msgConfig $name: called function msgConfig_Get()";
  343. my @msgTypes = ( "audio", "light", "mail", "push", "screen" );
  344. # routeCmd
  345. if ( lc($what) eq "routecmd" ) {
  346. my $return = "";
  347. my $msgTypesReq =
  348. defined( $a[0] ) ? lc( $a[0] ) : join( ',', @msgTypes );
  349. my $devicesReq = defined( $a[1] ) ? $a[1] : $name;
  350. my $cmdSchema = msgSchema::get();
  351. my $UserDeviceTypes = "";
  352. foreach my $msgType ( split( /,/, $msgTypesReq ) ) {
  353. # Check device
  354. if ( $devicesReq ne "" ) {
  355. foreach my $device ( split( /,/, $devicesReq ) ) {
  356. if ( defined( $defs{$device} ) ) {
  357. $UserDeviceTypes .= "," . $defs{$device}{TYPE}
  358. if ( $UserDeviceTypes ne ""
  359. && $msgType ne "mail"
  360. && $device ne $name );
  361. $UserDeviceTypes = $defs{$device}{TYPE}
  362. if ( $UserDeviceTypes eq ""
  363. && $msgType ne "mail"
  364. && $device ne $name );
  365. $UserDeviceTypes .= ",fhemMsgMail"
  366. if ( $UserDeviceTypes ne ""
  367. && $msgType eq "mail"
  368. && $device ne $name );
  369. $UserDeviceTypes = "fhemMsgMail"
  370. if ( $UserDeviceTypes eq ""
  371. && $msgType eq "mail"
  372. && $device ne $name );
  373. my $typeUc = ucfirst($msgType);
  374. my @priorities;
  375. @priorities = ( "Normal", "ShortPrio", "Short" )
  376. if ( $msgType eq "audio" );
  377. @priorities = ( "Normal", "High", "Low" )
  378. if ( $msgType ne "audio" );
  379. my $output = 0;
  380. foreach my $prio (@priorities) {
  381. my $priorityCat = "";
  382. $priorityCat = $prio if ( $prio ne "Normal" );
  383. my $cmd =
  384. # look for direct
  385. AttrVal(
  386. $device, "msgCmd$typeUc$priorityCat",
  387. # look for indirect
  388. AttrVal(
  389. AttrVal(
  390. $device, "msgRecipient$typeUc", ""
  391. ),
  392. "msgCmd$typeUc$priorityCat",
  393. #look for indirect general
  394. AttrVal(
  395. AttrVal( $device, "msgRecipient", "" ),
  396. "msgCmd$typeUc$priorityCat",
  397. # look for global direct
  398. AttrVal(
  399. $name,
  400. "msgCmd$typeUc$priorityCat",
  401. # look for global indirect
  402. AttrVal(
  403. AttrVal(
  404. $name,
  405. "msgRecipient$typeUc", ""
  406. ),
  407. "msgCmd$typeUc$priorityCat",
  408. #look for global indirect general
  409. AttrVal(
  410. AttrVal(
  411. $name, "msgRecipient",
  412. ""
  413. ),
  414. "msgCmd$typeUc$priorityCat",
  415. # none
  416. ""
  417. )
  418. )
  419. )
  420. )
  421. )
  422. );
  423. next
  424. if ( $cmd eq ""
  425. && $device eq $name
  426. && $output == 0 );
  427. $return .=
  428. uc($msgType)
  429. . ": USER DEFINED COMMANDS WITH PRECEDENCE\n-------------------------------------------------------------------------------\n\n"
  430. if ( $output == 0 );
  431. $return .=
  432. " $device (DEVICE TYPE: "
  433. . $defs{$device}{TYPE} . ")\n"
  434. if ( $output == 0 );
  435. $output = 1 if ( $output == 0 );
  436. $return .= " Priority $prio:\n $cmd\n"
  437. if ( $cmd ne "" );
  438. $return .=
  439. " Priority $prio:\n [DEFAULT COMMAND]\n"
  440. if ( $cmd eq "" );
  441. }
  442. $return .= "\n" if ( $return ne "" );
  443. }
  444. }
  445. $return .= "\n" if ( $return ne "" );
  446. }
  447. # Default commands
  448. if ( defined( $cmdSchema->{$msgType} ) ) {
  449. my $deviceTypes = $devicesReq;
  450. $deviceTypes = join( ',', keys %{ $cmdSchema->{$msgType} } )
  451. if ( $deviceTypes eq "" || $devicesReq eq $name );
  452. $deviceTypes = $UserDeviceTypes
  453. if ( $UserDeviceTypes ne "" );
  454. my $outout = 0;
  455. foreach my $deviceType ( split( /,/, $deviceTypes ) ) {
  456. if ( defined( $cmdSchema->{$msgType}{$deviceType} ) ) {
  457. $return .=
  458. uc($msgType)
  459. . ": DEFAULT COMMANDS\n-------------------------------------------------------------------------------\n\n"
  460. if ( $outout == 0 );
  461. $outout = 1;
  462. $return .= " $deviceType\n";
  463. my @priorities;
  464. @priorities = ( "Normal", "ShortPrio", "Short" )
  465. if ( $msgType eq "audio" );
  466. @priorities = ( "Normal", "High", "Low" )
  467. if ( $msgType ne "audio" );
  468. foreach my $prio (@priorities) {
  469. $return .=
  470. " Priority $prio:\n "
  471. . $cmdSchema->{$msgType}{$deviceType}{$prio}
  472. . "\n";
  473. if (
  474. defined(
  475. $cmdSchema->{$msgType}{$deviceType}
  476. {defaultValues}{$prio}
  477. )
  478. )
  479. {
  480. $return .= " Default Values:\n";
  481. foreach my $key (
  482. keys %{
  483. $cmdSchema->{$msgType}{$deviceType}
  484. {defaultValues}{$prio}
  485. }
  486. )
  487. {
  488. if ( $cmdSchema->{$msgType}{$deviceType}
  489. {defaultValues}{$prio}{$key} ne "" )
  490. {
  491. $return .=
  492. " $key = "
  493. . $cmdSchema->{$msgType}{$deviceType}
  494. {defaultValues}{$prio}{$key} . "\n";
  495. }
  496. else {
  497. $return .= " $key = [EMPTY]\n";
  498. }
  499. }
  500. }
  501. }
  502. $return .= "\n" if ( $return ne "" );
  503. }
  504. }
  505. }
  506. else {
  507. $return .= "Unknown messaging type '$msgType'\n"
  508. if ( $msgType ne "text" );
  509. $return .=
  510. "Messaging type 'text' does not have dedicated routing commands. This is a wrapper type to dynamically distinguish between push and mail.\n"
  511. if ( $msgType eq "text" );
  512. }
  513. $return .= "\n" if ( $return ne "" );
  514. }
  515. $return =
  516. "Non-existing device or unknown module messaging schema definition: $devicesReq"
  517. if ( $return eq "" );
  518. return $return;
  519. }
  520. else {
  521. return
  522. "Unknown argument $what, choose one of routeCmd:,audio,light,mail,push,screen";
  523. }
  524. }
  525. 1;
  526. =pod
  527. =item helper
  528. =item summary global settings and tools for FHEM command <a href="#MSG">msg</a>
  529. =item summary_DE globale Einstellungen und Tools f&uml;r das FHEM Kommando <a href="#MSG">msg</a>
  530. =begin html
  531. <p>
  532. <a name="msgConfig" id="msgConfig"></a>
  533. </p>
  534. <h3>
  535. msgConfig
  536. </h3>
  537. <ul>
  538. Provides global settings and tools for FHEM command <a href="#MSG">msg</a>.<br>
  539. A device named globalMsg will be created automatically when using msg-command for the first time and no msgConfig device could be found.<br>
  540. The device name can be renamed and reconfigured afterwards if desired.<br>
  541. <br>
  542. <a name="msgConfigdefine" id="msgConfigdefine"></a> <b>Define</b>
  543. <ul>
  544. <code>define &lt;name&gt; msgConfig</code><br>
  545. </ul><br>
  546. <br>
  547. <a name="msgConfigset" id="msgConfigset"></a> <b>Set</b>
  548. <ul>
  549. <ul>
  550. <li>
  551. <b>addLocation</b> &nbsp;&nbsp;<Location Name>&nbsp;&nbsp;<br>
  552. Conveniently creates a Dummy device based on the given location name. It will be pre-configured to be used together with location-based routing when using the msg-command. The dummy device will be added to attribute msgLocationDevs automatically. Afterwards additional configuration is required by adding msgContact* or msgRecipient* attributes for gateway devices placed at this specific location.
  553. </li>
  554. <li>
  555. <b>cleanReadings</b> &nbsp;&nbsp;[<device and/or regex>]&nbsp;&nbsp;<br>
  556. Easy way to cleanup all fhemMsg readings. A parameter is optional and can be a concrete device name or mixed together with regex. This command is an alias for "deletereading <device and/or regex> fhemMsg.*".
  557. </li>
  558. <li>
  559. <b>createResidentsDev</b> &nbsp;&nbsp;<de|en>&nbsp;&nbsp;<br>
  560. Creates a new device named rgr_Residents of type <a href="#RESIDENTS">RESIDENTS</a>. It will be pre-configured based on the given language. In case rgr_Residents exists it will be updated based on the given language (basically only a language change). Afterwards next configuration steps will be displayed to use RESIDENTS together with presence-based routing of the msg-command.<br>
  561. This next step is basically to set attribute msgResidentsDevice to refer to this RESIDENTS device either globally or for any other specific FHEM device (most likely you do NOT want to have this attribute set globally as otherwise this will affect ALL devices and therefore ALL msg-commands in your automations).<br>
  562. Note that use of RESIDENTS only makes sense together with ROOMMATE and or GUEST devices which still need to be created manually. See <a href="#RESIDENTSset">RESIDENTS Set commands</a> addRoommate and addGuest respectively.
  563. </li>
  564. <li>
  565. <b>createSwitcherDev</b> &nbsp;&nbsp;<de|en>&nbsp;&nbsp;<br>
  566. Creates a pre-configured Dummy device named HouseAnn and updates globalMsg attribute msgSwitcherDev to refer to it.
  567. </li>
  568. </ul>
  569. </ul>
  570. </ul>
  571. =end html
  572. =begin html_DE
  573. <p>
  574. <a name="msgConfig" id="msgConfig"></a>
  575. </p>
  576. <h3>
  577. msgConfig
  578. </h3>
  579. <ul>
  580. Stellt globale Einstellungen und Tools f&uuml;r das FHEM Kommando <a href="#MSG">msg</a> bereit.<br>
  581. Ein Device mit dem Namen globalMsg wird automatisch bei der ersten Benutzung des msg Kommandos angelegt, sofern kein msgConfig Device gefunden wurde.<br>
  582. Der Device Name kann anschlie&szlig;end beliebig umbenannt und umkonfiguriert werden.<br>
  583. <br>
  584. <a name="msgConfigdefine" id="msgConfigdefine"></a> <b>Define</b>
  585. <ul>
  586. <code>define &lt;name&gt; msgConfig</code><br>
  587. </ul><br>
  588. <br>
  589. <a name="msgConfigset" id="msgConfigset"></a> <b>Set</b>
  590. <ul>
  591. <ul>
  592. <li>
  593. <b>addLocation</b> &nbsp;&nbsp;<Name der Lokation>&nbsp;&nbsp;<br>
  594. Erstellt auf einfache Weise ein Dummy Device basierend auf dem &uuml;bergebenen Lokationsnamen. Es wird for die lokations-basierte Verwendung mit dem msg-Kommando vorkonfiguriert. Das Dummy Device wird automatisch zum Attribut msgLocationDevs hinzugef&uuml;gt. Anschlie&szlig;end ist eine weitere Konfiguration &uuml;ber die Attribute msgContact* oder msgRecipient* notwendig, die auf entsprechende Gateway Devices verweisen, die an dieser Lokation stehen.
  595. </li>
  596. </ul>
  597. </ul>
  598. </ul>
  599. =end html_DE
  600. =cut