2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-01 01:09:47 +00:00

73_km200.pm: Feature service info for get command.

git-svn-id: https://svn.fhem.de/fhem/trunk@12148 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
sailor-fhem 2016-09-12 19:22:33 +00:00
parent d0bd6cd591
commit aaaf56cdd1

View File

@ -1579,9 +1579,9 @@ sub km200_GetSingleService($)
my $JsonType = $json->{type};
### Log entries for debugging purposes
Log3 $name, 4, $name. " : km200_parseHttpResponseDyn - value found for : " .$Service;
Log3 $name, 5, $name. " : km200_parseHttpResponseDyn - id : " .$JsonId;
Log3 $name, 5, $name. " : km200_parseHttpResponseDyn - type : " .$JsonType;
Log3 $name, 4, $name. " : km200_GetSingleService - value found for : " .$Service;
Log3 $name, 5, $name. " : km200_GetSingleService - id : " .$JsonId;
Log3 $name, 5, $name. " : km200_GetSingleService - type : " .$JsonType;
### Set up variables
my $TempReturnVal = "";
@ -1831,6 +1831,59 @@ sub km200_GetSingleService($)
return $json;
}
### Check whether the type is a systeminfo
elsif ($json -> {type} eq "systeminfo")
{
my $JsonId = $json->{id};
my $JsonType = $json->{type};
my @JsonValues = $json->{values};
### Log entries for debugging purposes
Log3 $name, 4, $name. " : km200_GetSingleService - value found for : " .$Service;
Log3 $name, 5, $name. " : km200_GetSingleService - id : " .$JsonId;
Log3 $name, 5, $name. " : km200_GetSingleService - type : " .$JsonType;
### Initialise Return Message
my $ReturnMessage = "";
### Initialise ArrayCounter
my $ArrayCounter = 0;
foreach my $ArrayItem (@{ $json->{values} })
{
### Incrementation of ArrayCounter
$ArrayCounter++;
### Get array from scalar
my %ArrayHash = %{$ArrayItem};
while( my( $SystemInfoHashKey, $SystemInfoHashValue ) = each %ArrayHash )
{
### Create new Service and write reading for fhem
my $TempJsonId = $JsonId . "/" . sprintf ('%02d', $ArrayCounter) . "/" . $SystemInfoHashKey;
readingsSingleUpdate( $hash, $TempJsonId, $SystemInfoHashValue, 1);
### If it is the first item in the list
if ($ReturnMessage eq "")
{
$ReturnMessage = $TempJsonId . " = " . $SystemInfoHashValue;
}
### If it is not the first item in the list
else
{
$ReturnMessage = $ReturnMessage . "\n" . $TempJsonId . " = " . $SystemInfoHashValue;
}
}
}
### Return list of available directories
$json->{value} = $ReturnMessage;
### Save raw Json string
$hash->{temp}{JsonRaw} = $decodedContent;
return $json;
}
### If the type is unknown
else
{