2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-07 19:04:20 +00:00

74_Unifi: update VC-readings immediately when getting voucher

git-svn-id: https://svn.fhem.de/fhem/trunk@16622 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
wuehler 2018-04-15 18:33:31 +00:00
parent 494529bf25
commit 466043763d
2 changed files with 516 additions and 157 deletions

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,8 @@
# - feature: 74_Unifi: added voucher-functions
# V 2.2
# - feature: 74_Unifi: added set updateClien, encrypt user and password
# V 2.2.1
# - feature: 74_Unifi: update VC-readings immediately when getting voucher
package main;
@ -606,14 +608,15 @@ sub Unifi_Get($@) {
elsif ($getName eq 'voucher' && defined $hash->{hotspot}->{vouchers}[0]) {
my $returnedVoucher = Unifi_getNextVoucherForNote($hash,$getVal);
if ($returnedVoucher eq ""){
return "VoucherCache for $getVal is not defined!";
return "No voucher with note: $getVal!";
}
my $returnedVoucherCode = "";
if(defined $returnedVoucher->{_id}){
$returnedVoucherCode = $returnedVoucher->{code};
#if (defined $hash->{hotspot}->{voucherCache}->{$getVal}->{setCmd}){
$hash->{hotspot}->{voucherCache}->{$getVal}->{$returnedVoucher->{_id}}->{delivered_at} = time();
#}
if (defined $hash->{hotspot}->{voucherCache}->{$getVal}->{setCmd}){
$hash->{hotspot}->{voucherCache}->{$getVal}->{$returnedVoucher->{_id}}->{delivered_at} = time();
readingsSingleUpdate($hash,"-VC_".$getVal,Unifi_getNextVoucherForNote($hash,$getVal)->{code},1);
}
}
return $returnedVoucherCode;
}