mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-27 20:34:52 +00:00
74_Unifi: added set command to en-/disable Site-Status-LEDs
git-svn-id: https://svn.fhem.de/fhem/trunk@15918 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
928aab275b
commit
bcd7202d6d
fhem
@ -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.
|
||||||
|
- feature: 74_Unifi: add new set command to en-/disable Site Status-LEDs
|
||||||
- bugfix: 74_XiaomiBTLESens: fix ssh gatttool which test
|
- bugfix: 74_XiaomiBTLESens: fix ssh gatttool which test
|
||||||
- new: 74_XiaomiBTLESens: modul replace 74_XiaomiFlowerSens, add Support
|
- new: 74_XiaomiBTLESens: modul replace 74_XiaomiFlowerSens, add Support
|
||||||
for Xiamomi Themometer/Hygrometer mit Display
|
for Xiamomi Themometer/Hygrometer mit Display
|
||||||
|
@ -1,6 +1,15 @@
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
|
# CHANGED
|
||||||
|
##############################################################################
|
||||||
|
# V2.0
|
||||||
|
# - feature: 74_Unifi: add new set commands to block/unblock clients,
|
||||||
|
# enable/disable WLAN, new client-Reading essid
|
||||||
|
# V2.1
|
||||||
|
# - feature: 74_Unifi: add new set command to en-/disable Site Status-LEDs
|
||||||
|
|
||||||
|
|
||||||
package main;
|
package main;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
@ -50,6 +59,8 @@ sub Unifi_BlockClient_Send($@);
|
|||||||
sub Unifi_BlockClient_Receive($);
|
sub Unifi_BlockClient_Receive($);
|
||||||
sub Unifi_UnblockClient_Send($@);
|
sub Unifi_UnblockClient_Send($@);
|
||||||
sub Unifi_UnblockClient_Receive($);
|
sub Unifi_UnblockClient_Receive($);
|
||||||
|
sub Unifi_SwitchSiteLEDs_Send($$);
|
||||||
|
sub Unifi_SwitchSiteLEDs_Receive($);
|
||||||
sub Unifi_WlanconfRest_Send($$@);
|
sub Unifi_WlanconfRest_Send($$@);
|
||||||
sub Unifi_WlanconfRest_Receive($);
|
sub Unifi_WlanconfRest_Receive($);
|
||||||
sub Unifi_NextUpdateFn($$);
|
sub Unifi_NextUpdateFn($$);
|
||||||
@ -163,14 +174,14 @@ sub Unifi_Set($@) {
|
|||||||
my $apNames = Unifi_ApNames($hash);
|
my $apNames = Unifi_ApNames($hash);
|
||||||
my $SSIDs = Unifi_SSIDs($hash);
|
my $SSIDs = Unifi_SSIDs($hash);
|
||||||
|
|
||||||
if($setName !~ /archiveAlerts|restartAP|setLocateAP|unsetLocateAP|disconnectClient|update|clear|poeMode|blockClient|unblockClient|enableWLAN|disableWLAN/) {
|
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 "
|
||||||
.((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 " : "")
|
||||||
."poeMode enableWLAN:$SSIDs disableWLAN:$SSIDs "
|
."poeMode enableWLAN:$SSIDs disableWLAN:$SSIDs "
|
||||||
."blockClient:$clientNames unblockClient:$clientNames";
|
."blockClient:$clientNames unblockClient:$clientNames switchSiteLEDs:on,off";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log3 $name, 4, "$name: set $setName";
|
Log3 $name, 4, "$name: set $setName";
|
||||||
@ -218,11 +229,18 @@ sub Unifi_Set($@) {
|
|||||||
Unifi_UnblockClient_Send($hash,keys(%{$hash->{clients}}));
|
Unifi_UnblockClient_Send($hash,keys(%{$hash->{clients}}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elsif ($setName eq 'switchSiteLEDs') {
|
||||||
|
my $state="true";
|
||||||
|
if ($setVal && $setVal eq 'off') {
|
||||||
|
$state="false";
|
||||||
|
}
|
||||||
|
Unifi_SwitchSiteLEDs_Send($hash,$state);
|
||||||
|
}
|
||||||
elsif ($setName eq 'disableWLAN') {
|
elsif ($setName eq 'disableWLAN') {
|
||||||
my $wlan = Unifi_SSIDs($hash,$setVal,'makeID');
|
my $wlan = Unifi_SSIDs($hash,$setVal,'makeID');
|
||||||
if (defined $hash->{wlans}->{$wlan}) {
|
if (defined $hash->{wlans}->{$wlan}) {
|
||||||
my $wlanconf = $hash->{wlans}->{$wlan};
|
my $wlanconf = $hash->{wlans}->{$wlan};
|
||||||
$wlanconf->{enabled}='false';
|
$wlanconf->{enabled}=JSON::false;
|
||||||
Unifi_WlanconfRest_Send($hash,$wlan,$wlanconf);
|
Unifi_WlanconfRest_Send($hash,$wlan,$wlanconf);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -233,7 +251,7 @@ sub Unifi_Set($@) {
|
|||||||
my $wlan = Unifi_SSIDs($hash,$setVal,'makeID');
|
my $wlan = Unifi_SSIDs($hash,$setVal,'makeID');
|
||||||
if (defined $hash->{wlans}->{$wlan}) {
|
if (defined $hash->{wlans}->{$wlan}) {
|
||||||
my $wlanconf = $hash->{wlans}->{$wlan};
|
my $wlanconf = $hash->{wlans}->{$wlan};
|
||||||
$wlanconf->{enabled}='true';
|
$wlanconf->{enabled}=JSON::true;
|
||||||
Unifi_WlanconfRest_Send($hash,$wlan,$wlanconf);
|
Unifi_WlanconfRest_Send($hash,$wlan,$wlanconf);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -706,9 +724,9 @@ sub Unifi_GetWlans_Receive($) {
|
|||||||
|
|
||||||
for my $h (@{$data->{data}}) {
|
for my $h (@{$data->{data}}) {
|
||||||
$hash->{wlans}->{$h->{_id}} = $h;
|
$hash->{wlans}->{$h->{_id}} = $h;
|
||||||
#TODO: Passphrase ggf. verschlüsseln?!
|
#TODO: Passphrase ggf. verschlüsseln?!
|
||||||
#Ich musste diese Zeile rausnehmen, sonst ist das Json für enable/disableWLAN bei offenem WLAN (ohne Passphrase) falsch
|
#Ich musste diese Zeile rausnehmen, sonst ist das Json für enable/disableWLAN bei offenem WLAN (ohne Passphrase) falsch
|
||||||
#Aussternen geht nicht, sonst wird das PW unter Umständen darauf geändert.
|
#Aussternen geht nicht, sonst wird das PW unter Umständen darauf geändert.
|
||||||
#$hash->{wlans}->{$h->{_id}}->{x_passphrase} = '***'; # Don't show passphrase in list
|
#$hash->{wlans}->{$h->{_id}}->{x_passphrase} = '***'; # Don't show passphrase in list
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1148,6 +1166,45 @@ sub Unifi_UnblockClient_Receive($) {
|
|||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
sub Unifi_SwitchSiteLEDs_Send($$) {
|
||||||
|
my ($hash,$state) = @_;
|
||||||
|
my ($name,$self) = ($hash->{NAME},Unifi_Whoami());
|
||||||
|
Log3 $name, 5, "$name ($self) - executed with command: '".$state."'";
|
||||||
|
|
||||||
|
HttpUtils_NonblockingGet( {
|
||||||
|
%{$hash->{httpParams}},
|
||||||
|
url => $hash->{unifi}->{url}."set/setting/mgmt",
|
||||||
|
callback => \&Unifi_SwitchSiteLEDs_Receive,
|
||||||
|
data => "{'led_enabled': ".$state."}",
|
||||||
|
} );
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
###############################################################################
|
||||||
|
sub Unifi_SwitchSiteLEDs_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}."});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
###############################################################################
|
###############################################################################
|
||||||
sub Unifi_WlanconfRest_Send($$@) {
|
sub Unifi_WlanconfRest_Send($$@) {
|
||||||
my ($hash,$id,$data) = @_;
|
my ($hash,$id,$data) = @_;
|
||||||
@ -1609,6 +1666,8 @@ Or you can use the other readings or set and get features to control your unifi-
|
|||||||
Disables WLAN with <ssid></li>
|
Disables WLAN with <ssid></li>
|
||||||
<li><code>set <name> enableWLAN <ssid></code><br>
|
<li><code>set <name> enableWLAN <ssid></code><br>
|
||||||
Enables WLAN with <ssid></li>
|
Enables WLAN with <ssid></li>
|
||||||
|
<li><code>set <name> switchSiteLEDs <on|off></code><br>
|
||||||
|
Enables or disables the Status-LED settings of the site.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user