mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 09:16:53 +00:00
74_Unifi: new setter to start RF-Scan
git-svn-id: https://svn.fhem.de/fhem/trunk@19989 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
fadc2cee53
commit
fc1b1afa76
@ -71,10 +71,14 @@
|
|||||||
# - fixed: 74_Unifi: fixed restore clients at fhem restart
|
# - fixed: 74_Unifi: fixed restore clients at fhem restart
|
||||||
# V 3.3.3
|
# V 3.3.3
|
||||||
# - fixed: 74_Unifi: fixed (un)blockClient for UC Version 5.10.24
|
# - fixed: 74_Unifi: fixed (un)blockClient for UC Version 5.10.24
|
||||||
|
# V 3.3.4
|
||||||
|
# - fixed: 74_Unifi: fixed AP-Readingnames (use makeReadingName())
|
||||||
|
# V 3.4.0
|
||||||
|
# - feature: 74_Unifi: new setter to start RF-Scan
|
||||||
|
|
||||||
|
|
||||||
package main;
|
package main;
|
||||||
my $version="3.3.3";
|
my $version="3.4.0";
|
||||||
# Default für clientReadings setzen. Die Readings waren der Standard vor Einführung des Attributes customClientReadings.
|
# Default für clientReadings setzen. Die Readings waren der Standard vor Einführung des Attributes customClientReadings.
|
||||||
# Eine Änderung hat Auswirkungen auf (alte) Moduldefinitionen ohne dieses Attribut.
|
# Eine Änderung hat Auswirkungen auf (alte) Moduldefinitionen ohne dieses Attribut.
|
||||||
my $defaultClientReadings=".:^accesspoint|^essid|^hostname|^last_seen|^snr|^uptime"; #ist wegen snr vs rssi nur halb korrekt, wird aber auch nicht wirklich verwendet ;-)
|
my $defaultClientReadings=".:^accesspoint|^essid|^hostname|^last_seen|^snr|^uptime"; #ist wegen snr vs rssi nur halb korrekt, wird aber auch nicht wirklich verwendet ;-)
|
||||||
@ -347,14 +351,26 @@ sub Unifi_Set($@) {
|
|||||||
$disconnectedClientNames =~ s/.$//;
|
$disconnectedClientNames =~ s/.$//;
|
||||||
|
|
||||||
#my $clientNames = Unifi_ClientNames($hash);
|
#my $clientNames = Unifi_ClientNames($hash);
|
||||||
my $apNames = Unifi_ApNames($hash);
|
my $apNames = Unifi_ApNames($hash); # TODO: $apNames in $deviceNames umbenennen
|
||||||
my $SSIDs = Unifi_SSIDs($hash);
|
my $SSIDs = Unifi_SSIDs($hash);
|
||||||
|
|
||||||
if($setName !~ /archiveAlerts|restartAP|setLocateAP|unsetLocateAP|disconnectClient|update|updateClient|clear|blockClient|unblockClient|enableWLAN|disableWLAN|switchSiteLEDs|createVoucher|removeClientReadings|refreshUsergroups/) {
|
my $aps = '';
|
||||||
|
for my $apID (keys %{$hash->{accespoints}}) {
|
||||||
|
my $apName=Unifi_ApNames($hash,$apID,'makeName');
|
||||||
|
my $essid_Reading=ReadingsVal($name, '-AP_'.$apName.'_essid', undef);
|
||||||
|
my $has_essid=0;
|
||||||
|
$has_essid=1 if(defined $essid_Reading && $essid_Reading ne 'none');
|
||||||
|
if ($has_essid){
|
||||||
|
$aps .= $apName.',';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$aps =~ s/.$//;
|
||||||
|
|
||||||
|
if($setName !~ /archiveAlerts|restartAP|setLocateAP|unsetLocateAP|startRFScan|disconnectClient|update|updateClient|clear|blockClient|unblockClient|enableWLAN|disableWLAN|switchSiteLEDs|createVoucher|removeClientReadings|refreshUsergroups/) {
|
||||||
return "Unknown argument $setName, choose one of update:noArg "
|
return "Unknown argument $setName, choose one of update:noArg "
|
||||||
."clear:all,readings,clientData,allData,voucherCache "
|
."clear:all,readings,clientData,allData,voucherCache "
|
||||||
.((defined $hash->{alerts_unarchived}[0] && scalar @{$hash->{alerts_unarchived}}) ? "archiveAlerts:noArg " : "")
|
.((defined $hash->{alerts_unarchived}[0] && scalar @{$hash->{alerts_unarchived}}) ? "archiveAlerts:noArg " : "")
|
||||||
.(($apNames && Unifi_CONNECTED($hash)) ? "restartAP:all,$apNames setLocateAP:all,$apNames unsetLocateAP:all,$apNames " : "")
|
.(($apNames && Unifi_CONNECTED($hash)) ? "restartAP:all,$apNames setLocateAP:all,$apNames unsetLocateAP:all,$apNames startRFScan:$aps " : "")
|
||||||
.(($connectedClientNames && Unifi_CONNECTED($hash)) ? "disconnectClient:all,$connectedClientNames " : "")
|
.(($connectedClientNames && Unifi_CONNECTED($hash)) ? "disconnectClient:all,$connectedClientNames " : "")
|
||||||
.(($disconnectedClientNames && Unifi_CONNECTED($hash)) ? "removeClientReadings:$disconnectedClientNames " : "")
|
.(($disconnectedClientNames && Unifi_CONNECTED($hash)) ? "removeClientReadings:$disconnectedClientNames " : "")
|
||||||
.(($unblockedClientNames && Unifi_CONNECTED($hash)) ? "blockClient:$unblockedClientNames " : "")
|
.(($unblockedClientNames && Unifi_CONNECTED($hash)) ? "blockClient:$unblockedClientNames " : "")
|
||||||
@ -490,6 +506,15 @@ sub Unifi_Set($@) {
|
|||||||
Unifi_ApCmd_Send($hash,'unset-locate',keys(%{$hash->{accespoints}}));
|
Unifi_ApCmd_Send($hash,'unset-locate',keys(%{$hash->{accespoints}}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elsif ($setName eq 'startRFScan') {
|
||||||
|
$setVal = Unifi_ApNames($hash,$setVal,'makeID');
|
||||||
|
if (defined $hash->{accespoints}->{$setVal}) {
|
||||||
|
Unifi_ApCmd_Send($hash,'spectrum-scan',$setVal);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "$hash->{NAME}: Unknown accesspoint '$setVal' in command '$setName', choose one of: $aps";
|
||||||
|
}
|
||||||
|
}
|
||||||
elsif ($setName eq 'removeClientReadings') {
|
elsif ($setName eq 'removeClientReadings') {
|
||||||
if($setVal && $setVal ne ""){
|
if($setVal && $setVal ne ""){
|
||||||
my $id = Unifi_ClientNames($hash,$setVal,'makeID');
|
my $id = Unifi_ClientNames($hash,$setVal,'makeID');
|
||||||
@ -1381,7 +1406,8 @@ sub Unifi_GetEvents_Receive($) {
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
###############################################################################
|
###############################################################################
|
||||||
sub Unifi_GetAccesspoints_Send($) {
|
sub Unifi_GetAccesspoints_Send($) { # TODO Umbenennen in Unifi_GetDevices_Send. Dann muss man auch an Get_ApNames() ran, da dort nicht nur APs sondern auch usg und switch drin sind.
|
||||||
|
# Waren wohl früher in Version 1 des Moduls nur APs unter devices
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
my ($name,$self) = ($hash->{NAME},Unifi_Whoami());
|
my ($name,$self) = ($hash->{NAME},Unifi_Whoami());
|
||||||
Log3 $name, 5, "$name ($self) - executed.";
|
Log3 $name, 5, "$name ($self) - executed.";
|
||||||
@ -1394,7 +1420,7 @@ sub Unifi_GetAccesspoints_Send($) {
|
|||||||
} );
|
} );
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
sub Unifi_GetAccesspoints_Receive($) {
|
sub Unifi_GetAccesspoints_Receive($) {# TODO Umbenennen in Unifi_GetDevices_Receive
|
||||||
my ($param, $err, $data) = @_;
|
my ($param, $err, $data) = @_;
|
||||||
my ($name,$self,$hash) = ($param->{hash}->{NAME},Unifi_Whoami(),$param->{hash});
|
my ($name,$self,$hash) = ($param->{hash}->{NAME},Unifi_Whoami(),$param->{hash});
|
||||||
Log3 $name, 5, "$name ($self) - executed.";
|
Log3 $name, 5, "$name ($self) - executed.";
|
||||||
@ -2038,7 +2064,7 @@ sub Unifi_CreateVoucher_Receive($) {
|
|||||||
}
|
}
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
sub Unifi_ApCmd_Send($$@) { #cmd: 'set-locate', 'unset-locate', 'restart'
|
sub Unifi_ApCmd_Send($$@) { #cmd: 'set-locate', 'unset-locate', 'restart', 'startRFScan'
|
||||||
my ($hash,$cmd,@aps) = @_;
|
my ($hash,$cmd,@aps) = @_;
|
||||||
my ($name,$self) = ($hash->{NAME},Unifi_Whoami());
|
my ($name,$self) = ($hash->{NAME},Unifi_Whoami());
|
||||||
Log3 $name, 5, "$name ($self) - executed with cmd:'".$cmd."', count:'".scalar(@aps)."', ID:'".$aps[0]."'";
|
Log3 $name, 5, "$name ($self) - executed with cmd:'".$cmd."', count:'".scalar(@aps)."', ID:'".$aps[0]."'";
|
||||||
@ -2668,6 +2694,9 @@ Or you can use the other readings or set and get features to control your unifi-
|
|||||||
<li><code>set <name> unsetLocateAP <all|_id|name|ip></code><br>
|
<li><code>set <name> unsetLocateAP <all|_id|name|ip></code><br>
|
||||||
Stop 'locate' on one or all accesspoints. </li>
|
Stop 'locate' on one or all accesspoints. </li>
|
||||||
<br>
|
<br>
|
||||||
|
<li><code>set <name> startRFScan <all|_id|name|ip></code><br>
|
||||||
|
Start 'RF-Scan' on one or all accesspoints. Does not work with 1. Gen APs. </li>
|
||||||
|
<br>
|
||||||
<li><code>set <name> blockClient <clientname></code><br>
|
<li><code>set <name> blockClient <clientname></code><br>
|
||||||
Block the <clientname>. Can also be called with the mac-address of the client.</li>
|
Block the <clientname>. Can also be called with the mac-address of the client.</li>
|
||||||
<br>
|
<br>
|
||||||
|
@ -264,8 +264,8 @@ sub UnifiClient_Parse($$) {
|
|||||||
$hash->{MODEL}=$clientRef->{oui};
|
$hash->{MODEL}=$clientRef->{oui};
|
||||||
|
|
||||||
my $old_tx=ReadingsVal($hash->{NAME},"tx_bytes",undef);
|
my $old_tx=ReadingsVal($hash->{NAME},"tx_bytes",undef);
|
||||||
my $seconds=ReadingsAge($hash->{NAME},"tx_bytes",1);
|
my $seconds=ReadingsAge($hash->{NAME},"tx_bytes",0);
|
||||||
$seconds=0.1 if ($seconds eq 0 || ! defined $seconds);
|
$seconds=0.1 if (! defined $seconds || $seconds < 0.1);
|
||||||
my $tx_used=0;
|
my $tx_used=0;
|
||||||
if (defined $old_tx && defined $clientRef->{tx_bytes}){
|
if (defined $old_tx && defined $clientRef->{tx_bytes}){
|
||||||
$tx_used=($clientRef->{tx_bytes})-($old_tx);
|
$tx_used=($clientRef->{tx_bytes})-($old_tx);
|
||||||
|
@ -23,12 +23,14 @@
|
|||||||
# - bugfix: 74_UnififSwitch: fixed poe restart
|
# - bugfix: 74_UnififSwitch: fixed poe restart
|
||||||
# V 0.0.94
|
# V 0.0.94
|
||||||
# - feature: 74_UnififSwitch: supports new module UnifiClient
|
# - feature: 74_UnififSwitch: supports new module UnifiClient
|
||||||
|
# V 0.0.95
|
||||||
|
# - feature: 74_UnififSwitch: supports disablePort
|
||||||
#
|
#
|
||||||
# TODOs:
|
# TODOs:
|
||||||
# - state des USW für weiter state-Numbers korrekt in Worte übersetzen
|
# - state des USW für weiter state-Numbers korrekt in Worte übersetzen
|
||||||
|
|
||||||
package main;
|
package main;
|
||||||
my $version="0.0.94";
|
my $version="0.0.95";
|
||||||
# Laden evtl. abhängiger Perl- bzw. FHEM-Module
|
# Laden evtl. abhängiger Perl- bzw. FHEM-Module
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user