mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-01 20:20:10 +00:00
30_HUEBridge.pm: allow spaces in updateschedule json
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@21366 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
5cf63ad3af
commit
d2ccc60ebe
@ -799,7 +799,7 @@ HUEBridge_Set($@)
|
|||||||
|
|
||||||
} elsif($cmd eq 'createrule' || $cmd eq 'updaterule') {
|
} elsif($cmd eq 'createrule' || $cmd eq 'updaterule') {
|
||||||
return "usage: createrule <name> <conditions&actions json>" if( $cmd eq 'createrule' && @args < 2 );
|
return "usage: createrule <name> <conditions&actions json>" if( $cmd eq 'createrule' && @args < 2 );
|
||||||
return "usage: updaterule <id> <conditions&actions json>" if( $cmd eq 'updaterule' && @args != 2 );
|
return "usage: updaterule <id> <conditions&actions json>" if( $cmd eq 'updaterule' && @args < 2 );
|
||||||
|
|
||||||
$args[@args-1] = '
|
$args[@args-1] = '
|
||||||
{ "name":"Wall Switch Rule",
|
{ "name":"Wall Switch Rule",
|
||||||
@ -809,7 +809,7 @@ HUEBridge_Set($@)
|
|||||||
"actions":[
|
"actions":[
|
||||||
{"address":"/groups/0/action","method":"PUT", "body":{"scene":"S3"}}
|
{"address":"/groups/0/action","method":"PUT", "body":{"scene":"S3"}}
|
||||||
]}' if( 0 || !$args[@args-1] );
|
]}' if( 0 || !$args[@args-1] );
|
||||||
my $json = $args[@args-1];
|
my $json = join( ' ', @args[1..@args-1]);
|
||||||
my $obj = eval { JSON->new->utf8(0)->decode($json) };
|
my $obj = eval { JSON->new->utf8(0)->decode($json) };
|
||||||
if( $@ ) {
|
if( $@ ) {
|
||||||
Log3 $name, 2, "$name: json error: $@ in $json";
|
Log3 $name, 2, "$name: json error: $@ in $json";
|
||||||
@ -830,10 +830,10 @@ HUEBridge_Set($@)
|
|||||||
return undef;
|
return undef;
|
||||||
|
|
||||||
} elsif($cmd eq 'updateschedule') {
|
} elsif($cmd eq 'updateschedule') {
|
||||||
return "usage: updateschedule <id> <attributes json>" if( @args != 2 );
|
return "usage: $cmd <id> <attributes json>" if( @args < 2 );
|
||||||
return "$arg is not a hue schedule number" if( $arg !~ m/^\d+$/ );
|
return "$arg is not a hue schedule number" if( $arg !~ m/^\d+$/ );
|
||||||
|
|
||||||
my $json = $args[@args-1];
|
my $json = join( ' ', @args[1..@args-1]);
|
||||||
my $obj = eval { JSON->new->utf8(0)->decode($json) };
|
my $obj = eval { JSON->new->utf8(0)->decode($json) };
|
||||||
if( $@ ) {
|
if( $@ ) {
|
||||||
Log3 $name, 2, "$name: json error: $@ in $json";
|
Log3 $name, 2, "$name: json error: $@ in $json";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user