Removed dependencies to SSL, HTTP and UserAgent stuff. Added two readings for last message and last result.
git-svn-id: https://svn.fhem.de/fhem/trunk@4653 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -32,8 +32,7 @@
|
|||||||
|
|
||||||
package main;
|
package main;
|
||||||
|
|
||||||
use HTTP::Request;
|
use HttpUtils;
|
||||||
use LWP::UserAgent;
|
|
||||||
use utf8;
|
use utf8;
|
||||||
|
|
||||||
my %sets = (
|
my %sets = (
|
||||||
@@ -205,7 +204,14 @@ sub Pushover_Set_Message
|
|||||||
$body = $body . "&" . "timestamp=" . time();
|
$body = $body . "&" . "timestamp=" . time();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Pushover_HTTP_Call($hash, $body);
|
my $result = Pushover_HTTP_Call($hash, $body);
|
||||||
|
|
||||||
|
readingsBeginUpdate($hash);
|
||||||
|
readingsBulkUpdate($hash, "last-message", $title . ": " . $message);
|
||||||
|
readingsBulkUpdate($hash, "last-result", $result);
|
||||||
|
readingsEndUpdate($hash, 1);
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -217,28 +223,28 @@ sub Pushover_HTTP_Call($$)
|
|||||||
{
|
{
|
||||||
my ($hash,$body) = @_;
|
my ($hash,$body) = @_;
|
||||||
|
|
||||||
my $client = LWP::UserAgent->new();
|
my $url = "https://api.pushover.net/1/messages.json";
|
||||||
|
|
||||||
my $req = HTTP::Request->new(POST => "https://api.pushover.net/1/messages.json");
|
$response = GetFileFromURL($url, 10, $body, 0, 5);
|
||||||
$req->header('Content-Type' => 'application/x-www-form-urlencoded');
|
|
||||||
$req->content($body);
|
|
||||||
|
|
||||||
my $response = $client->request($req);
|
if ($response =~ m/"status":(.*),/)
|
||||||
|
|
||||||
if($response)
|
|
||||||
{
|
{
|
||||||
if ($response->is_error)
|
if ($1 eq "1")
|
||||||
{
|
|
||||||
return "Error: " . $response->status_line;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
return "OK";
|
return "OK";
|
||||||
}
|
}
|
||||||
|
elsif ($response =~ m/"errors":\[(.*)\]/)
|
||||||
|
{
|
||||||
|
return "Error: " . $1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return "Status: " . $response->status_line;
|
return "Error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "Error: No known response"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,15 +261,6 @@ sub Pushover_HTTP_Call($$)
|
|||||||
You need an account to use this module.<br>
|
You need an account to use this module.<br>
|
||||||
For further information about the service see <a href="https://pushover.net">pushover.net</a>.<br>
|
For further information about the service see <a href="https://pushover.net">pushover.net</a>.<br>
|
||||||
<br>
|
<br>
|
||||||
You have to install these modules:<br>
|
|
||||||
<ul>
|
|
||||||
<li>IO::Socket::SSL</li>
|
|
||||||
<li>Mozilla::CA</li>
|
|
||||||
<li>LWP::Protocol::https</li>
|
|
||||||
</ul>
|
|
||||||
<br>
|
|
||||||
Use 'cpan -i *module-name*' to install them.<br>
|
|
||||||
For instructions on QNAP see <a href="http://forum.fhem.de/index.php/topic,17297.msg119096.html#msg119096">this thread</a>.<br>
|
|
||||||
Discuss the module <a href="http://forum.fhem.de/index.php/topic,16215.0.html">here</a>.<br>
|
Discuss the module <a href="http://forum.fhem.de/index.php/topic,16215.0.html">here</a>.<br>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
@@ -334,15 +331,6 @@ sub Pushover_HTTP_Call($$)
|
|||||||
Du brauchst einen Account um dieses Modul zu verwenden.<br>
|
Du brauchst einen Account um dieses Modul zu verwenden.<br>
|
||||||
Für weitere Informationen über den Dienst besuche <a href="https://pushover.net">pushover.net</a>.<br>
|
Für weitere Informationen über den Dienst besuche <a href="https://pushover.net">pushover.net</a>.<br>
|
||||||
<br>
|
<br>
|
||||||
Du musst diese Module installieren:<br>
|
|
||||||
<ul>
|
|
||||||
<li>IO::Socket::SSL</li>
|
|
||||||
<li>Mozilla::CA</li>
|
|
||||||
<li>LWP::Protocol::https</li>
|
|
||||||
</ul>
|
|
||||||
<br>
|
|
||||||
Verwende 'cpan -i *module-name*' um sie zu installieren.<br>
|
|
||||||
Für Installationsschritte auf einem QNAP-Gerät besuche <a href="http://forum.fhem.de/index.php/topic,17297.msg119096.html#msg119096">diesen Thread</a>.<br>
|
|
||||||
Diskutiere das Modul <a href="http://forum.fhem.de/index.php/topic,16215.0.html">hier</a>.<br>
|
Diskutiere das Modul <a href="http://forum.fhem.de/index.php/topic,16215.0.html">hier</a>.<br>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
Reference in New Issue
Block a user