98_Hyperion.pm: use decode_json instead of from_json

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@13366 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
deespe 2017-02-08 21:20:47 +00:00
parent 78fb1e5e19
commit 93003cbe2c

View File

@ -90,7 +90,7 @@ sub Hyperion_Define($$)
} }
$hash->{IP} = $host; $hash->{IP} = $host;
$hash->{PORT} = $port; $hash->{PORT} = $port;
$hash->{DeviceName} = $host.":".$port; $hash->{DeviceName} = "$host:$port";
$interval = undef unless defined $interval; $interval = undef unless defined $interval;
$interval = 5 if ($interval && $interval < 5); $interval = 5 if ($interval && $interval < 5);
RemoveInternalTimer($hash); RemoveInternalTimer($hash);
@ -224,7 +224,7 @@ sub Hyperion_Read($)
Log3 $name,5,"$name: url ".$hash->{DeviceName}." returned result: $result"; Log3 $name,5,"$name: url ".$hash->{DeviceName}." returned result: $result";
delete $hash->{PARTIAL}; delete $hash->{PARTIAL};
$result =~ /(\s+)?\/{2,}.*|(?:[\t ]*(?:\r?\n|\r))+/gm; $result =~ /(\s+)?\/{2,}.*|(?:[\t ]*(?:\r?\n|\r))+/gm;
if ($result=~ /^\{"success":true\}$/) if ($result =~ /^\{"success":true\}$/)
{ {
fhem "sleep 1; get $name statusRequest" fhem "sleep 1; get $name statusRequest"
if (AttrVal($name,"queryAfterSet",1) == 1 || !$hash->{INTERVAL}); if (AttrVal($name,"queryAfterSet",1) == 1 || !$hash->{INTERVAL});
@ -232,7 +232,7 @@ sub Hyperion_Read($)
} }
elsif ($result =~ /^\{"info":\{.+\},"success":true\}$/) elsif ($result =~ /^\{"info":\{.+\},"success":true\}$/)
{ {
my $obj = eval {from_json($result)}; my $obj = eval {decode_json($result)};
my $data = $obj->{info}; my $data = $obj->{info};
if (AttrVal($name,"hyperionVersionCheck",1) == 1) if (AttrVal($name,"hyperionVersionCheck",1) == 1)
{ {
@ -602,7 +602,7 @@ sub Hyperion_Set($@)
{ {
return "Effect $value is not available in the effect list of $name!" return "Effect $value is not available in the effect list of $name!"
if ($value !~ /^([\w-]+)$/ || index(ReadingsVal($name,".effects",""),$value) == -1); if ($value !~ /^([\w-]+)$/ || index(ReadingsVal($name,".effects",""),$value) == -1);
my $arg = $args[3]?eval{from_json $args[3]}:""; my $arg = $args[3] ? eval{decode_json $args[3]} : "";
my $ce = $hash->{helper}{customeffects}; my $ce = $hash->{helper}{customeffects};
if (!$arg && $ce) if (!$arg && $ce)
{ {
@ -826,12 +826,12 @@ sub Hyperion_Attr(@)
{ {
foreach my $eff (@custeffs) foreach my $eff (@custeffs)
{ {
push @effs,eval{from_json $eff}; push @effs,eval{decode_json $eff};
} }
} }
else else
{ {
push @effs,eval{from_json $attr_value}; push @effs,eval{decode_json $attr_value};
} }
$hash->{helper}{customeffects} = \@effs; $hash->{helper}{customeffects} = \@effs;
Hyperion_Call($hash); Hyperion_Call($hash);