mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
70_PushNotifier: use regexe for deviceID
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@9211 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
cd25e5f169
commit
db7db4e96e
1
CHANGED
1
CHANGED
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||||
# Do not insert empty lines here, update check depends on it.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- feature: 70_PushNotifier: use regexe for deviceID
|
||||||
- bugfix: 30_pilight_temp: pressure, windavg, winddir, windgust from weather stations without temperature
|
- bugfix: 30_pilight_temp: pressure, windavg, winddir, windgust from weather stations without temperature
|
||||||
- feature: 74_Unifi: - new readings for controller, accesspoints and clients
|
- feature: 74_Unifi: - new readings for controller, accesspoints and clients
|
||||||
- new Setter: archiveAlerts, disconnectClient, restartAP
|
- new Setter: archiveAlerts, disconnectClient, restartAP
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
###############################################
|
###############################################
|
||||||
#$Id: 70_PushNotifier.pm 2014-12-16 17:00:00 xusader
|
#$Id: 70_PushNotifier.pm 2015-09-07 12:24:00 xusader
|
||||||
#
|
#
|
||||||
# download client-app http://pushnotifier.de/apps/
|
# download client-app http://pushnotifier.de/apps/
|
||||||
# create account http://pushnotifier.de/login/
|
# create account http://pushnotifier.de/login/
|
||||||
@ -57,18 +57,11 @@ PushNotifier_Define($$)
|
|||||||
['apiToken' => $apiToken,
|
['apiToken' => $apiToken,
|
||||||
'appToken' => $appToken]);
|
'appToken' => $appToken]);
|
||||||
my $strg_chkID = $responseID->as_string;
|
my $strg_chkID = $responseID->as_string;
|
||||||
$strg_chkID =~ s/[-"{}_]//g;
|
|
||||||
|
|
||||||
$re1='.*?';
|
$strg_chkID =~ /\[(.*),(.*)\]/;
|
||||||
$re2='(\\[.*?\\])';
|
my $devIDs = $1;
|
||||||
|
$devIDs =~ s/[-"{}_]//g;
|
||||||
$re=$re1.$re2;
|
$hash->{devices} = $devIDs;
|
||||||
if ($strg_chkID =~ m/$re/is)
|
|
||||||
{
|
|
||||||
$sbraces1=$1;
|
|
||||||
my $devices = $sbraces1;
|
|
||||||
$hash->{devices} = $devices;
|
|
||||||
}
|
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -93,24 +86,35 @@ PushNotifier_Send_Message
|
|||||||
my $msg = join(" ", @_);
|
my $msg = join(" ", @_);
|
||||||
$msg =~ s/\_/\n/g;
|
$msg =~ s/\_/\n/g;
|
||||||
|
|
||||||
|
my $result="";
|
||||||
|
|
||||||
|
while ($hash->{devices} =~ /title:([^,.]+),id:(\d+),model:([^,^\].]+)/g) {
|
||||||
|
my ($nd_title, $nd_id, $nd_model) = ("$1", "$2", "$3");
|
||||||
|
|
||||||
|
# Log3 (undef, 3, "PushNotifier: Send Message $msg to device title: $nd_title, id: $nd_id, model: $nd_model");
|
||||||
|
|
||||||
|
if ( $nd_id =~ m/$hash->{deviceID}/ || $nd_title =~ m/$hash->{deviceID}/ || $nd_model =~ m/$hash->{deviceID}/ ) {
|
||||||
my $response = LWP::UserAgent->new()->post('http://a.pushnotifier.de/1/sendToDevice',
|
my $response = LWP::UserAgent->new()->post('http://a.pushnotifier.de/1/sendToDevice',
|
||||||
['apiToken' => $hash->{apiToken},
|
['apiToken' => $hash->{apiToken},
|
||||||
'appToken' => $hash->{appToken},
|
'appToken' => $hash->{appToken},
|
||||||
'app' => $hash->{app},
|
'app' => $hash->{app},
|
||||||
'deviceID' => $hash->{deviceID},
|
'deviceID' => $nd_id,
|
||||||
'type' => 'MESSAGE',
|
'type' => 'MESSAGE',
|
||||||
'content' => "$msg"]);
|
'content' => "$msg"]);
|
||||||
|
|
||||||
my $error_chk = $response->as_string;
|
my $error_chk = $response->as_string;
|
||||||
|
|
||||||
if($error_chk =~ m/"status":"ok"/) {
|
if($error_chk =~ m/"status":"ok"/) {
|
||||||
return "OK!\n\n$msg";
|
$result.="OK! Message sent to $nd_title (id: $nd_id)\n\n$msg\n\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $error_chk;
|
$result.="ERROR sending message to $nd_title (id: $nd_id)\n\nResponse:\n$error_chk\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
@ -176,7 +180,7 @@ PushNotifier_Send_Message
|
|||||||
PushNotifier ist ein Dienst, um Benachrichtigungen von einer vielzahl
|
PushNotifier ist ein Dienst, um Benachrichtigungen von einer vielzahl
|
||||||
von Quellen auf Deinem Smartphone oder Tablet zu empfangen.<br>
|
von Quellen auf Deinem Smartphone oder Tablet zu empfangen.<br>
|
||||||
Du brauchst einen Account um dieses Modul zu verwenden.<br>
|
Du brauchst einen Account um dieses Modul zu verwenden.<br>
|
||||||
Für weitere Informationen besuche <a href="http://www.fhemwiki.de/wiki/PushNotifier">FhemWiki PushNotifier</a>.<br>
|
F<EFBFBD><EFBFBD>r weitere Informationen besuche <a href="http://www.fhemwiki.de/wiki/PushNotifier">FhemWiki PushNotifier</a>.<br>
|
||||||
<br>
|
<br>
|
||||||
Diskutiere das Modul <a href="http://forum.fhem.de/index.php/topic,25440.0.html">hier</a>.<br>
|
Diskutiere das Modul <a href="http://forum.fhem.de/index.php/topic,25440.0.html">hier</a>.<br>
|
||||||
<br>
|
<br>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user