From 2e6fa0bf8b61a6bfce4761b094e1d9bd9fb5208d Mon Sep 17 00:00:00 2001 From: justme-1968 Date: Mon, 8 Mar 2021 10:21:02 +0000 Subject: [PATCH] 31_HUEDevice.pm: allow param list in setList & configList (by DeeSpe, see: https://forum.fhem.de/index.php/topic,119298.0) git-svn-id: https://svn.fhem.de/fhem/trunk@23912 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/31_HUEDevice.pm | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/fhem/FHEM/31_HUEDevice.pm b/fhem/FHEM/31_HUEDevice.pm index 0a39c9877..0e9a9800a 100644 --- a/fhem/FHEM/31_HUEDevice.pm +++ b/fhem/FHEM/31_HUEDevice.pm @@ -397,7 +397,7 @@ HUEDevice_Define($$) { my ($name, $type, $id, $interval) = @args; - $hash->{STATE} = 'Initialized'; + $hash->{STATE} = 'Initialized' if($init_done); $hash->{ID} = $hash->{helper}->{devtype}.$id; @@ -910,6 +910,7 @@ HUEDevice_Set($@) foreach my $entry (@{$entries}) { $list .= ' '; $list .= (split( ' ', $entry->{regex} ))[0]; + $list .= ":$entry->{opts}" if( $entry->{opts} ); } } $list .= ' '. join( ':noArg ', keys %{$hash->{helper}{configList}{cmds}} ) if( $hash->{helper}{configList}{cmds} ); @@ -918,6 +919,7 @@ HUEDevice_Set($@) foreach my $entry (@{$entries}) { $list .= ' '; $list .= (split( ' ', $entry->{regex} ))[0]; + $list .= ":$entry->{opts}" if( $entry->{opts} ); } } @@ -1907,11 +1909,17 @@ HUEDevice_Attr($$$;$) #return "$name is not a CLIP sensor device" if( $hash->{type} && $hash->{type} !~ m/^CLIP/ ); if( $cmd eq "set" && $attrVal ) { foreach my $line ( split( "\n", $attrVal ) ) { - my($cmd,$json) = split( ":", $line,2 ); + my ($cmd,$opts,$json); + if (scalar split(':',$line) > 3 && (split(':',$line))[1] !~ /^perl/){ + ($cmd,$opts,$json) = split( ':', $line,3 ); + } else { + ($cmd,$json) = split( ':', $line,2 ); + $opts = ''; + } if( $cmd =~ m'^/(.*)/$' ) { my $regex = $1; $hash->{helper}{$attrName}{'regex'} = [] if( !$hash->{helper}{$attrName}{'regex'} ); - push @{$hash->{helper}{$attrName}{'regex'}}, { regex => $regex, json => $json }; + push @{$hash->{helper}{$attrName}{'regex'}}, { regex => $regex, opts => $opts, json => $json }; } else { $hash->{helper}{$attrName}{cmds}{$cmd} = $json; } @@ -2100,7 +2108,8 @@ absent:{<json>}
  • configList
    The list of know config commands for sensor type devices. one command per line, eg.:
    attr mySensor mode:{<json>}\
    -/heatsetpoint (.*)/:perl:{'{"heatsetpoint":'. $VALUE1 * 100 .'}'}
  • +/heatsetpoint (.*)/:perl:{'{"heatsetpoint":'. $VALUE1 * 100 .'}'}
    +/sensitivity (.*)/:0,1,2,3:{"sensitivity":$1}
  • readingList
    The list of readings that should be created from the sensor state object. Space or comma separated.
  • subType