neue Art des Parsens

This commit is contained in:
Marko Oldenburg
2015-12-01 20:58:45 +01:00
parent 6eebf2d240
commit 8ee9e6362e

View File

@ -35,15 +35,7 @@ use Time::HiRes qw(gettimeofday);
use HttpUtils; use HttpUtils;
use TcpServerUtils; use TcpServerUtils;
my $version = "0.0.9"; my $version = "0.1.0";
# my %jsonCmd = ( Wird gebraucht wenn wir auf die JSON Schnittstelle umstellen
#);
@ -92,7 +84,7 @@ sub HOMEBOT_Define($$) {
#readingsSingleUpdate ( $hash, "state", "initialized", 1 ); bleibt solange bis ein Request gemacht werden kann und Readings angelegt #readingsSingleUpdate ( $hash, "state", "initialized", 1 ); bleibt solange bis ein Request gemacht werden kann und Readings angelegt
readingsSingleUpdate ( $hash, "state", "active", 1 ); readingsSingleUpdate ( $hash, "state", "active", 1 );
#InternalTimer( gettimeofday()+$hash->{INTERVAL}, "HOMEBOT_Get_stateRequest", $hash, 0 ); zum testen deaktiviert InternalTimer( gettimeofday()+$hash->{INTERVAL}, "HOMEBOT_Get_stateRequest", $hash, 0 );
return undef; return undef;
} }
@ -202,7 +194,7 @@ sub HOMEBOT_RetrieveHomebotInfomations($) {
my $port = $hash->{PORT}; my $port = $hash->{PORT};
my $url = "http://" . $host . ":" . $port . "/status.txt"; # Path muß so im Automagic als http request Trigger drin stehen my $url = "http://" . $host . ":" . $port . "/status.txt";
HttpUtils_NonblockingGet( HttpUtils_NonblockingGet(
@ -323,12 +315,12 @@ sub HOMEBOT_Parse_HomebotInfomations($$$) {
### Begin Parse Processing ### Begin Parse Processing
readingsSingleUpdate( $hash, "state", "active", 1) if( ReadingsVal( $name, "state", 0 ) ne "initialized" or ReadingsVal( $name, "state", 0 ) ne "active" ); readingsSingleUpdate( $hash, "state", "active", 1) if( ReadingsVal( $name, "state", 0 ) ne "initialized" or ReadingsVal( $name, "state", 0 ) ne "active" );
my @valuestring = split( '\R', $data ); my @valuestring = split( '\R', $data );
my %buffer; my %buffer;
foreach( @valuestring ) { foreach( @valuestring ) {
my @values = split( '="' , $_ ); my @values = split( '="' , $_ );
$buffer{$values[0]} = $values[1]; $buffer{$values[0]} = $values[1];
} }
@ -340,10 +332,8 @@ sub HOMEBOT_Parse_HomebotInfomations($$$) {
my $v; my $v;
while( ( $t, $v ) = each %buffer ) { while( ( $t, $v ) = each %buffer ) {
$v =~ s/"//g;
$v =~ tr/"//d;
printf "\nReading: $t - Value: $v\n";
readingsBulkUpdate( $hash, $t, $v ) if( defined( $v ) ); readingsBulkUpdate( $hash, $t, $v ) if( defined( $v ) );
} }