mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-09 20:57:11 +00:00
31HUEDevice: added configList attribute
added optional setsensor|configsensor param to set json git-svn-id: https://svn.fhem.de/fhem/trunk@19652 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
c3a133a9bc
commit
2e96d6afd6
@ -1,5 +1,7 @@
|
||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||
# Do not insert empty lines here, update check depends on it.
|
||||
- feature: 31HUEDevice: added configList attribute
|
||||
added optional setsensor|configsensor param to set json
|
||||
- bugfix: 73_AMADCommBridge: fix $version bug
|
||||
- update: 95_Astro: v2.0.0
|
||||
device attributes for language, timezone and locale settings
|
||||
|
@ -178,6 +178,7 @@ sub HUEDevice_Initialize($)
|
||||
"transitiontime ".
|
||||
"model:".join(",", sort map { $_ =~ s/ /#/g ;$_} keys %hueModels)." ".
|
||||
"setList:textField-long ".
|
||||
"configList:textField-long ".
|
||||
"subType:extcolordimmer,colordimmer,ctdimmer,dimmer,switch ".
|
||||
$readingFnAttributes;
|
||||
|
||||
@ -701,7 +702,12 @@ HUEDevice_Set($@)
|
||||
return undef;
|
||||
|
||||
} elsif( $cmd eq 'json' ) {
|
||||
return HUEBridge_Set( $shash, $shash->{NAME}, 'setsensor', $id, @args );
|
||||
return "usage: json [setsensor|configsensor] <json>" if( !@args );
|
||||
my $type = 'setsensor';
|
||||
if( $args[0] eq 'setsensor' || $args[0] eq 'configsensor' ) {
|
||||
$type = shift @args;
|
||||
}
|
||||
return HUEBridge_Set( $shash, $shash->{NAME}, $type, $id, @args );
|
||||
|
||||
return undef;
|
||||
|
||||
@ -722,6 +728,24 @@ HUEDevice_Set($@)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} elsif( my @match = grep { $cmd eq $_ } keys %{($hash->{helper}{configList}{cmds}?$hash->{helper}{configList}{cmds}:{})} ) {
|
||||
return HUEBridge_Set( $shash, $shash->{NAME}, 'configsensor', $id, $hash->{helper}{configList}{cmds}{$match[0]} );
|
||||
|
||||
} elsif( my $entries = $hash->{helper}{configList}{regex} ) {
|
||||
foreach my $entry (@{$entries}) {
|
||||
if( join(' ', @aa) =~ /$entry->{regex}/ ) {
|
||||
my $VALUE1 = $1;
|
||||
my $VALUE2 = $2;
|
||||
my $VALUE3 = $3;
|
||||
my $json = $entry->{json};
|
||||
$json =~ s/\$1/$VALUE1/;
|
||||
$json =~ s/\$2/$VALUE2/;
|
||||
$json =~ s/\$3/$VALUE3/;
|
||||
return HUEBridge_Set( $shash, $shash->{NAME}, 'configsensor', $id, $json );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $list = 'statusRequest:noArg';
|
||||
@ -734,6 +758,14 @@ HUEDevice_Set($@)
|
||||
$list .= (split( ' ', $entry->{regex} ))[0];
|
||||
}
|
||||
}
|
||||
$list .= ' '. join( ':noArg ', keys %{$hash->{helper}{configList}{cmds}} ) if( $hash->{helper}{configList}{cmds} );
|
||||
$list .= ':noArg' if( $hash->{helper}{configList}{cmds} );
|
||||
if( my $entries = $hash->{helper}{configList}{regex} ) {
|
||||
foreach my $entry (@{$entries}) {
|
||||
$list .= ' ';
|
||||
$list .= (split( ' ', $entry->{regex} ))[0];
|
||||
}
|
||||
}
|
||||
|
||||
return SetExtensions($hash, $list, $name, @aa);
|
||||
}
|
||||
@ -1584,20 +1616,20 @@ HUEDevice_Attr($$$;$)
|
||||
{
|
||||
my ($cmd, $name, $attrName, $attrVal) = @_;
|
||||
|
||||
if( $attrName eq "setList" ) {
|
||||
if( $attrName eq 'setList' || $attrName eq 'configList' ) {
|
||||
my $hash = $defs{$name};
|
||||
delete $hash->{helper}{setList};
|
||||
delete $hash->{helper}{$attrName};
|
||||
return "$name is not a sensor device" if( $hash->{helper}->{devtype} ne 'S' );
|
||||
return "$name is not a CLIP sensor device" if( $hash->{type} && $hash->{type} !~ m/^CLIP/ );
|
||||
#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 );
|
||||
if( $cmd =~ m'^/(.*)/$' ) {
|
||||
my $regex = $1;
|
||||
$hash->{helper}{setList}{'regex'} = [] if( !$hash->{helper}{setList}{':regex'} );
|
||||
push @{$hash->{helper}{setList}{'regex'}}, { regex => $regex, json => $json };
|
||||
$hash->{helper}{$attrName}{'regex'} = [] if( !$hash->{helper}{$attrName}{'regex'} );
|
||||
push @{$hash->{helper}{$attrName}{'regex'}}, { regex => $regex, json => $json };
|
||||
} else {
|
||||
$hash->{helper}{setList}{cmds}{$cmd} = $json;
|
||||
$hash->{helper}{$attrName}{cmds}{$cmd} = $json;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1724,6 +1756,8 @@ HUEDevice_Attr($$$;$)
|
||||
The lights are given as a comma sparated list of fhem device names or bridge light numbers.</li>
|
||||
<li>rename <new name><br>
|
||||
Renames the device in the bridge and changes the fhem alias.</li>
|
||||
<li>json [setsensor|configsensor] <json><br>
|
||||
send <json> to the state or config endpoints for this device.</li>
|
||||
<br>
|
||||
<li><a href="#setExtensions"> set extensions</a> are supported.</li>
|
||||
<br>
|
||||
@ -1764,6 +1798,9 @@ HUEDevice_Attr($$$;$)
|
||||
The list of know set commands for sensor type devices. one command per line, eg.: <code><br>
|
||||
attr mySensor setList present:{<json>}\<br>
|
||||
absent:{<json>}</code></li>
|
||||
<li>configList<br>
|
||||
The list of know config commands for sensor type devices. one command per line, eg.: <code><br>
|
||||
mode:{<json>}</code></li>
|
||||
<li>subType<br>
|
||||
extcolordimmer -> device has rgb and color temperatur control<br>
|
||||
colordimmer -> device has rgb controll<br>
|
||||
|
Loading…
x
Reference in New Issue
Block a user