diff --git a/fhem/FHEM/31_HUEDevice.pm b/fhem/FHEM/31_HUEDevice.pm index ba91d7ab5..126e7afe3 100644 --- a/fhem/FHEM/31_HUEDevice.pm +++ b/fhem/FHEM/31_HUEDevice.pm @@ -60,6 +60,7 @@ sub HUEDevice_Initialize($) $hash->{GetFn} = "HUEDevice_Get"; $hash->{AttrList} = "IODev ". "delayedUpdate:1 ". + "realtimePicker:1 ". "color-icons:1,2 ". "model:".join(",", sort keys %hueModels)." ". "subType:colordimmer,dimmer,switch ". @@ -312,6 +313,8 @@ HUEDevice_SetParam($$@) $defs{$name}->{fhem}->{update_timeout} = 1; } elsif( $cmd eq "immediateUpdate" ) { $defs{$name}->{fhem}->{update_timeout} = 0; + } elsif( $cmd eq "noUpdate" ) { + $defs{$name}->{fhem}->{update_timeout} = -1; } else { return 0; } @@ -345,6 +348,18 @@ HUEDevice_Set($@) HUEDevice_SetParam($name, \%obj, $cmd, $value, $value2); } +# if( $defs{$name}->{fhem}->{update_timeout} == -1 ) { +# my $diff; +# my ($seconds, $microseconds) = gettimeofday(); +# if( $defs{$name}->{fhem}->{timestamp} ) { +# my ($seconds2, $microseconds2) = @{$defs{$name}->{fhem}->{timestamp}}; +# +# $diff = (($seconds-$seconds2)*1000000 + $microseconds-$microseconds2)/1000; +# } +# $defs{$name}->{fhem}->{timestamp} = [$seconds, $microseconds]; +# +# return undef if( $diff < 100 ); +# } if( scalar keys %obj ) { my $result; @@ -358,7 +373,8 @@ HUEDevice_Set($@) return undef; } - if( $defs{$name}->{fhem}->{update_timeout} + if( $defs{$name}->{fhem}->{update_timeout} == -1 ) { + } elsif( $defs{$name}->{fhem}->{update_timeout} && !$hash->{fhem}->{group} ) { RemoveInternalTimer($hash); InternalTimer(gettimeofday()+1, "HUEDevice_GetUpdate", $hash, 1); diff --git a/fhem/FHEM/Color.pm b/fhem/FHEM/Color.pm index fe6db8c7c..94a5f4885 100644 --- a/fhem/FHEM/Color.pm +++ b/fhem/FHEM/Color.pm @@ -46,6 +46,13 @@ FHEM_colorpickerFn($$$) 'border:1px solid #fff;border-radius:8px;background-color:#'. $args[1] .';">'. ''. ''; + } elsif(AttrVal($d,"realtimePicker",0)) { + my $c = "$FW_ME?XHR=1&cmd=set $d $cmd %$srf"; + my $ci = $c; + $ci = "$FW_ME?XHR=1&cmd=set $d $cmd % : transitiontime 0 : noUpdate$srf" if($defs{$d}->{TYPE} eq "HUEDevice"); + return ''. + "". + ''; } else { my $c = "$FW_ME?XHR=1&cmd=set $d $cmd %$srf"; return ''. @@ -112,7 +119,7 @@ RgbToChannels($$) { sub ChannelsToRgb(@) { my @channels = @_; - return sprintf("%02X" x @_, @_); + return sprintf("%02X" x @_, @_); } sub @@ -124,14 +131,15 @@ ChannelsToBrightness(@) { $max = $value if ($max < $value); } + return { + bri => 0, + channels => \(255 x @channels), + } unless ($max > 0); + my @bri = (); - if( $max == 0) { - @bri = (0) x @channels; - } else { - my $norm = 255/$max; - foreach my $value (@channels) { - push @bri,int($value*$norm); - } + my $norm = 255/$max; + foreach my $value (@channels) { + push @bri,int($value*$norm); } return { diff --git a/fhem/www/pgm2/fhemweb_colorpicker.js b/fhem/www/pgm2/fhemweb_colorpicker.js index c7fcc7e6c..7d2daf4a7 100644 --- a/fhem/www/pgm2/fhemweb_colorpicker.js +++ b/fhem/www/pgm2/fhemweb_colorpicker.js @@ -9,13 +9,23 @@ FW_colorpickerUpdateLine(d) if(el) { el.color.fromString(d[1]); } - } function colorpicker_setColor(el,mode,cmd) { var v = el.color; + + if(mode==undefined) { + mode=el.pickerMode; + } + if(cmd==undefined) { + cmd=el.command; + } + if(v==undefined) { + v=el.toString(); + } + if(mode=="HSV") { v = (0x100 | Math.round(42*el.color.hsv[0])).toString(16).substr(1) + (0x100 | Math.round(255*el.color.hsv[1])).toString(16).substr(1) + @@ -31,7 +41,7 @@ colorpicker_setColor(el,mode,cmd) document.location = cmd.replace('%',v); } -FW_widgets['colorpicker'] = { +FW_widgets['colorpicker'] = { updateLine:FW_colorpickerUpdateLine };