2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

74_Unifi: SSIDs-Readings and drop-downs use goodReadingName()

git-svn-id: https://svn.fhem.de/fhem/trunk@16008 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
wuehler 2018-01-27 12:27:57 +00:00
parent cc135e9f13
commit 6fad8a85b8
2 changed files with 30 additions and 18 deletions

View File

@ -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.
- change: 74_Unifi: SSIDs-Readings and drop-downs use goodReadingName()
- feature: new module 37_NotifyAndroidTV.pm to send notifications - feature: new module 37_NotifyAndroidTV.pm to send notifications
to Notifications for Android TV/Fire TV apps (justme1968) to Notifications for Android TV/Fire TV apps (justme1968)
- bugfix: 98_TRAFFIC: v1.3.4, fixed DbLog_SplitFn, misc improvements - bugfix: 98_TRAFFIC: v1.3.4, fixed DbLog_SplitFn, misc improvements

View File

@ -12,6 +12,8 @@
# - bugfix: 74_Unifi: fixed blockClient # - bugfix: 74_Unifi: fixed blockClient
# V2.1.2 # V2.1.2
# - feature: 74_Unifi: new Readings for WLAN-states, fixed Warning # - feature: 74_Unifi: new Readings for WLAN-states, fixed Warning
# V2.1.3
# - change: 74_Unifi: SSIDs-Readings and drop-downs use goodReadingName()
package main; package main;
@ -182,7 +184,7 @@ sub Unifi_Set($@) {
if($setName !~ /archiveAlerts|restartAP|setLocateAP|unsetLocateAP|disconnectClient|update|clear|poeMode|blockClient|unblockClient|enableWLAN|disableWLAN|switchSiteLEDs/) { if($setName !~ /archiveAlerts|restartAP|setLocateAP|unsetLocateAP|disconnectClient|update|clear|poeMode|blockClient|unblockClient|enableWLAN|disableWLAN|switchSiteLEDs/) {
return "Unknown argument $setName, choose one of update:noArg " return "Unknown argument $setName, choose one of update:noArg "
."clear:all,readings,clientData " ."clear:all,readings,clientData,allData "
.((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 " : "")
.(($clientNames && Unifi_CONNECTED($hash)) ? "disconnectClient:all,$clientNames " : "") .(($clientNames && Unifi_CONNECTED($hash)) ? "disconnectClient:all,$clientNames " : "")
@ -243,22 +245,22 @@ sub Unifi_Set($@) {
Unifi_SwitchSiteLEDs_Send($hash,$state); Unifi_SwitchSiteLEDs_Send($hash,$state);
} }
elsif ($setName eq 'disableWLAN') { elsif ($setName eq 'disableWLAN') {
my $wlan = Unifi_SSIDs($hash,$setVal,'makeID'); my $wlanid = Unifi_SSIDs($hash,$setVal,'makeID');
if (defined $hash->{wlans}->{$wlan}) { if (defined $hash->{wlans}->{$wlanid}) {
my $wlanconf = $hash->{wlans}->{$wlan}; my $wlanconf = $hash->{wlans}->{$wlanid};
$wlanconf->{enabled}=JSON::false; $wlanconf->{enabled}=JSON::false;
Unifi_WlanconfRest_Send($hash,$wlan,$wlanconf); Unifi_WlanconfRest_Send($hash,$wlanid,$wlanconf);
} }
else { else {
return "$hash->{NAME}: Unknown SSID '$setVal' in command '$setName', choose one of: all,$SSIDs"; return "$hash->{NAME}: Unknown SSID '$setVal' in command '$setName', choose one of: all,$SSIDs";
} }
} }
elsif ($setName eq 'enableWLAN') { elsif ($setName eq 'enableWLAN') {
my $wlan = Unifi_SSIDs($hash,$setVal,'makeID'); my $wlanid = Unifi_SSIDs($hash,$setVal,'makeID');
if (defined $hash->{wlans}->{$wlan}) { if (defined $hash->{wlans}->{$wlanid}) {
my $wlanconf = $hash->{wlans}->{$wlan}; my $wlanconf = $hash->{wlans}->{$wlanid};
$wlanconf->{enabled}=JSON::true; $wlanconf->{enabled}=JSON::true;
Unifi_WlanconfRest_Send($hash,$wlan,$wlanconf); Unifi_WlanconfRest_Send($hash,$wlanid,$wlanconf);
} }
else { else {
return "$hash->{NAME}: Unknown SSID '$setVal' in command '$setName', choose one of: all,$SSIDs"; return "$hash->{NAME}: Unknown SSID '$setVal' in command '$setName', choose one of: all,$SSIDs";
@ -387,9 +389,18 @@ sub Unifi_Set($@) {
delete $hash->{READINGS}->{$_} if($_ ne 'state'); delete $hash->{READINGS}->{$_} if($_ ne 'state');
} }
} }
if ($setVal eq 'clientData' || $setVal eq 'all') { if ($setVal eq 'clientData') {
%{$hash->{clients}} = (); %{$hash->{clients}} = ();
} }
if ($setVal eq 'allData' || $setVal eq 'all') {
%{$hash->{clients}} = ();
%{$hash->{wlans}} = ();
%{$hash->{wlan_health}} = ();
%{$hash->{accespoints}} = ();
# %{$hash->{events}} = ();
%{$hash->{wlangroups}} = ();
# %{$hash->{alerts_unarchived}} = ();
}
} }
} }
return undef; return undef;
@ -1012,7 +1023,7 @@ sub Unifi_SetClientReadings($) {
readingsBulkUpdate($hash,$clientName."_last_seen",strftime "%Y-%m-%d %H:%M:%S",localtime($clientRef->{last_seen})); readingsBulkUpdate($hash,$clientName."_last_seen",strftime "%Y-%m-%d %H:%M:%S",localtime($clientRef->{last_seen}));
readingsBulkUpdate($hash,$clientName."_uptime",$clientRef->{uptime}); readingsBulkUpdate($hash,$clientName."_uptime",$clientRef->{uptime});
readingsBulkUpdate($hash,$clientName."_snr",$clientRef->{rssi}); readingsBulkUpdate($hash,$clientName."_snr",$clientRef->{rssi});
readingsBulkUpdate($hash,$clientName."_essid",$clientRef->{essid}); readingsBulkUpdate($hash,$clientName."_essid",makeReadingName($clientRef->{essid}));
readingsBulkUpdate($hash,$clientName."_accesspoint",$apName); readingsBulkUpdate($hash,$clientName."_accesspoint",$apName);
readingsBulkUpdate($hash,$clientName,'connected'); readingsBulkUpdate($hash,$clientName,'connected');
} }
@ -1053,7 +1064,7 @@ sub Unifi_SetAccesspointReadings($) {
if (defined $apRef->{vap_table} && scalar @{$apRef->{vap_table}}) { if (defined $apRef->{vap_table} && scalar @{$apRef->{vap_table}}) {
for my $vap (@{$apRef->{vap_table}}) { for my $vap (@{$apRef->{vap_table}}) {
$essid .= $vap->{essid}.','; $essid .= makeReadingName($vap->{essid}).',';
} }
$essid =~ s/.$//; $essid =~ s/.$//;
} else { } else {
@ -1092,7 +1103,7 @@ sub Unifi_SetWlanReadings($) {
my ($wlanName,$wlanRef); my ($wlanName,$wlanRef);
for my $wlanID (keys %{$hash->{wlans}}) { for my $wlanID (keys %{$hash->{wlans}}) {
$wlanRef = $hash->{wlans}->{$wlanID}; $wlanRef = $hash->{wlans}->{$wlanID};
$wlanName = $wlanRef->{name}; $wlanName = makeReadingName($wlanRef->{name});
readingsBulkUpdate($hash,'-WLAN_'.$wlanName.'_state',($wlanRef->{enabled} == JSON::true) ? 'enabled' : 'disabled'); readingsBulkUpdate($hash,'-WLAN_'.$wlanName.'_state',($wlanRef->{enabled} == JSON::true) ? 'enabled' : 'disabled');
} }
@ -1476,15 +1487,15 @@ sub Unifi_SSIDs($@){
if(defined $ID && defined $W && $W eq 'makeName') { # Return Name from ID if(defined $ID && defined $W && $W eq 'makeName') { # Return Name from ID
$wlanRef = $hash->{wlans}->{$ID}; $wlanRef = $hash->{wlans}->{$ID};
if (defined $wlanRef->{name} && $wlanRef->{name} =~ /^([\w\.\-]+)$/) { if (defined $wlanRef->{name} ){ #&& $wlanRef->{name} =~ /^([\w\.\-]+)$/) {
$ID = $1; $ID = makeReadingName($wlanRef->{name});
} }
return $ID; return $ID;
} }
elsif (defined $ID && defined $W && $W eq 'makeID') { # Return ID from Name elsif (defined $ID && defined $W && $W eq 'makeID') { # Return ID from Name
for (keys %{$hash->{wlans}}) { for (keys %{$hash->{wlans}}) {
$wlanRef = $hash->{wlans}->{$_}; $wlanRef = $hash->{wlans}->{$_};
if (defined $wlanRef->{name} && $wlanRef->{name} eq $ID) { if (defined $wlanRef->{name} && makeReadingName($wlanRef->{name}) eq $ID) {
$ID = $_; $ID = $_;
last; last;
} }
@ -1708,8 +1719,8 @@ Or you can use the other readings or set and get features to control your unifi-
<li><code>set &lt;name&gt; update</code><br> <li><code>set &lt;name&gt; update</code><br>
Makes immediately a manual update. </li> Makes immediately a manual update. </li>
<br> <br>
<li><code>set &lt;name&gt; clear &lt;readings|clientData|all&gt;</code><br> <li><code>set &lt;name&gt; clear &lt;readings|clientData|allData|all&gt;</code><br>
Clears the readings, clientData or all. </li> Clears the readings, clientData, all Unifi data or all (readings and data). </li>
<br> <br>
<li><code>set &lt;name&gt; archiveAlerts</code><br> <li><code>set &lt;name&gt; archiveAlerts</code><br>
Archive all unarchived Alerts. </li> Archive all unarchived Alerts. </li>