mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-29 17:37:09 +00:00
70_Pushover: fix callback (Forum #16215.msg608475)
git-svn-id: https://svn.fhem.de/fhem/trunk@13747 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
fb24317cf3
commit
0687220eef
@ -247,7 +247,14 @@ sub Pushover_SendCommand($$;$\%) {
|
|||||||
cmd => $cmd,
|
cmd => $cmd,
|
||||||
type => $type,
|
type => $type,
|
||||||
httpversion => "1.1",
|
httpversion => "1.1",
|
||||||
callback => \&Pushover_ReceiveCommand,
|
header => {
|
||||||
|
Agent => 'FHEM-Pushover/1.0.0',
|
||||||
|
'User-Agent' => 'FHEM-Pushover/1.0.0',
|
||||||
|
'Content-Type' => 'application/x-www-form-urlencoded',
|
||||||
|
Accept => 'application/json;charset=UTF-8',
|
||||||
|
'Accept-Charset' => 'UTF-8',
|
||||||
|
},
|
||||||
|
callback => \&Pushover_ReceiveCommand,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -265,15 +272,23 @@ sub Pushover_SendCommand($$;$\%) {
|
|||||||
|
|
||||||
HttpUtils_NonblockingGet(
|
HttpUtils_NonblockingGet(
|
||||||
{
|
{
|
||||||
url => $URL,
|
url => $URL,
|
||||||
timeout => $timeout,
|
timeout => $timeout,
|
||||||
noshutdown => $http_noshutdown,
|
noshutdown => $http_noshutdown,
|
||||||
data => $cmd,
|
data => $cmd,
|
||||||
hash => $hash,
|
hash => $hash,
|
||||||
service => $service,
|
service => $service,
|
||||||
cmd => $cmd,
|
cmd => $cmd,
|
||||||
type => $type,
|
type => $type,
|
||||||
callback => \&Pushover_ReceiveCommand,
|
httpversion => "1.1",
|
||||||
|
header => {
|
||||||
|
Agent => 'FHEM-Pushover/1.0.0',
|
||||||
|
'User-Agent' => 'FHEM-Pushover/1.0.0',
|
||||||
|
'Content-Type' => 'application/x-www-form-urlencoded',
|
||||||
|
Accept => 'application/json;charset=UTF-8',
|
||||||
|
'Accept-Charset' => 'UTF-8',
|
||||||
|
},
|
||||||
|
callback => \&Pushover_ReceiveCommand,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1352,7 +1367,7 @@ sub Pushover_CGI() {
|
|||||||
|
|
||||||
my $webArgs;
|
my $webArgs;
|
||||||
my $receipt = "";
|
my $receipt = "";
|
||||||
my $revReadings;
|
my %revReadings;
|
||||||
|
|
||||||
# extract values from URI
|
# extract values from URI
|
||||||
foreach my $pv ( split( "&", $URI ) ) {
|
foreach my $pv ( split( "&", $URI ) ) {
|
||||||
@ -1376,21 +1391,18 @@ sub Pushover_CGI() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# search for existing receipt
|
# search for existing receipt
|
||||||
while ( ( $key, $value ) = each %{ $hash->{READINGS} } ) {
|
keys %{ $hash->{READINGS} };
|
||||||
if ( $key =~ /^cb_\d+$/ ) {
|
while ( my ( $key, $value ) = each %{ $hash->{READINGS} } ) {
|
||||||
my $val = $value->{VAL};
|
$revReadings{ $value->{VAL} } = $1
|
||||||
$revReadings{$val} = $key;
|
if ( defined( $value->{VAL} ) && $key =~ /^cb_(\d+)$/ );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( defined( $revReadings{$receipt} ) ) {
|
if ( defined( $revReadings{$receipt} ) ) {
|
||||||
my $r = $revReadings{$receipt};
|
my $rAct = "cbAct_" . $revReadings{$receipt};
|
||||||
my @rBase = split( "_", $r );
|
my $rAck = "cbAck_" . $revReadings{$receipt};
|
||||||
my $rAct = "cbAct_" . $rBase[1];
|
my $rAckAt = "cbAckAt_" . $revReadings{$receipt};
|
||||||
my $rAck = "cbAck_" . $rBase[1];
|
my $rAckBy = "cbAckBy_" . $revReadings{$receipt};
|
||||||
my $rAckAt = "cbAckAt_" . $rBase[1];
|
my $rDev = "cbDev_" . $revReadings{$receipt};
|
||||||
my $rAckBy = "cbAckBy_" . $rBase[1];
|
|
||||||
my $rDev = "cbDev_" . $rBase[1];
|
|
||||||
|
|
||||||
return ( "text/plain; charset=utf-8",
|
return ( "text/plain; charset=utf-8",
|
||||||
"NOK " . $receipt . ": invalid argument 'acknowledged'" )
|
"NOK " . $receipt . ": invalid argument 'acknowledged'" )
|
||||||
@ -1402,12 +1414,8 @@ sub Pushover_CGI() {
|
|||||||
if ( !defined( $webArgs->{acknowledged_by} )
|
if ( !defined( $webArgs->{acknowledged_by} )
|
||||||
|| $webArgs->{acknowledged_by} ne $hash->{USER_KEY} );
|
|| $webArgs->{acknowledged_by} ne $hash->{USER_KEY} );
|
||||||
|
|
||||||
return ( "text/plain; charset=utf-8",
|
if ( ReadingsVal( $name, $rAck, "1" ) eq "0"
|
||||||
"NOK " . $receipt . ": receipt does not exist" )
|
&& $revReadings{$receipt} > int( time() ) )
|
||||||
if ( ReadingsVal( $name, $rAck, "N/A" ) eq "N/A" );
|
|
||||||
|
|
||||||
if ( ReadingsVal( $name, $rAck, 1 ) == 0
|
|
||||||
&& $rBase[1] > int( time() ) )
|
|
||||||
{
|
{
|
||||||
readingsBeginUpdate($hash);
|
readingsBeginUpdate($hash);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user