From ab4efc996f42b31d5f1fb8bf346efb6089f85a57 Mon Sep 17 00:00:00 2001 From: wuehler <> Date: Sun, 21 Jan 2018 19:51:41 +0000 Subject: [PATCH] 74_Unifi: new Readings for WLAN-states, fixed Warning git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@15949 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- CHANGED | 1 + FHEM/74_Unifi.pm | 33 +++++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/CHANGED b/CHANGED index 09ea85872..cf7fa98c4 100644 --- a/CHANGED +++ b/CHANGED @@ -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. + - feature: 74_Unifi: new Readings for WLAN-states, fixed Warning - feature: 93_DbRep: V7.5.1, new set-options display/writeToDB for (max|min|sum|average|diff)Value, create background_processing_time before execute diff --git a/FHEM/74_Unifi.pm b/FHEM/74_Unifi.pm index d0bbb6ed8..770ccfe0c 100644 --- a/FHEM/74_Unifi.pm +++ b/FHEM/74_Unifi.pm @@ -10,6 +10,8 @@ # - feature: 74_Unifi: add new set command to en-/disable Site Status-LEDs # V2.1.1 # - bugfix: 74_Unifi: fixed blockClient +# V2.1.2 +# - feature: 74_Unifi: new Readings for WLAN-states, fixed Warning package main; @@ -49,6 +51,7 @@ sub Unifi_ProcessUpdate($); sub Unifi_SetClientReadings($); sub Unifi_SetHealthReadings($); sub Unifi_SetAccesspointReadings($); +sub Unifi_SetWlanReadings($); sub Unifi_DisconnectClient_Send($@); sub Unifi_DisconnectClient_Receive($); sub Unifi_ApCmd_Send($$@); @@ -57,6 +60,7 @@ sub Unifi_ArchiveAlerts_Send($); sub Unifi_Cmd_Receive($); sub Unifi_ClientNames($@); sub Unifi_ApNames($@); +sub Unifi_SSIDs($@); sub Unifi_BlockClient_Send($@); sub Unifi_BlockClient_Receive($); sub Unifi_UnblockClient_Send($@); @@ -961,6 +965,7 @@ sub Unifi_ProcessUpdate($) { Unifi_SetHealthReadings($hash); Unifi_SetClientReadings($hash); Unifi_SetAccesspointReadings($hash); + Unifi_SetWlanReadings($hash); ## WLANGROUPS ??? #'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''# readingsEndUpdate($hash,1); @@ -1077,6 +1082,22 @@ sub Unifi_SetAccesspointReadings($) { return undef; } + +############################################################################### +sub Unifi_SetWlanReadings($) { + my ($hash) = @_; + my ($name,$self) = ($hash->{NAME},Unifi_Whoami()); + Log3 $name, 5, "$name ($self) - executed."; + + my ($wlanName,$wlanRef); + for my $wlanID (keys %{$hash->{wlans}}) { + $wlanRef = $hash->{wlans}->{$wlanID}; + $wlanName = $wlanRef->{name}; + readingsBulkUpdate($hash,'-WLAN_'.$wlanName.'_state',($wlanRef->{enabled} == JSON::true) ? 'enabled' : 'disabled'); + } + + return undef; +} ############################################################################### sub Unifi_DisconnectClient_Send($@) { @@ -1470,14 +1491,14 @@ sub Unifi_SSIDs($@){ } return $ID; } - else { # Return all aps in a scalar - my $aps = ''; - for my $apID (keys %{$hash->{wlans}}) { - $aps .= Unifi_SSIDs($hash,$apID,'makeName').','; + else { # Return all wlans in a scalar + my $wlans = ''; + for my $wlanID (keys %{$hash->{wlans}}) { + $wlans .= Unifi_SSIDs($hash,$wlanID,'makeName').','; } - $aps =~ s/.$//; + $wlans =~ s/.$//; - return $aps; + return $wlans; } } ###############################################################################