70_Pushbullet.pm 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. ##############################################################################
  2. #
  3. # This file is part of fhem.
  4. #
  5. # Fhem is free software: you can redistribute it and/or rename
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # Fhem is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with fhem. If not, see <http://www.gnu.org/licenses/>.
  17. #
  18. ##############################################################################
  19. #
  20. # $Id: 70_Pushbullet.pm 9730 2015-10-30 15:06:41Z fhainz $
  21. #
  22. ##############################################################################
  23. package main;
  24. use strict;
  25. use warnings;
  26. use Data::Dumper;
  27. use utf8;
  28. use Encode qw( encode_utf8 );
  29. use HttpUtils;
  30. use JSON;
  31. #use diagnostics;
  32. sub Pushbullet_Initialize($) {
  33. my ($hash) = @_;
  34. $hash->{GetFn} = "Pushbullet_Get";
  35. $hash->{SetFn} = "Pushbullet_Set";
  36. $hash->{AttrFn} = "Pushbullet_Attr";
  37. $hash->{DefFn} = "Pushbullet_Define";
  38. $hash->{UndefFn} = "Pushbullet_Undefine";
  39. #$hash->{NotifyFn = "Pushbullet_Notify";
  40. $hash->{AttrList} = "disable:0,1".
  41. " defaultTitle".
  42. " defaultDevice".
  43. " ".$readingFnAttributes;
  44. }
  45. sub Pushbullet_Define($$) {
  46. my ( $hash, $def ) = @_;
  47. my @a = split( "[ \t][ \t]*", $def );
  48. return "Usage: define <name> Pushbullet <accessToken>"
  49. if ( @a != 3 );
  50. $hash->{NAME} = $a[0];
  51. $hash->{helper}{key} = $a[2];
  52. my $name = $hash->{NAME};
  53. # accessToken Check
  54. my $url = 'https://' . $hash->{helper}{key} . ':%20@api.pushbullet.com/v2/users/me';
  55. my $decoded = Pushbullet_httpCall($hash,$url,undef,"GET");
  56. return $decoded->{error}{message} if( $decoded->{error} );
  57. Pushbullet_clear($hash);
  58. return undef;
  59. }
  60. sub Pushbullet_Undefine($) {
  61. return undef;
  62. }
  63. sub Pushbullet_Set($@) {
  64. my ($hash, @a) = @_;
  65. my $name = $hash->{NAME};
  66. # Disabled
  67. return undef if( IsDisabled($name) );
  68. # Zu wenig argumente
  69. return "no set argument specified" if(int(@a) < 2);
  70. # Variablen
  71. my $cmd = "";
  72. $cmd = $a[1] if( $a[1] );
  73. my @setValues;
  74. my $i = 0;
  75. my $list = undef;
  76. my %url;
  77. my $urlNew;
  78. my ($err,$data);
  79. my $jsonHash;
  80. my $json;
  81. my $value = "";
  82. # Set Liste
  83. $list = "clear:noArg contactAdd deviceDelete deviceRename message link list";
  84. # Eingaben einlesen
  85. $i = 0;
  86. foreach my $set ( @a ){
  87. $i++;
  88. next if( $i <= 2 );
  89. $value .= Pushbullet_trim($set) . " ";
  90. }
  91. # setValues einlesen
  92. my @split = split( /\s*\|\s*/, $value );
  93. foreach my $sv ( @split ){
  94. $sv = Pushbullet_trim($sv);
  95. push(@setValues, $sv);
  96. Log3 $hash, 4, $sv;
  97. }
  98. %url = ( "push" => 'https://' . $hash->{helper}{key} . ': @api.pushbullet.com/v2/pushes',
  99. "device" => 'https://' . $hash->{helper}{key} . ': @api.pushbullet.com/v2/devices/',
  100. "contact" => 'https://' . $hash->{helper}{key} . ': @api.pushbullet.com/v2/contacts/',
  101. "contactAdd" => 'https://' . $hash->{helper}{key} . ': @api.pushbullet.com/v2/contacts' );
  102. # clear
  103. if( $cmd eq "clear" ){
  104. Pushbullet_clear($hash);
  105. }
  106. # Message senden
  107. elsif( $cmd eq "message" ){
  108. return 'Message needet. Correct sytax: set ' . $name . ' message a message[|a title|deviceName]' if( @a < 3 );
  109. # Variablen
  110. my ($msg, $title, $deviceNick, $deviceIden, $deviceEmail) = "";
  111. my $decoded;
  112. # Argumente überprüfen und auswerten
  113. ($msg, $title, $deviceNick, $deviceIden, $deviceEmail) = Pushbullet_checkArgs($hash, $cmd, @setValues);
  114. # Push geht an Device
  115. $jsonHash = { 'device_iden' => $deviceIden, 'type' => 'note', 'title' => $title, 'body' => $msg };
  116. # Push geht an Kontakt
  117. $jsonHash = { 'email' => $deviceEmail, 'type' => 'note', 'title' => $title, 'body' => $msg } if( $deviceEmail );
  118. # Push senden
  119. $decoded = Pushbullet_httpCall($hash,$url{push},$jsonHash,"POST");
  120. return $decoded->{error}{message} if( $decoded->{error} );
  121. # Last Push Date
  122. my ($seconds) = gettimeofday();
  123. $hash->{LAST_PUSH} = FmtDateTime( $seconds );
  124. }
  125. # Link senden
  126. elsif( $cmd eq "link" ){
  127. return 'Message needet. Correct sytax: set ' . $name . ' link http://www.google.com [| Title | Device]' if( @a < 3 );
  128. # Variablen
  129. my ($link, $title, $deviceNick, $deviceIden, $deviceEmail) = "";
  130. my $decoded;
  131. # Argumente überprüfen und auswerten
  132. ($link, $title, $deviceNick, $deviceIden, $deviceEmail) = Pushbullet_checkArgs($hash, $cmd, @setValues);
  133. # Link check
  134. return "URL is not valid. Correct sytax: set " . $name . " link http://www.google.com [| Title | Device] "
  135. if( $link !~ /^(http|https):\/\/.*/ && $link !~ /^skype:.*/ );
  136. # Push geht an Device
  137. $jsonHash = {'type' => 'link', 'device_iden' => $deviceIden, 'title' => $title, 'url' => $link};
  138. # Push geht an Kontakt
  139. $jsonHash = {'type' => 'link', 'email' => $deviceEmail, 'title' => $title, 'url' => $link} if( $deviceEmail );
  140. # Push senden
  141. $decoded = Pushbullet_httpCall($hash,$url{push},$jsonHash,"POST");
  142. return $decoded->{error}{message} if( $decoded->{error} );
  143. # Last Push Date
  144. my ($seconds) = gettimeofday();
  145. $hash->{LAST_PUSH} = FmtDateTime( $seconds );
  146. }
  147. # Liste senden
  148. elsif( $cmd eq "list" ){
  149. return 'Message needet. Correct sytax: set ' . $name . ' list item1[, item2, item3, ... | Titel | Device]' if( @a < 2 );
  150. my @items = split( m/,/, $setValues[0] );
  151. for( my $i=0; $i<=int(@items); $i++){
  152. next if(Pushbullet_trim($items[$i]) eq "");
  153. Log3 $hash, 4, $name . ": $i:" . Pushbullet_trim($items[$i]);
  154. $items[$i] = Pushbullet_trim($items[$i])
  155. }
  156. # Variablen
  157. my ($title, $deviceNick, $deviceIden, $deviceEmail) = "";
  158. my $decoded;
  159. # Argumente überprüfen und auswerten
  160. (undef, $title, $deviceNick, $deviceIden, $deviceEmail) = Pushbullet_checkArgs($hash, $cmd, @setValues);
  161. # Push geht an Device
  162. $jsonHash = {'type' => 'list', 'device_iden' => $deviceIden, 'title' => $title, 'items' => [@items]};
  163. # Push geht an Kontakt
  164. $jsonHash = {'type' => 'list', 'email' => $deviceEmail, 'title' => $title, 'items' => [@items]} if( $deviceEmail );
  165. # Push senden
  166. $decoded = Pushbullet_httpCall($hash,$url{push},$jsonHash,"POST");
  167. return $decoded->{error}{message} if( $decoded->{error} );
  168. # Last Push Date
  169. my ($seconds) = gettimeofday();
  170. $hash->{LAST_PUSH} = FmtDateTime( $seconds );
  171. }
  172. # Device umbenennen
  173. elsif( $cmd eq "deviceRename" ){
  174. return '2 parameter needet. Correct sytax: set ' . $name . ' renameDeviceName oldName | newName' if( @setValues < 2 );
  175. my ($deviceNick, $deviceNickNew, $deviceIden, $deviceEmail) = "";
  176. my $decoded;
  177. # Argumente überprüfen und auswerten
  178. ($deviceNick, $deviceNickNew, undef, $deviceIden, $deviceEmail) = Pushbullet_checkArgs($hash, $cmd, @setValues);
  179. # Device = Device
  180. $jsonHash = {'nickname' => $deviceNickNew};
  181. $urlNew = $url{device} . $deviceIden;
  182. # Device = Kontakt
  183. $jsonHash = {'name' => $deviceNickNew} if( $deviceEmail );
  184. $urlNew = $url{contact} . $deviceIden if( $deviceEmail );
  185. # Device umbenennen
  186. $decoded = Pushbullet_httpCall($hash,$urlNew,$jsonHash,"POST");
  187. return $decoded->{error}{message} if( $decoded->{error});
  188. Pushbullet_clear($hash);
  189. Pushbullet_getDevices($hash);
  190. Pushbullet_getContacts($hash);
  191. }
  192. # Device löschen
  193. elsif( $cmd eq "deviceDelete" ){
  194. $value = $setValues[0];
  195. return '1 parameter needet. Correct sytax: set ' . $name . ' deleteDevice deviceName' if( !$value );
  196. my ($deviceNick, $deviceIden, $deviceEmail) = "";
  197. my $decoded;
  198. # Argumente überprüfen und auswerten
  199. ($deviceNick, undef, undef, $deviceIden, $deviceEmail) = Pushbullet_checkArgs($hash, $cmd, $value);
  200. # Device = Device
  201. $urlNew = $url{device} . $deviceIden;
  202. # Device = Kontakt
  203. $urlNew = $url{contact} . $deviceIden if( $deviceEmail );
  204. # Device löschen
  205. $decoded = Pushbullet_httpCall($hash,$urlNew,undef,"DELETE");
  206. return $decoded->{error}{message} if( $decoded->{error} );
  207. Pushbullet_clear($hash);
  208. Pushbullet_getDevices($hash);
  209. Pushbullet_getContacts($hash);
  210. }
  211. # Kontakt hinzufügen
  212. elsif( $cmd eq "contactAdd" ){
  213. return '2 parameter needet. Correct sytax: set ' . $name . ' contactAdd name | email' if( @a < 3 || @setValues == 1 || @setValues > 2 );
  214. my ($contactName,$contactEmail) = "";
  215. my $decoded;
  216. # Argumente überprüfen und auswerten
  217. ($contactName, $contactEmail, undef, undef, undef) = Pushbullet_checkArgs($hash, $cmd, @setValues);
  218. # Log
  219. Log3 $hash, 4, $name . ": add contact - contact:" . @setValues . " name:" . $contactName . " email:" . $contactEmail;
  220. # Email validation
  221. return "<" .$contactEmail . "> is no valid email." if( $contactEmail !~ /.+\@.+\..+/ );
  222. $jsonHash = {'name', => $contactName, 'email' => $contactEmail};
  223. # Kontakt hinzufügen
  224. $decoded = Pushbullet_httpCall($hash,$url{contactAdd},$jsonHash,"POST");
  225. return $decoded->{error}{message} if( $decoded->{error} );
  226. Pushbullet_clear($hash);
  227. Pushbullet_getDevices($hash);
  228. Pushbullet_getContacts($hash);
  229. }
  230. else {
  231. return "Unknown argument $cmd, choose one of $list";
  232. }
  233. return;
  234. }
  235. sub Pushbullet_Get($@) {
  236. my ($hash, @a) = @_;
  237. my $name = $hash->{NAME};
  238. # Disabled
  239. return undef if( IsDisabled($name) );
  240. return "Need a parameter for get" if(@a < 2);
  241. my $cmd = $a[1];
  242. my $value = $a[2];
  243. my $list = undef;
  244. $list .= " devices:noArg";
  245. if( $cmd eq "devices" ){
  246. Pushbullet_clear($hash);
  247. Pushbullet_getDevices($hash);
  248. Pushbullet_getContacts($hash);
  249. }
  250. else{
  251. return "Unknown argument $cmd, choose one of $list";
  252. }
  253. }
  254. sub Pushbullet_Attr(@) {
  255. return undef;
  256. }
  257. sub Pushbullet_getDevices($){
  258. my ($hash) = @_;
  259. my $name = $hash->{NAME};
  260. my $url;
  261. my $decoded;
  262. my $i = 0;
  263. $url = 'https://' . $hash->{helper}{key} . ':%20@api.pushbullet.com/v2/devices';
  264. $decoded = Pushbullet_httpCall($hash,$url,undef,"GET");
  265. return $decoded->{error}{message} if( $decoded->{error} );
  266. # Last Poll Date
  267. my ($seconds) = gettimeofday();
  268. $hash->{LAST_POLL} = FmtDateTime( $seconds );
  269. for my $d( @{ $decoded->{devices}} ){
  270. next if( !$d->{active} );
  271. if( $d->{nickname} =~ /'|"/ ){
  272. Log3 $hash, 3, "$name: Forbidden character. Please check your device name on pushbullet.com";
  273. next;
  274. }
  275. # Readings updaten
  276. readingsBeginUpdate($hash);
  277. readingsBulkUpdate($hash, $d->{iden} . "_name", $d->{nickname} );
  278. readingsEndUpdate($hash, 1);
  279. $i++;
  280. };
  281. Log3 $hash, 4, "$name: Es wurden $i Endgeraete neu eingelesen.";
  282. return;
  283. }
  284. sub Pushbullet_getContacts($){
  285. my ($hash) = @_;
  286. my $name = $hash->{NAME};
  287. my $url;
  288. my $decoded;
  289. my $i = 0;
  290. $url = 'https://' . $hash->{helper}{key} . ':%20@api.pushbullet.com/v2/contacts';
  291. $decoded = Pushbullet_httpCall($hash,$url,undef,"GET");
  292. return $decoded->{error}{message} if( $decoded->{error} );
  293. for my $c( @{ $decoded->{contacts}} ){
  294. next if( !$c->{active} || !$c->{name} );
  295. if( $c->{name} =~ /'|"/ ){
  296. Log3 $hash, 3, "$name: Forbidden character. Please check your device name on pushbullet.com";
  297. next;
  298. }
  299. # Readings updaten
  300. readingsBeginUpdate($hash);
  301. readingsBulkUpdate($hash, $c->{iden} . "_name", $c->{name} );
  302. readingsBulkUpdate($hash, $c->{iden} . "_email", $c->{email} );
  303. readingsEndUpdate($hash, 1);
  304. $i++;
  305. };
  306. Log3 $hash, 4, "$name: Es wurden $i Kontakte neu eingelesen.";
  307. return;
  308. }
  309. sub Pushbullet_clear($){
  310. my ($hash) = @_;
  311. my $name = $hash->{NAME};
  312. delete $hash->{READINGS};
  313. readingsSingleUpdate($hash, "state", "Initialized", 1);
  314. return undef;
  315. }
  316. sub Pushbullet_getDeviceIden($$){
  317. my ($hash, $deviceNick) = @_;
  318. my $name = $hash->{NAME};
  319. my $deviceIden = undef;
  320. my @deviceIdenSplit;
  321. my ($nkey, $nvalue, $rkey, $rvalue);
  322. $deviceNick = Pushbullet_trim($deviceNick);
  323. return if( !$hash->{READINGS} );
  324. while( ($nkey, $nvalue) = each%{$hash->{READINGS}} ){
  325. while( ($rkey, $rvalue) = each%{$hash->{READINGS}{$nkey}} ){
  326. Log3 $hash, 5, $name . ": nkey:" . $nkey . " nvalue:" . $nvalue . " rkey:" . $rkey . " rvalue:" . $rvalue if( $rvalue eq $deviceNick );
  327. $deviceIden = $nkey if( $rvalue eq $deviceNick );
  328. }
  329. }
  330. if( !$deviceIden ){
  331. Log3 $hash, 3, "$name: Can not read deviceIden from $deviceNick.";
  332. return;
  333. }
  334. @deviceIdenSplit = split( /_name/, $deviceIden );
  335. $deviceIden = $deviceIdenSplit[0];
  336. Log3 $hash, 5, $name . ": deviceIden:".$deviceIden;
  337. return $deviceIden;
  338. }
  339. sub Pushbullet_httpCall($$$$){
  340. my ($hash,$url,$jsonHash,$method) = @_;
  341. my ($json,$err,$data,$decoded);
  342. my $name = $hash->{NAME};
  343. $json = JSON->new->latin1->encode($jsonHash) if( $jsonHash );
  344. ($err,$data) = HttpUtils_BlockingGet({
  345. url => $url,
  346. method => $method,
  347. header => "Content-Type: application/json",
  348. data => $json
  349. });
  350. $json = "" if( !$json );
  351. $data = "" if( !$data );
  352. Log3 $hash, 4, "FHEM -> Pushbullet.com: " . $json;
  353. Log3 $hash, 4, "Pushbullet.com -> FHEM: " . $data;
  354. Log3 $hash, 5, '$err: ' . $err;
  355. Log3 $hash, 5, '$method: ' . $method;
  356. Log3 $hash, 3, "Something gone wrong" if( $data =~ "<!DOCTYPE html>" );
  357. $err = 1 if( $data =~ "<!DOCTYPE html>" );
  358. $decoded = decode_json($data) if( !$err );
  359. return($decoded);
  360. }
  361. sub Pushbullet_trim($)
  362. {
  363. my $string = shift;
  364. $string = "" if( !defined($string) );
  365. #$string =~ s/Â//;
  366. $string =~ s/^\\u00a0//g;
  367. # BUGFIX: Â Zeichen umwandeln. Tritt auf wenn Safari Formular automatisch ausfüllt
  368. #$string =~ s/\s*\|\W/\s\|\s/;
  369. # Leerzeichen am Anfang und am Ende entfernen
  370. $string =~ s/^\s+//;# if( $string =~ m/^\s+/ );
  371. $string =~ s/\s+$//;# if( $string =~ m/\s+$/ );
  372. return $string;
  373. }
  374. sub Pushbullet_checkArgs($$@){
  375. my ($hash, $cmd, @args) = @_;
  376. my $name = $hash->{NAME};
  377. my $argsCount = int(@args);
  378. my ($msg, $title, $deviceNick, $defaultNick, $deviceIden, $deviceEmail) = "";
  379. # Nachricht (cmd = message)
  380. # Link (cmd = link)
  381. # Liste (cmd = list)
  382. # AlterNick (cmd = deviceRename)
  383. # Nick (cmd = devicedDelete || contactAdd)
  384. # Titel (cmd = message || link)
  385. # NeuerNick (cmd = deviceRename)
  386. # undef (cmd = devicedDelete)
  387. # Email (cmd = contactAdd)
  388. $args[1] = "FHEM" if( ( $cmd eq "message" || $cmd eq "link" || $cmd eq "list" ) && $argsCount == 1 );
  389. $args[1] = AttrVal($name, "defaultTitle", undef) if( ( $cmd eq "message" || $cmd eq "link" || $cmd eq "list" ) && $argsCount == 1 && AttrVal($name, "defaultTitle", undef) );
  390. # Default Nick (cmd = message || link)
  391. $defaultNick = AttrVal($name, "defaultDevice", undef) if( ( $cmd eq "message" || $cmd eq "link" || $cmd eq "list" ) && $argsCount < 2 && AttrVal($name, "defaultDevice", undef) );
  392. # Device Nick
  393. $deviceNick = $defaultNick if( ( $cmd eq "message" || $cmd eq "link" || $cmd eq "list" ) && $argsCount < 2 && AttrVal($name, "defaultDevice", undef) );
  394. $deviceNick = $args[2] if( $argsCount > 2);
  395. $deviceNick = $args[0] if( $cmd eq "deviceRename" || $cmd eq "deviceDelete" );
  396. # Device Iden
  397. $deviceIden = Pushbullet_getDeviceIden($hash,$deviceNick) if( defined($deviceNick) );
  398. $deviceIden = "" if( !defined($deviceIden) );
  399. # Device Email
  400. $deviceEmail = ReadingsVal($name, $deviceIden . "_email", undef) if( defined($deviceNick) );
  401. # Warnungen ausblenden
  402. $deviceNick = "" if( !defined($deviceNick) );
  403. $deviceIden = "" if( !defined($deviceIden) );
  404. $deviceEmail = "" if( !defined($deviceEmail) );
  405. $args[1] = "" if( !defined($args[1]) );
  406. # Log
  407. Log3 $hash, 4, $name . "_checkArgs: cmd:" . $cmd . " Args:" . $argsCount . " arg0:" . $args[0] . " arg1:" . $args[1] . " deviceNick:" . $deviceNick . " deviceIden:" . $deviceIden . " email:" . $deviceEmail;
  408. return($args[0], $args[1], $deviceNick, $deviceIden, $deviceEmail);
  409. }
  410. 1;
  411. =pod
  412. =begin html
  413. <a name="Pushbullet"></a>
  414. <h3>Pushbullet</h3>
  415. <ul>
  416. Pushbullet is a service to send instant push notifications to different devices. There are
  417. apps for iPhone, Android, Windows (Beta), Mac OS X and plugins for Chrome Firefox and Safari.<br>
  418. For further information about the service see <a target="_blank" href="https://pushbullet.com">pushbullet.com</a>.<br>
  419. <br>
  420. Discuss the module <a target="_blank" href="http://forum.fhem.de/index.php/topic,29796.0.html">here</a>.<br> <br><br>
  421. <a name="Pushbullet_Define"></a>
  422. <b>Define</b>
  423. <ul>
  424. <code>define &lt;name&gt; Pushbullet &lt;accessToken&gt;</code><br>
  425. <br>
  426. Note:<br>
  427. <ul>
  428. <li>JSON has to be installed on the FHEM host.</li>
  429. <li>Register on pushbullet.com to get your accessToken.</li>
  430. </ul>
  431. </ul><br>
  432. <a name="Pushbullet_Set"></a>
  433. <b>Set</b>
  434. <ul>
  435. <li>clear<br>
  436. clear device readings</li>
  437. <li>contactAdd name | email<br>
  438. adds a contact. Spaces in name are allowed</li>
  439. <li>deviceDelete deviceName<br>
  440. deletes a device</li>
  441. <li>deviceRename deviceName | newDeviceName<br>
  442. renames a device</li>
  443. <li>link [| title | device]<br>
  444. sends a link with optional title and device. If no device is given, push goes to all your devices.</li>
  445. <li>list item1[, item2, item3, ... | title | device]<br>
  446. sends a list with one or more items, optional title and device. If no device is given, push goes to all your devices.</li>
  447. <li>message [| title | device]<br>
  448. sends a push notification with optional title and device. If no device is given, push goes to all your devices.</li>
  449. <br>
  450. Examples:<br>
  451. <ul>
  452. <code>set Pushbullet message This is a message.</code><br>
  453. sends a push notification with message "This is a message" without a title to all <b>your</b> devices.<br><br>
  454. <code>set Pushbullet message This is a message | A title</code><br>
  455. sends a push notification with message "This is a message" and title "A title" to all <b>your</b> devices.<br><br>
  456. <code>set Pushbullet message This is a message | A title | iPhone</code><br>
  457. sends a push notification with message "This is a message" and title "A title" to Device iPhone.<br><br>
  458. <code>set Pushbullet message This is a message | A title | Max Mustermann</code><br>
  459. sends a push notification with message "This is a message" and title "A title" to your contact Max Mustermann.<br>
  460. </ul>
  461. <br>
  462. Note:<br>
  463. Spaces before and after | are not needed.
  464. </ul><br>
  465. <a name="Pushbullet_Get"></a>
  466. <b>Get</b>
  467. <ul>
  468. <li>devices<br>
  469. reads your device list (devices + contacts) and set device readings</li>
  470. </ul><br>
  471. <a name="Pushbullet_Attr"></a>
  472. <b>Attributes</b>
  473. <ul>
  474. <li>defaultDevice<br>
  475. default device for pushmessages</li>
  476. <li>defaultTitle<br>
  477. default title for pushmessages. If it is undefined the defaultTitle will be FHEM</li>
  478. </ul>
  479. </ul>
  480. =end html
  481. =begin html_DE
  482. <a name="Pushbullet"></a>
  483. <h3>Pushbullet</h3>
  484. <ul>
  485. Pushbullet ist ein Dienst, um Benachrichtigungen an unterschiedliche Endgeräte zu senden. Pushbullet
  486. bietet Apps für iPhone, Android, Windows (Beta) und Mac OS X sowie Plugins für Chrome, Firefox und Safari an.<br>
  487. Für weitere Informationen über den Dienst besuche <a target="_blank" href="https://pushbullet.com">pushbullet.com</a>.<br>
  488. <br>
  489. Diskutiere das Modul <a target="_blank" href="http://forum.fhem.de/index.php/topic,29796.0.html">hier</a>.<br>
  490. <br><br>
  491. <a name="Pushbullet_Define"></a>
  492. <b>Define</b>
  493. <ul>
  494. <code>define &lt;name&gt; Pushbullet &lt;accessToken&gt;</code><br>
  495. <br>
  496. Notiz:<br>
  497. JSON muss auf dem FHEM Host installiert sein.<br><br>
  498. Registriere dich auf pushbullet.com um deine accessToken zu bekommen.<br>
  499. </ul><br>
  500. <a name="Pushbullet_Set"></a>
  501. <b>Set</b>
  502. <ul>
  503. <li>clear<br>
  504. Löscht alle Device Readings</li>
  505. <li>contactAdd name | email<br>
  506. Fügt einen neuen Kontakt hinzu. Leerzeichen im Namen sind erlaubt.</li>
  507. <li>deviceDelete deviceName<br>
  508. Löscht das Device.</li>
  509. <li>deviceRename deviceName | neuerDeviceName<br>
  510. Benennt das Device um.</li>
  511. <li>link [| Titel | Device]<br>
  512. Sendet einen Link mit optionalen Titel und Device. Wenn kein Device angegeben ist, geht der Push an alle deine Devices.</li>
  513. <li>list Item1[, Item2, Item3, ... | Titel | Device]<br>
  514. Sendet eine Liste mit einem oder mehreren Items, optionalen Titel und Device. Wenn kein Device angegeben ist, geht der Push an alle deine Devices.</li>
  515. <li>message [| Titel | Device]<br>
  516. Sendet eine Nachricht mit optionalen Titel und Device. Wenn kein Device angegeben ist, geht der Push an alle deine Devices.</li>
  517. <br>
  518. Beispiele:<br>
  519. <ul>
  520. <code>set Pushbullet message Das ist eine Nachricht</code><br>
  521. Sendet eine Push Benachrichtigung mit der Nachricht "Das ist eine Nachricht" ohne vorbestimmten Titel an alle <b>deine</b> Devices.<br><br>
  522. <code>set Pushbullet message Das ist eine Nachricht | Ein Titel</code><br>
  523. Sendet eine Push Benachrichtigung mit der Nachricht "Das ist eine Nachricht" mit dem Titel "Ein Titel" an alle <b>deine</b> Devices.<br><br>
  524. <code>set Pushbullet message This is a message | Ein Titel | iPhone</code><br>
  525. Sendet eine Push Benachrichtigung mit der Nachricht "Das ist eine Nachricht" mit dem Titel "Ein Titel" an deinen Device iPhone.<br><br>
  526. <code>set Pushbullet message This is a message | Ein Titel | Max Mustermann</code><br>
  527. Sendet eine Push Benachrichtigung mit der Nachricht "Das ist eine Nachricht" mit dem Titel "Ein Titel" an deinen Kontakt Max Mustermann.<br><br>
  528. </ul>
  529. <br>
  530. Notiz:<br>
  531. Leerstellen vor und nach dem Trenner | werden nicht benötigt.
  532. </ul><br>
  533. <a name="Pushbullet_Get"></a>
  534. <b>Get</b>
  535. <ul>
  536. <li>devices<br>
  537. Liest alle Geräte und Kontakte ein und setzt die entsprechenden Readings.</li>
  538. </ul><br>
  539. <a name="Pushbullet_Attr"></a>
  540. <b>Attributes</b>
  541. <ul>
  542. <li>defaultDevice<br>
  543. Standart Device für Pushnachrichten.</li>
  544. <li>defaultTitle<br>
  545. Standart Titel für Pushnachrichten. Wenn nicht gesetzt ist der Standart Titel FHEM</li>
  546. </ul>
  547. </ul>
  548. =end html_DE
  549. =cut