diff --git a/FHEM/31_HUEDevice.pm b/FHEM/31_HUEDevice.pm index 5c8bb523f..0cc9614f0 100644 --- a/FHEM/31_HUEDevice.pm +++ b/FHEM/31_HUEDevice.pm @@ -10,6 +10,8 @@ package main; use strict; use warnings; +use Color; + use POSIX; use JSON; use SetExtensions; @@ -63,7 +65,7 @@ sub HUEDevice_Initialize($) #$hash->{FW_summaryFn} = "HUEDevice_summaryFn"; - $data{webCmdFn}{colorpicker} = "HUEDevice_colorpickerFn"; + $data{webCmdFn}{colorpicker} = "FHEM_colorpickerFn"; $data{FWEXT}{"/"}{SCRIPT} = "/jscolor/jscolor.js"; } @@ -111,41 +113,6 @@ Log 3, "HUEDevice_summaryFn"; return HUEDevice_devStateIcon($hash); } -sub -HUEDevice_colorpickerFn($$$) -{ - my ($FW_wname, $d, $FW_room, $cmd, $values) = @_; - - my @args = split("[ \t]+", $cmd); - - return undef if($values !~ m/^colorpicker,(.*)$/); - my ($mode) = ($1); - $mode = "RGB" if( !defined($mode) ); - my $srf = $FW_room ? "&room=$FW_room" : ""; - my $cv = CommandGet("","$d $cmd"); - $cmd = "" if($cmd eq "state"); - if( $args[1] ) { - my $c = "cmd=set $d $cmd$srf"; - - return ''. - "
'. - '' if( AttrVal($FW_wname, "longpoll", 1)); - - return ''. - "". - '
'. - '
'. - ''; - } else { - my $c = "$FW_ME?XHR=1&cmd=set $d $cmd %$srf"; - return ''. - "". - ''; - } -} - sub HUEDevice_Define($$) { my ($hash, $def) = @_; diff --git a/FHEM/Color.pm b/FHEM/Color.pm new file mode 100644 index 000000000..ada81a4c5 --- /dev/null +++ b/FHEM/Color.pm @@ -0,0 +1,44 @@ + +# $Id$ + +package main; + +use strict; +use warnings; + +sub +FHEM_colorpickerFn($$$) +{ + my ($FW_wname, $d, $FW_room, $cmd, $values) = @_; + + my @args = split("[ \t]+", $cmd); + + return undef if($values !~ m/^colorpicker,(.*)$/); + my ($mode) = ($1); + $mode = "RGB" if( !defined($mode) ); + my $srf = $FW_room ? "&room=$FW_room" : ""; + my $cv = CommandGet("","$d $cmd"); + $cmd = "" if($cmd eq "state"); + if( $args[1] ) { + my $c = "cmd=set $d $cmd$srf"; + + return ''. + "
'. + '' if( AttrVal($FW_wname, "longpoll", 1)); + + return ''. + "". + '
'. + '
'. + ''; + } else { + my $c = "$FW_ME?XHR=1&cmd=set $d $cmd %$srf"; + return ''. + "". + ''; + } +} + +1;