98_DOIF.pm: card: internal improvements
git-svn-id: https://svn.fhem.de/fhem/trunk@24491 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -1334,18 +1334,23 @@ sub accu_setValue
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub DOIF_collect_save_values {
|
sub DOIF_collect_save_values {
|
||||||
my ($hash,$dev_reading)=@_;
|
my ($hash)=@_;
|
||||||
foreach my $hours (keys %{$hash->{collect}{"$dev_reading"}}) {
|
foreach my $key (keys %{$defs{$hash->{NAME}}{READINGS}}) {
|
||||||
if (ref($hash->{collect}{$dev_reading}{$hours}{values}) eq "ARRAY") {
|
delete $defs{$hash->{NAME}}{READINGS}{$key} if ($key =~ /^\.col/);
|
||||||
my @va=@{$hash->{collect}{$dev_reading}{$hours}{values}};
|
}
|
||||||
my @ta=@{$hash->{collect}{$dev_reading}{$hours}{times}};
|
foreach my $dev_reading (keys %{$hash->{collect}}) {
|
||||||
for (@va) { $_ = "" if (!defined $_); };
|
foreach my $hours (keys %{$hash->{collect}{"$dev_reading"}}) {
|
||||||
for (@ta) { $_ = "" if (!defined $_); };
|
if (ref($hash->{collect}{$dev_reading}{$hours}{values}) eq "ARRAY") {
|
||||||
my $dim=$hash->{collect}{$dev_reading}{$hours}{dim};
|
my @va=@{$hash->{collect}{$dev_reading}{$hours}{values}};
|
||||||
my $devReading=$dev_reading;
|
my @ta=@{$hash->{collect}{$dev_reading}{$hours}{times}};
|
||||||
$devReading =~ s/ /_/g;
|
for (@va) { $_ = "" if (!defined $_); };
|
||||||
::readingsSingleUpdate($hash,".col_".$dim."_".$devReading."_".$hours."_values",join(",",@va),0);
|
for (@ta) { $_ = "" if (!defined $_); };
|
||||||
::readingsSingleUpdate($hash,".col_".$dim."_".$devReading."_".$hours."_times",join(",",@ta),0);
|
my $dim=$hash->{collect}{$dev_reading}{$hours}{dim};
|
||||||
|
my $devReading=$dev_reading;
|
||||||
|
$devReading =~ s/ /_/g;
|
||||||
|
::readingsSingleUpdate($hash,".col_".$dim."_".$devReading."_".$hours."_values",join(",",@va),0);
|
||||||
|
::readingsSingleUpdate($hash,".col_".$dim."_".$devReading."_".$hours."_times",join(",",@ta),0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1658,23 +1663,24 @@ sub ReplaceReadingDoIf
|
|||||||
$hours=$num;
|
$hours=$num;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete $hash->{collect}{"$name $reading"}{$hours};
|
|
||||||
AddRegexpTriggerDoIf($hash,"collect","","collect",$name,$reading);
|
AddRegexpTriggerDoIf($hash,"collect","","collect",$name,$reading);
|
||||||
$hash->{collect}{"$name $reading"}{$hours}{hours}=$hours;
|
if (ref($hash->{collect}{"$name $reading"}{$hours}{values}) ne "ARRAY") {
|
||||||
$hash->{collect}{"$name $reading"}{$hours}{dim}=72;
|
delete $hash->{collect}{"$name $reading"}{$hours};
|
||||||
my $values=::ReadingsVal($hash->{NAME},".col_".$hash->{collect}{"$name $reading"}{$hours}{dim}."_".$name."_".$reading."_".$hours."_values","");
|
$hash->{collect}{"$name $reading"}{$hours}{hours}=$hours;
|
||||||
my $times=::ReadingsVal($hash->{NAME},".col_".$hash->{collect}{"$name $reading"}{$hours}{dim}."_".$name."_".$reading."_".$hours."_times","");
|
$hash->{collect}{"$name $reading"}{$hours}{dim}=72;
|
||||||
my $va;
|
my $values=::ReadingsVal($hash->{NAME},".col_".$hash->{collect}{"$name $reading"}{$hours}{dim}."_".$name."_".$reading."_".$hours."_values","");
|
||||||
my $ta;
|
my $times=::ReadingsVal($hash->{NAME},".col_".$hash->{collect}{"$name $reading"}{$hours}{dim}."_".$name."_".$reading."_".$hours."_times","");
|
||||||
@{$va}=split (",",$values);
|
my $va;
|
||||||
for (@{$va}) { $_ = undef if ($_ eq ""); };
|
my $ta;
|
||||||
@{$ta}=split (",",$times);
|
@{$va}=split (",",$values);
|
||||||
for (@{$ta}) { $_ = undef if ($_ eq ""); };
|
for (@{$va}) { $_ = undef if ($_ eq ""); };
|
||||||
$hash->{collect}{"$name $reading"}{$hours}{values}=$va;
|
@{$ta}=split (",",$times);
|
||||||
$hash->{collect}{"$name $reading"}{$hours}{times}=$ta;
|
for (@{$ta}) { $_ = undef if ($_ eq ""); };
|
||||||
$hash->{collect}{"$name $reading"}{$hours}{dim}=72;
|
$hash->{collect}{"$name $reading"}{$hours}{values}=$va;
|
||||||
collect_setValue($hash,$name,$reading,$hours);
|
$hash->{collect}{"$name $reading"}{$hours}{times}=$ta;
|
||||||
##collect_get_min_max_DoIf(\%{$hash->{collect}{"$name $reading"}{$hours}});
|
$hash->{collect}{"$name $reading"}{$hours}{dim}=72;
|
||||||
|
collect_setValue($hash,$name,$reading,$hours);
|
||||||
|
}
|
||||||
} elsif ($format =~ /^(d[^:]*)(?::(.*))?/) {
|
} elsif ($format =~ /^(d[^:]*)(?::(.*))?/) {
|
||||||
$regExp =$1;
|
$regExp =$1;
|
||||||
$output=$2;
|
$output=$2;
|
||||||
@@ -2841,9 +2847,7 @@ DOIF_Notify($$)
|
|||||||
|
|
||||||
if ($dev->{NAME} eq "global" and (EventCheckDoif($dev->{NAME},"global",$eventa,'^SAVE$'))) {
|
if ($dev->{NAME} eq "global" and (EventCheckDoif($dev->{NAME},"global",$eventa,'^SAVE$'))) {
|
||||||
if (defined $hash->{collect}) {
|
if (defined $hash->{collect}) {
|
||||||
foreach my $dev_reading (keys %{$hash->{collect}}) {
|
DOIF_collect_save_values($hash);
|
||||||
DOIF_collect_save_values($hash,$dev_reading);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3869,9 +3873,7 @@ DOIF_Shutdown
|
|||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
DOIF_killBlocking($hash);
|
DOIF_killBlocking($hash);
|
||||||
if (defined $hash->{collect}) {
|
if (defined $hash->{collect}) {
|
||||||
foreach my $dev_reading (keys %{$hash->{collect}}) {
|
DOIF_collect_save_values($hash);
|
||||||
DOIF_collect_save_values($hash,$dev_reading);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@@ -4539,6 +4541,10 @@ sub get_color {
|
|||||||
sub card
|
sub card
|
||||||
{
|
{
|
||||||
my ($collect,$header,$icon,$min,$max,$minColor,$maxColor,$unit,$func,$decfont,$prop,$model,$lightness) = @_;
|
my ($collect,$header,$icon,$min,$max,$minColor,$maxColor,$unit,$func,$decfont,$prop,$model,$lightness) = @_;
|
||||||
|
|
||||||
|
if (!defined ${$collect}{hours}) {
|
||||||
|
return("");
|
||||||
|
}
|
||||||
my $val=${$collect}{value};
|
my $val=${$collect}{value};
|
||||||
my $a=@{$collect}{values};
|
my $a=@{$collect}{values};
|
||||||
my $maxVal = ${$collect}{max_value};
|
my $maxVal = ${$collect}{max_value};
|
||||||
|
|||||||
Reference in New Issue
Block a user