2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-19 18:56:03 +00:00

98_Hyperion: fix toggleMode sometimes not working as expected

git-svn-id: https://svn.fhem.de/fhem/trunk@12503 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
deespe 2016-11-04 16:13:23 +00:00
parent 36cf89afc2
commit 4f55e35ff1

View File

@ -334,7 +334,6 @@ sub Hyperion_Read($)
elsif ($col) elsif ($col)
{ {
my $rgb = lc((split("x",$col))[1]); my $rgb = lc((split("x",$col))[1]);
$rgb =~ m/^(..)(..)(..)/;
my ($r,$g,$b) = Color::hex2rgb($rgb); my ($r,$g,$b) = Color::hex2rgb($rgb);
my ($h,$s,$v) = Color::rgb2hsv($r / 255,$g / 255,$b / 255); my ($h,$s,$v) = Color::rgb2hsv($r / 255,$g / 255,$b / 255);
my $dim = int($v * 100); my $dim = int($v * 100);
@ -379,8 +378,7 @@ sub Hyperion_Read($)
sub Hyperion_GetConfigs($) sub Hyperion_GetConfigs($)
{ {
my ($hash) = @_; my ($hash) = @_;
return "Not connected" return "Not connected" if (!$hash->{FD});
if (!$hash->{FD});
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $ip = $hash->{IP}; my $ip = $hash->{IP};
my $dir = AttrVal($name,"hyperionConfigDir","/etc/hyperion/"); my $dir = AttrVal($name,"hyperionConfigDir","/etc/hyperion/");
@ -545,7 +543,7 @@ sub Hyperion_Set($@)
elsif ($cmd eq "rgb") elsif ($cmd eq "rgb")
{ {
return "Value of $cmd has to be in RGB hex format like ffffff or 3F7D90" return "Value of $cmd has to be in RGB hex format like ffffff or 3F7D90"
if ($value !~ /^(\d|[a-f|A-F]){6}$/); if ($value !~ /^[\dA-Fa-f]{6}$/);
$value = lc($value); $value = lc($value);
my ($r,$g,$b) = Color::hex2rgb($value); my ($r,$g,$b) = Color::hex2rgb($value);
$obj{color} = [$r,$g,$b]; $obj{color} = [$r,$g,$b];
@ -657,7 +655,7 @@ sub Hyperion_Set($@)
{ {
$nmode = $i < $count - 1 ? $modeorder[$i+1] : $modeorder[0] if ($modeorder[$i] eq $mode); $nmode = $i < $count - 1 ? $modeorder[$i+1] : $modeorder[0] if ($modeorder[$i] eq $mode);
} }
$nmode = $nmode ? $nmode : "off"; $nmode = $nmode ? $nmode : @modeorder[0];
fhem "set $name mode $nmode"; fhem "set $name mode $nmode";
return undef; return undef;
} }