mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
74_Unifi.pm:fixed blockClient
git-svn-id: https://svn.fhem.de/fhem/trunk@15930 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
fb4f285e7d
commit
065b27c358
@ -1,5 +1,6 @@
|
||||
# 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.
|
||||
- bugfix: 74_Unifi: fixed blockClient
|
||||
- bugfix: 98_dewpoint.pm: Fix event processing when updating STATE
|
||||
- bugfix: 73_ElectricityCalculator.pm: Spelling error
|
||||
- change: 74_XiaomiBTLESens: Code clean
|
||||
|
@ -8,6 +8,8 @@
|
||||
# enable/disable WLAN, new client-Reading essid
|
||||
# V2.1
|
||||
# - feature: 74_Unifi: add new set command to en-/disable Site Status-LEDs
|
||||
# V2.1.1
|
||||
# - bugfix: 74_Unifi: fixed blockClient
|
||||
|
||||
|
||||
package main;
|
||||
@ -1121,6 +1123,52 @@ sub Unifi_DisconnectClient_Receive($) {
|
||||
|
||||
return undef;
|
||||
}
|
||||
###############################################################################
|
||||
sub Unifi_BlockClient_Send($@) {
|
||||
my ($hash,@clients) = @_;
|
||||
my ($name,$self) = ($hash->{NAME},Unifi_Whoami());
|
||||
Log3 $name, 5, "$name ($self) - executed with count:'".scalar(@clients)."', ID:'".$clients[0]."'";
|
||||
my $id = shift @clients;
|
||||
HttpUtils_NonblockingGet( {
|
||||
%{$hash->{httpParams}},
|
||||
url => $hash->{unifi}->{url}."cmd/stamgr",
|
||||
callback => \&Unifi_BlockClient_Receive,
|
||||
clients => [@clients],
|
||||
data => "{'mac': '".$hash->{clients}->{$id}->{mac}."', 'cmd': 'block-sta'}",
|
||||
} );
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
sub Unifi_BlockClient_Receive($) {
|
||||
my ($param, $err, $data) = @_;
|
||||
my ($name,$self,$hash) = ($param->{hash}->{NAME},Unifi_Whoami(),$param->{hash});
|
||||
Log3 $name, 5, "$name ($self) - executed.";
|
||||
|
||||
if ($err ne "") {
|
||||
Unifi_ReceiveFailure($hash,{rc => 'Error while requesting', msg => $param->{url}." - $err"});
|
||||
}
|
||||
elsif ($data ne "") {
|
||||
if ($param->{code} == 200 || $param->{code} == 400 || $param->{code} == 401) {
|
||||
eval { $data = decode_json($data); 1; } or do { $data = { meta => {rc => 'error.decode_json', msg => $@} }; };
|
||||
|
||||
if ($data->{meta}->{rc} eq "ok") {
|
||||
Log3 $name, 5, "$name ($self) - state:'$data->{meta}->{rc}'";
|
||||
}
|
||||
else { Unifi_ReceiveFailure($hash,$data->{meta}); }
|
||||
} else {
|
||||
Unifi_ReceiveFailure($hash,{rc => $param->{code}, msg => "Failed with HTTP Code $param->{code}."});
|
||||
}
|
||||
}
|
||||
|
||||
if (scalar @{$param->{clients}}) {
|
||||
Unifi_BlockClient_Send($hash,@{$param->{clients}});
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
sub Unifi_UnblockClient_Send($@) {
|
||||
my ($hash,@clients) = @_;
|
||||
@ -1161,7 +1209,7 @@ sub Unifi_UnblockClient_Receive($) {
|
||||
}
|
||||
|
||||
if (scalar @{$param->{clients}}) {
|
||||
Unifi_BlockClient_Send($hash,@{$param->{clients}});
|
||||
Unifi_UnblockClient_Send($hash,@{$param->{clients}});
|
||||
}
|
||||
|
||||
return undef;
|
||||
|
Loading…
Reference in New Issue
Block a user