70_Pushsafer.pm 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. # $Id: 70_Pushsafer.pm 15140 2017-09-26 09:20:09Z markusbloch $
  2. ##############################################################################
  3. #
  4. # 70_Pushsafer.pm
  5. # Sents messages to your Pushsafer accout which will be delivered to
  6. # any configured device (e.g. iOS, Andriod, Windows).
  7. #
  8. # This module is based on the Pushsafer API description
  9. # which is available at https://www.pushsafer.com/en/pushapi:
  10. #
  11. # Copyright by Markus Bloch
  12. # e-mail: Notausstieg0309@googlemail.com
  13. #
  14. # This file is part of fhem.
  15. #
  16. # Fhem is free software: you can redistribute it and/or modify
  17. # it under the terms of the GNU General Public License as published by
  18. # the Free Software Foundation, either version 2 of the License, or
  19. # (at your option) any later version.
  20. #
  21. # Fhem is distributed in the hope that it will be useful,
  22. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. # GNU General Public License for more details.
  25. #
  26. # You should have received a copy of the GNU General Public License
  27. # along with fhem. If not, see <http://www.gnu.org/licenses/>.
  28. #
  29. ##############################################################################
  30. package main;
  31. use HttpUtils;
  32. use MIME::Base64 qw(encode_base64 encode_base64url);
  33. use utf8;
  34. my %Pushsaver_Params = (
  35. "title" => {"short" => "t", "check" => qr/^.*$/},
  36. "sound" => {"short" => "s", "check" => qr/^\d+$/},
  37. "vibration" => {"short" => "v", "check" => qr/^\d+$/},
  38. "icon" => {"short" => "i", "check" => qr/^\d+$/},
  39. "url" => {"short" => "u", "check" => qr/^[a-z]+:/},
  40. "device" => {"short" => "d", "check" => qr/^(?:gs)?\d+$/},
  41. "key" => {"short" => "k", "check" => qr/^(?:[a-zA-Z\d]{20}|[a-zA-Z\d]{15})$/},
  42. "urlText" => {"short" => "ut"},
  43. "message" => {"short" => "m"},
  44. "ttl" => {"short" => "l", "check" => qr/^\d+$/},
  45. "picture" => {"short" => "p"},
  46. "picture2" => {"short" => "p2"},
  47. "picture3" => {"short" => "p3"}
  48. );
  49. #############################
  50. sub Pushsafer_Initialize($$)
  51. {
  52. my ($hash) = @_;
  53. $hash->{DefFn} = "Pushsafer_Define";
  54. $hash->{SetFn} = "Pushsafer_Set";
  55. $hash->{AttrList} = "disable:0,1 ".
  56. "disabledForIntervals ".
  57. "do_not_notify:0,1 ".
  58. $readingFnAttributes;
  59. return undef;
  60. }
  61. #############################
  62. sub Pushsafer_Define($$)
  63. {
  64. my ($hash, $def) = @_;
  65. my @args = split("[ \t]+", $def);
  66. if(!@args == 3)
  67. {
  68. return "wrong define syntax: define <name> Pushsafer <privatekey>";
  69. }
  70. my $privatekey = @args[2];
  71. return "invalid private key: ".$privatekey if ($privatekey !~ /^[a-z\d]{20}$/i);
  72. $hash->{PrivateKey} = $privatekey;
  73. $hash->{helper}{URL} = "https://www.pushsafer.com/api";
  74. Log3 $hash, 4, "Pushsafer ($name) - defined with private key: ".$privatekey;
  75. $hash->{STATE} = "Initialized";
  76. return undef;
  77. }
  78. #############################
  79. sub Pushsafer_Set($$$@)
  80. {
  81. my ($hash, $name, $cmd, @args) = @_;
  82. my $usage = "Unknown argument " . $cmd . ", choose one of message";
  83. if ($cmd eq 'message')
  84. {
  85. return "Arguments for command \"message\" missing" unless (@args >= 1);
  86. return "Device $name is disabled" if(IsDisabled($name));
  87. my ($a, $h) = parseParams(\@args);
  88. unless(defined($a->[0]))
  89. {
  90. return "No message text given";
  91. }
  92. if(scalar(@{$a}) > 1 and scalar(keys(%{$h})) == 0)
  93. {
  94. $h->{m} = join(" ", @{$a});
  95. }
  96. elsif(scalar(@{$a}) == 1 and scalar(keys(%{$h})) >= 0)
  97. {
  98. $h->{m} = $a->[0];
  99. }
  100. else
  101. {
  102. return "invalid syntax";
  103. }
  104. $h->{m} =~ s/\\n/\n/g; # replace \n with newlines
  105. my ($err, $data) = Pushsafer_createBody($hash, $h);
  106. return $err if(defined($err));
  107. my $data_scrambled = $data;
  108. $data_scrambled =~ s/k=[^&]+/k=HIDDEN/g; # remove private key from log output
  109. Log3 $name, 5, "Pushsafer ($name) - sending data: $data_scrambled";
  110. Pushsafer_Send($hash, $data);
  111. return undef;
  112. }
  113. else
  114. {
  115. return $usage;
  116. }
  117. }
  118. ############################################################################################################
  119. #
  120. # Begin of helper functions
  121. #
  122. ############################################################################################################
  123. #############################
  124. # creates the HTTP Body to sent a message
  125. sub Pushsafer_createBody($$)
  126. {
  127. my ($hash, $args) = @_;
  128. my $name = $hash->{NAME};
  129. my @urlParts;
  130. my @errs;
  131. push @urlParts, "k=".$hash->{PrivateKey} unless(exists($args->{k}) and exists($args->{key}));
  132. foreach my $item (keys %{$args})
  133. {
  134. my $key;
  135. my $val;
  136. if(exists($Pushsaver_Params{$item}))
  137. {
  138. if(exists($Pushsaver_Params{$item}{check}) and $args->{$item} !~ $Pushsaver_Params{$item}{check})
  139. {
  140. push @errs, "wrong syntax for option $item: ".$args->{$item};
  141. }
  142. else
  143. {
  144. $key = $Pushsaver_Params{$item}{short};
  145. $val = $args->{$item}
  146. }
  147. }
  148. elsif(grep($Pushsaver_Params{$_}{short} eq $item, keys(%Pushsaver_Params)))
  149. {
  150. my $command = join "", grep($Pushsaver_Params{$_}{short} eq $item, keys(%Pushsaver_Params));
  151. if(exists($Pushsaver_Params{$command}{check}) and $args->{$item} !~ $Pushsaver_Params{$command}{check})
  152. {
  153. push @errs, "wrong syntax for option $item: ".$args->{$item};
  154. }
  155. else
  156. {
  157. $key = $item;
  158. $val = $args->{$item}
  159. }
  160. }
  161. else
  162. {
  163. push @errs, "unsupported parameter: $item";
  164. next;
  165. }
  166. if($key =~/^p\d?$/)
  167. {
  168. if($val =~ /^IPCAM:(\S+)$/)
  169. {
  170. my $ipcam = $1;
  171. if(!exists($defs{$ipcam}) or !exists($defs{$ipcam}{TYPE}) or $defs{$ipcam}{TYPE} ne "IPCAM")
  172. {
  173. Log3 $name, 3, "Pushsafer ($name) - no such IPCAM device: $ipcam. sending message without a picture...";
  174. next;
  175. }
  176. my $path = AttrVal($ipcam, "storage",AttrVal("global", "modpath", ".")."/www/snapshots");
  177. $path .= "/" unless($path =~ m,/$,);
  178. $path .= ReadingsVal($ipcam, "last", "");
  179. $val = Pushsafer_createDataUrl($hash, $path);
  180. next unless(defined($val));
  181. }
  182. elsif(-e $val)
  183. {
  184. $val = Pushsafer_createDataUrl($hash, $val);
  185. next unless(defined($val));
  186. }
  187. else
  188. {
  189. Log3 $name, 3, "Pushsafer ($name) - picture file does not exist: $val - sending message without a picture...";
  190. next;
  191. }
  192. }
  193. push @urlParts, $key."=".urlEncode($val);
  194. }
  195. return join("\n", @errs) if(@errs);
  196. return (undef, join("&", @urlParts));
  197. }
  198. #####################################
  199. # determine the image file format (reused from IPCAM module by Martin Fischer)
  200. sub Pushsafer_guessFileFormat($)
  201. {
  202. my ($src) = shift;
  203. my $header;
  204. my $srcHeader;
  205. open(my $s, "<", $src) || return undef;
  206. $src = $s;
  207. my $reading = read($src, $srcHeader, 64);
  208. return undef if(!$reading);
  209. local($_) = $srcHeader;
  210. return "image/jpeg" if /^\xFF\xD8/;
  211. return "image/png" if /^\x89PNG\x0d\x0a\x1a\x0a/;
  212. return "image/gif" if /^GIF8[79]a/;
  213. return undef;
  214. }
  215. #####################################
  216. # create a data URL schema from a image file
  217. sub Pushsafer_createDataUrl($$)
  218. {
  219. my ($hash, $file) = @_;
  220. my $name = $hash->{NAME};
  221. Log3 $name, 4, "Pushsafer ($name) - open image file: $file";
  222. my ($err, @content) = FileRead({FileName => $file, ForceType => "file"});
  223. if(defined($err))
  224. {
  225. Log3 $name, 3, "Pushsafer ($name) - unable to open image file $file: $err";
  226. Log3 $name, 3, "Pushsafer ($name) - sending message without picture...";
  227. }
  228. else
  229. {
  230. my $image = join($/, @content);
  231. my $mime_type = Pushsafer_guessFileFormat(\$image);
  232. if(defined($mime_type))
  233. {
  234. Log3 $name, 5, "Pushsafer ($name) - found image of type: $mime_type";
  235. my $base_64 = encode_base64($image);
  236. return "data:$mime_type;base64,".$base_64;
  237. }
  238. else
  239. {
  240. Log3 $name, 3, "Pushsafer ($name) - unsupported image type for $file - see commandref for supported image formats";
  241. }
  242. }
  243. return undef;
  244. }
  245. #############################
  246. # sents a message via HTTP request
  247. sub Pushsafer_Send($$)
  248. {
  249. my ($hash, $body) = @_;
  250. my $params = {
  251. url => $hash->{helper}{URL},
  252. timeout => 10,
  253. hash => $hash,
  254. data => $body,
  255. method => "POST",
  256. callback => \&Pushsafer_Callback
  257. };
  258. HttpUtils_NonblockingGet($params);
  259. return undef;
  260. }
  261. #############################
  262. # processes the HTTP answer
  263. sub Pushsafer_Callback($$$)
  264. {
  265. my ($params, $err, $data) = @_;
  266. my $hash = $params->{hash};
  267. my $name = $hash->{NAME};
  268. $err = "" unless(defined($err));
  269. $data = "" unless(defined($err));
  270. if($data ne "")
  271. {
  272. Log3 $name, 5, "Pushsafer ($name) - received ".(defined($params->{code}) ? "HTTP status ".$params->{code}." with " : "")."data: $data";
  273. }
  274. if($err ne "")
  275. {
  276. readingsSingleUpdate($hash, "last-error", $err,1);
  277. Log3 $name, 3, "Pushsafer ($name) - error while sending message: $err";
  278. }
  279. if(exists($params->{code}) and $params->{code} != 200)
  280. {
  281. if($data ne "" and $data =~ /error"?\s*:\s*"?(.+?)"?(?:,|}|$)/)
  282. {
  283. readingsSingleUpdate($hash, "lastError", $1, 1);
  284. }
  285. else
  286. {
  287. readingsSingleUpdate($hash, "lastError", "received HTTP status ".$params->{code}, 1);
  288. Log3 $name, 3, "Pushsafer ($name) - error while sending message: received HTTP status $params->{code}";
  289. }
  290. return undef;
  291. }
  292. if($data ne "")
  293. {
  294. readingsBeginUpdate($hash);
  295. if($data =~ /success"?\s*:\s*"?(.+?)"?(?:,|}|$)/)
  296. {
  297. readingsBulkUpdate($hash, "lastSuccess", $1);
  298. }
  299. if($data =~ /available"?\s*:\s*{(.+)\s*}\s*}\s*$/gcs)
  300. {
  301. my %devices = grep { defined($_) } map { /^"?(\d+)"?:({.+})$/ ? ($1 => $2) : undef } split(",", $1);
  302. foreach my $dev (keys %devices)
  303. {
  304. if(defined($devices{$dev}) and $devices{$dev} =~ /^{\s*"?([^":]+)"?\s*:\s*"?([^":]+)"?\s*}$/)
  305. {
  306. my ($devname, $available) = ($1, $2);
  307. $devname =~ s/\s+//g;
  308. readingsBulkUpdate($hash, "availableMessages-$dev-$devname", $available);
  309. }
  310. }
  311. }
  312. readingsEndUpdate($hash, 1);
  313. }
  314. return undef;
  315. }
  316. 1;
  317. =pod
  318. =item device
  319. =item summary sents text message notifications via pushsafer.com
  320. =item summary_DE verschickt Texnachrichten zur Benachrichtigung via Pushsafer
  321. =begin html
  322. <a name="Pushsafer"></a>
  323. <h3>Pushsafer</h3>
  324. <ul>
  325. Pushsafer is a web service to receive instant push notifications on your
  326. iOS, Android or Windows 10 Phone or Desktop device from a variety of sources.<br>
  327. You need a Pushsafer account to use this module.<br>
  328. For further information about the service see <a href="https://www.pushsafer.com" target="_new">pushsafer.com</a>.<br>
  329. <br>
  330. This module is only capable to send messages via Pushsafer.<br>
  331. <br>
  332. <a name="PushsaferDefine"></a>
  333. <b>Define</b>
  334. <ul>
  335. <code>define &lt;name&gt; Pushsafer &lt;key&gt;</code><br>
  336. <br>
  337. The parameter &lt;key&gt; must be a alphanumeric string. This can be a regular private key (20 digits) from your Pushsafer account or an E-Mail alias key (15 digits) which needs to be setup in your account.<br>
  338. <br>
  339. Example:
  340. <ul>
  341. <code>define PushsaferAccount Pushsafer A1b2c3D4E5F6g7h8i9J0</code>
  342. </ul>
  343. </ul>
  344. <br>
  345. <a name="PushsaferSet"></a>
  346. <b>Set</b>
  347. <ul>
  348. <code>set &lt;name&gt; message &lt;text&gt; [&lt;option1&gt;=&lt;value&gt; &lt;option2&gt;=&lt;value&gt; ...]</code><br>
  349. <br>
  350. Currently only the message command is available to sent a message.<br>
  351. <br>
  352. So the very basic use case is to send a simple text message like the following example:<br>
  353. <br>
  354. <code>set PushsaferAccount message "My first Pushsafer message."</code><br>
  355. <br>
  356. To send a multiline message, use the placeholder "\n" to indicate a newline:<br>
  357. <br>
  358. <code>set PushsaferAccount message "My second Pushsafer message.\nThis time with two lines."</code><br>
  359. <br>
  360. <u>Optional Modifiers</u><br>
  361. <br>
  362. It is possible to customize a message with special options that can be given in the message command after the message text. Several options can be combined together. The possible options are:<br>
  363. <br>
  364. <code><b>title</b>&nbsp;&nbsp;&nbsp;&nbsp;</code> - short: <code>t&nbsp;</code> - type: text - A special title for the message text.<br>
  365. <code><b>device</b>&nbsp;&nbsp;&nbsp;</code> - short: <code>d&nbsp;</code> - type: text - The device ID as number, to send the message to a specific device, or "gs" + group ID to send to a device group (e.g. "gs23" for group id 23). By default the message will be send to all registered devices.<br>
  366. <code><b>sound</b>&nbsp;&nbsp;&nbsp;&nbsp;</code> - short: <code>s&nbsp;</code> - type: number - The ID of a specific sound to play on the target device upon reception (see <a href="https://www.pushsafer.com/en/pushapi" target="_new">Pushsafer.com</a> for a complete list of values and their meaning).<br>
  367. <code><b>icon</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code> - short: <code>i&nbsp;</code> - type: number - The ID of a specific icon to show on the target device for this text (see <a href="https://www.pushsafer.com/en/pushapi" target="_new">Pushsafer.com</a> for a complete list of values and their meaning).<br>
  368. <code><b>vibration</b></code> - short: <code>v&nbsp;</code> - type: number - The number of times the device should vibrate upon reception (maximum: 3 times; iOS/Android only). If not set, the default behavior of the device is used.<br>
  369. <code><b>url</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code> - short: <code>u&nbsp;</code> - type: text - A URL that should be included in the message. This can be regular http:// URL's but also specific app schemas. See <a href="https://www.pushsafer.com/en/url_schemes" target="_new">Pushsafer.com</a> for a complete list of supported URL schemas.<br>
  370. <code><b>urlText</b>&nbsp;&nbsp;</code> - short: <code>ut</code> - type: text - A text that should be used to display a URL from the "url" option.<br>
  371. <code><b>key</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code> - short: <code>k&nbsp;</code> - type: text - Overrides the private key given in the define statement. Also an alias key can be used.<br>
  372. <code><b>ttl</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code> - short: <code>l&nbsp;</code> - type: number - Defines a "time-to-live" given in minutes after the message will be deleted on the target device(s). Possible range is between 1 - 43200 minutes (30 days).<br>
  373. <code><b>picture</b>&nbsp;&nbsp;</code> - short: <code>p&nbsp;</code> - type: text - Attach a image to the message. This can be a file path located in your filesystem (e.g. <code>picture=/home/user/picture.jpg</code>) or the name of a IPCAM instance (like <code>picture=IPCAM:<i>&lt;name&gt;</i></code>) to send the last snapshot image (e.g. <code>picture=IPCAM:IpCam_Front_House</code>). The supported image formats are JPG, PNG and GIF.<br>
  374. <code><b>picture2</b>&nbsp;</code> - short: <code>p2</code> - type: text - same syntax as for option <code>"picture"</code><br>
  375. <code><b>picture3</b>&nbsp;</code> - short: <code>p3</code> - type: text - same syntax as for option <code>"picture"</code><br>
  376. <br>
  377. Examples:<br>
  378. <br>
  379. <ul>
  380. <code>set PushsaferAccount message "This is a message with a title." title="Super important"</code><br>
  381. <code>set PushsaferAccount message "Get down here\nWe're waiting" title="Lunch is ready" device=100</code><br>
  382. <code>set PushsaferAccount message "Server is down" sound=25 icon=5 vibration=3</code><br>
  383. <code>set PushsaferAccount message "Look at my photos" url="http://www.foo.com/myphotos" urlText="Summer Vacation"</code><br>
  384. <br>
  385. It is also possible to use the short-term versions of options:<br>
  386. <br>
  387. <code>set PushsaferAccount message "This is a message with a title." t="Super important"</code><br>
  388. <code>set PushsaferAccount message "Get down here\nWe're waiting" t="Lunch is ready" d=100</code><br>
  389. <code>set PushsaferAccount message "Server is down" s=25 i=5 v=3</code><br>
  390. <code>set PushsaferAccount message "Look at my photos" u="http://www.foo.com/myphotos" ut="Summer Vacation"</code><br>
  391. </ul>
  392. <br>
  393. </ul>
  394. <br>
  395. <b>Get</b> <ul>N/A</ul><br>
  396. <a name="PushsaferAttr"></a>
  397. <b>Attributes</b>
  398. <ul>
  399. <li><a href="#do_not_notify">do_not_notify</a></li>
  400. <li><a href="#disabledForIntervals">disabledForIntervals</a></li>
  401. <li><a href="#readingFnAttributes">readingFnAttributes</a></li><br>
  402. </ul>
  403. <br>
  404. <a name="PushsaferEvents"></a>
  405. <b>Generated Readings/Events:</b><br>
  406. <ul>
  407. <li><b>lastSuccess</b> - The last successful status message received by the Pushsafer server</li>
  408. <li><b>lastError</b> - The last errur message received by the Pushsafer server</li>
  409. <li><b>availableMessages-<i>&lt;device ID&gt;</i>-<i>&lt;device name&gt;</i></b> - The remaining messages that can be send to this device</li>
  410. </ul>
  411. </ul>
  412. =end html
  413. =begin html_DE
  414. <a name="Pushsafer"></a>
  415. <h3>Pushsafer</h3>
  416. <ul>
  417. Pushsafer ist ein Dienst, um Benachrichtigungen von einer Vielzahl
  418. unterschiedlicher Quellen auf einem iOS-, Android-, Windows 10 Phone oder Desktop-Ger&auml;t zu empfangen.<br>
  419. Es wird ein personalisierter Account ben&ouml;tigt um dieses Modul zu verwenden.<br>
  420. Weitere Information zum Pushsafer-Dienst gibt es unter <a href="https://www.pushsafer.com" target="_new">pushsafer.com</a>.<br>
  421. <br>
  422. Dieses Modul dient lediglich zum Versand von Nachrichten &uuml;ber Pushsafer.<br>
  423. <br>
  424. <br>
  425. <a name="PushsaferDefine"></a>
  426. <b>Define</b>
  427. <ul>
  428. <code>define &lt;Name&gt; Pushsafer &lt;Schl&uuml;ssel&gt;</code><br>
  429. <br>
  430. Der Parameter &lt;Schl&uuml;ssel&gt; muss eine alphanumerische Zeichenkette sein. Hierbei kann es sich um einen regul&auml;ren privaten Schl&uuml;ssel (20 Zeichen lang) handeln oder um einen Email-Alias-Schl&uuml;ssel (15 Zeichen lang), welcher in einem Account entsprechend eingerichtet sein muss.<br>
  431. <br>
  432. Beispiel:
  433. <ul>
  434. <code>define PushsaferAccount Pushsafer A1b2c3D4E5F6g7h8i9J0</code>
  435. </ul>
  436. </ul>
  437. <br>
  438. <a name="PushsaferSet"></a>
  439. <b>Set</b>
  440. <ul>
  441. <code>set &lt;Name&gt; message &lt;Nachricht&gt; [&lt;Option1&gt;=&lt;Wert&gt; &lt;Option2&gt;=&lt;Wert&gt; ...]</code><br>
  442. <br>
  443. Aktuell wird nur das "message"-Kommando unterst&uuml;tzt um Nachrichten zu versenden.<br>
  444. <br>
  445. Der einfachste Anwendungsfall ist das Versenden einer einfachen Textnachricht wie im folgenden Beispiel:<br>
  446. <br>
  447. <code>set PushsaferAccount message "Meine erste Pushsafer Nachricht."</code><br>
  448. <br>
  449. Um eine mehrzeilige Nachricht zu schicken, kann man den Platzhalter "\n" f&uuml;r einen Zeilenumbruch verwenden:<br>
  450. <br>
  451. <code>set PushsaferAccount message "Meine zweite Pushsafer Nachricht.\nDiesmal mit zwei Zeilen."</code><br>
  452. <br>
  453. <u>Optionale Zusatzparameter</u><br>
  454. <br>
  455. Es ist m&ouml;glich die zu versendende Nachricht durch zus&auml;tzliche Optionen an die eigenen W&uuml;nsche anzupassen. Diese Optionen k&ouml;nnen hinter dem Nachrichtentext beliebig kombiniert werden um die Nachricht zu individualisieren. Die m&ouml;glichen Optionen sind:<br>
  456. <br>
  457. <code><b>title</b>&nbsp;&nbsp;&nbsp;&nbsp;</code> - Kurzform: <code>t&nbsp;</code> - Typ: Text - Eine &Uuml;berschrift, die &uuml;ber der Nachricht hervorgehoben angezeigt werden soll.<br>
  458. <code><b>device</b>&nbsp;&nbsp;&nbsp;</code> - Kurzform: <code>d&nbsp;</code> - Typ: Text - Die Ger&auml;te-ID als Ganzzahl an welche die Nachricht gezielt geschickt werden soll. Um eine Gruppen-ID direkt zu addressieren muss der ID das Pr&auml;fix "gs" vorangestellt werden (Bsp. "gs23" f&uuml;r die Gruppen-ID 23). Standardm&auml;&szlig;ig wird eine Nachricht immer an alle Ger&auml;te geschickt, die mit dem Account verkn&uuml;pft sind.<br>
  459. <code><b>sound</b>&nbsp;&nbsp;&nbsp;&nbsp;</code> - Kurzform: <code>s&nbsp;</code> - Typ: Ganzzahl - Die Nummer eines Tons, welcher beim Empfang der Nachricht auf dem Zielger&auml;t ert&ouml;nen soll (siehe <a href="https://www.pushsafer.com/de/pushapi" target="_new">pushsafer.com</a> f&uuml;r eine Liste m&ouml;glicher Werte).<br>
  460. <code><b>icon</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code> - Kurzform: <code>i&nbsp;</code> - Typ: Ganzzahl - Die Nummer eines Icons, welches zusammen mit der Nachricht auf dem Zielger&auml;t angezeigt werden soll (siehe <a href="https://www.pushsafer.com/de/pushapi" target="_new">Pushsafer.com</a> f&uuml;r eine Liste m&ouml;glicher Werte).<br>
  461. <code><b>vibration</b></code> - Kurzform: <code>v&nbsp;</code> - Typ: Ganzzahl - Die Anzahl, wie oft das Zielger&auml;t vibrieren soll beim Empfang der Nachricht (maximal 3 mal; nur f&uuml;r iOS-/Android-Ger&auml;te nutzbar). Falls nicht benutzt, wird die ger&auml;teinterne Einstellung verwendet.<br>
  462. <code><b>url</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code> - Kurzform: <code>u&nbsp;</code> - Typ: Text - Eine URL, welche der Nachricht angehangen werden soll. Dies kann eine normale http:// bzw. https:// URL sein, es sind jedoch auch weitere spezielle Schemas m&ouml;glich. Eine Liste aller m&ouml;glichen URL-Schemas gibt es unter <a href="https://www.pushsafer.com/de/url_schemes" target="_new">pushsafer.com</a> .<br>
  463. <code><b>urlText</b>&nbsp;&nbsp;</code> - Kurzform: <code>ut</code> - Typ: Text - Der Text, welcher zum Anzeigen der URL benutzt werden soll anstatt der Zieladresse.<br>
  464. <code><b>key</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code> - Kurzform: <code>k&nbsp;</code> - Typ: Text - &Uuml;bersteuert den zu nutzenden Schl&uuml;ssel zur Identifikation aus dem define-Kommando. Es kann hierbei auch ein Email-Alias-Schl&uuml;ssel benutzt werden.<br>
  465. <code><b>ttl</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code> - Kurzform: <code>l&nbsp;</code> - Typ: Ganzzahl - Die Lebensdauer der Nachricht in Minuten. Sobald die Lebensdauer erreicht ist, wird die Nachricht selbstst&auml;ndig auf allen Ger&auml;ten gel&ouml;scht. Der m&ouml;gliche Wertebereich liegt zwischen 1 - 43200 Minuten (entspricht 30 Tagen).<br>
  466. <code><b>picture</b>&nbsp;&nbsp;</code> - Kurzform: <code>p&nbsp;</code> - Typ: Text - Anh&auml;ngen eines Bildes zur Nachricht. Dies kann ein Dateipfad zu einer Bilddatei sein (z.B. <code>picture=/home/user/Bild.jpg</code>) oder der Name einer IPCAM-Instanz (im Format: <code>picture=IPCAM:<i>&lt;Name&gt;</i></code>) um die letzte Aufnahme zu senden (Bsp. <code>picture=IPCAM:IpKamera_Einganstuer</code>). Es werden die Dateiformate JPG, PNG und GIF unterst&uuml;zt.<br>
  467. <code><b>picture2</b>&nbsp;</code> - Kurzform: <code>p2</code> - Typ: Text - Gleiche Syntax wie die Option <code>"picture"</code>.<br>
  468. <code><b>picture3</b>&nbsp;</code> - Kurzform: <code>p3</code> - Typ: Text - Gleiche Syntax wie die Option <code>"picture"</code>.<br>
  469. <br>
  470. Beispiele:<br>
  471. <br>
  472. <ul>
  473. <code>set PushsaferAccount message "Dies ist eine Nachricht mit &Uuml;berschrift." title="Sehr Wichtig!!"</code><br>
  474. <code>set PushsaferAccount message "Komm runter\nwir warten" title="Mittag ist fertig" device=100</code><br>
  475. <code>set PushsaferAccount message "Server ist nicht erreichbar" sound=25 icon=5 vibration=3</code><br>
  476. <code>set PushsaferAccount message "Hier sind die Urlaubsfotos" url="http://www.foo.de/fotos" urlText="Sommerurlaub"</code><br>
  477. <br>
  478. It is also possible to use the short-term versions of options:<br>
  479. <br>
  480. <code>set PushsaferAccount message "Dies ist eine Nachricht mit &Uuml;berschrift." t="Sehr Wichtig!!"</code><br>
  481. <code>set PushsaferAccount message "Komm runter\nwir warten" t="Mittag ist fertig" d=100</code><br>
  482. <code>set PushsaferAccount message "Server ist nicht erreichbar" s=25 i5 v=3</code><br>
  483. <code>set PushsaferAccount message "Hier sind die Urlaubsfotos" u="http://www.foo.de/fotos" ut="Sommerurlaub"</code><br>
  484. </ul>
  485. <br>
  486. </ul>
  487. <br>
  488. <b>Get</b> <ul>N/A</ul><br>
  489. <a name="PushsaferAttr"></a>
  490. <a name="PushsaferAttr"></a>
  491. <b>Attribute</b>
  492. <ul>
  493. <li><a href="#do_not_notify">do_not_notify</a></li>
  494. <li><a href="#disabled">disabled</a></li>
  495. <li><a href="#disabledForIntervals">disabledForIntervals</a></li>
  496. <li><a href="#readingFnAttributes">readingFnAttributes</a></li><br>
  497. </ul>
  498. <br>
  499. <a name="PushsaferEvents"></a>
  500. <b>Generierte Readings/Events:</b><br>
  501. <ul>
  502. <li><b>lastSuccess</b> - Die letzte erfolgreiche Statusmeldung vom Pushsafer Server</li>
  503. <li><b>lastError</b> - Die letzte Fehlermeldung vom Pushsafer Server</li>
  504. <li><b>availableMessages-<i>&lt;Ger&auml;te-ID&gt;</i>-<i>&lt;Ger&auml;te-Name&gt;</i></b> - Die verbleibende Anzahl an Nachrichten die zu diesem Ger&auml;t noch gesendet werden k&ouml;nnen</li>
  505. </ul>
  506. </ul>
  507. =end html_DE
  508. =cut