From c782c4467f65ef345e797caa22efc75bdaf8aa1f Mon Sep 17 00:00:00 2001 From: Damian <> Date: Sun, 16 Feb 2020 17:56:18 +0000 Subject: [PATCH] 98_DOIF.pm: DOIF_Attr-set removed at init_done (def modify), new ui_Table functions: hsv, ICON, icon_label git-svn-id: https://svn.fhem.de/fhem/trunk@21208 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/98_DOIF.pm | 55 +++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/fhem/FHEM/98_DOIF.pm b/fhem/FHEM/98_DOIF.pm index 47b44a920..684c831e0 100644 --- a/fhem/FHEM/98_DOIF.pm +++ b/fhem/FHEM/98_DOIF.pm @@ -119,6 +119,9 @@ sub DOIF_hsv { my ($cur,$min,$max,$min_s,$max_s,$s,$v)=@_; + $s=100 if (!defined ($s)); + $v=100 if (!defined ($v)); + my $m=($max_s-$min_s)/($max-$min); my $n=$min_s-$min*$m; if ($cur>$max) { @@ -3121,11 +3124,11 @@ CmdDoIfPerl($$) readingsBulkUpdate ($hash,"mode","enabled"); readingsEndUpdate($hash, 1); $hash->{helper}{globalinit}=1; - foreach my $key (keys %{$attr{$hash->{NAME}}}) { - if ($key ne "disable" and AttrVal($hash->{NAME},$key,"")) { - DOIF_Attr ("set",$hash->{NAME},$key,AttrVal($hash->{NAME},$key,"")); - } - } + #foreach my $key (keys %{$attr{$hash->{NAME}}}) { + # if ($key ne "disable" and AttrVal($hash->{NAME},$key,"")) { + # DOIF_Attr ("set",$hash->{NAME},$key,AttrVal($hash->{NAME},$key,"")); + # } + #} } $hash->{helper}{last_timer}=0; @@ -3205,11 +3208,11 @@ CmdDoIf($$) readingsEndUpdate($hash, 1); $hash->{helper}{globalinit}=1; - foreach my $key (keys %{$attr{$hash->{NAME}}}) { - if ($key ne "disable" and AttrVal($hash->{NAME},$key,"")) { - DOIF_Attr ("set",$hash->{NAME},$key,AttrVal($hash->{NAME},$key,"")); - } - } + #foreach my $key (keys %{$attr{$hash->{NAME}}}) { + # if ($key ne "disable" and AttrVal($hash->{NAME},$key,"")) { + # DOIF_Attr ("set",$hash->{NAME},$key,AttrVal($hash->{NAME},$key,"")); + # } + #} } $hash->{helper}{last_timer}=0; @@ -3287,6 +3290,7 @@ CmdDoIf($$) } $hash->{do}{$last_do+1}{0}=$else_cmd_ori if ($j==0); #doelse without brackets } + return("","") } @@ -3904,6 +3908,11 @@ sub FW_makeImage { return($value,"",("iconSwitch,".$state_on.",".$i_off.",".$state_off.",".$icon_on)); } + sub ICON { + my ($icon)=@_; + ::FW_makeImage($icon); + } + sub icon { my ($value,$icon_off,$icon_on,$state_off,$state_on)=@_; $state_on=(defined ($state_on) and $state_on ne "") ? $state_on : "on"; @@ -3913,6 +3922,25 @@ sub FW_makeImage { return($value,"",("iconLabel,".$state_on.",".$icon_on.",".$state_off.",".$i_off)); } + sub icon_label + { + my ($icon,$text,$color,$color_bg,$pos_left,$pos_top) = @_; + $color = "" if (!defined ($color)); + $color_bg = "" if (!defined ($color_bg)); + $pos_left = -3 if (!defined ($pos_left)); + $pos_top = -8 if (!defined ($pos_top)); + my $pad = (length($text) > 1) ? 2 : 5; + return '
'.::FW_makeImage($icon).'
'.$text.'
' + } + + sub hsv { + return(::DOIF_hsv(@_)); + } + + 1; @@ -3976,7 +4004,7 @@ Many examples with english identifiers - see

DOIF