AMAD Bridge nun vollständig integriert, 2 Funkrionen innerhalb des Information und setCommands Flows wurden bereits auf die Bridge Kommunikation umgestellt. Bsp, setzen der Music Metachanged Readings Album,Artist und so. Ausserdem wird das anfordern eines statusRequest nach erfolreichen setCommand nun über das Bridge Device durchgeführt. ES IST ZWINGEND NOTWENDIG DAS DAS ATTRIBUT fhemServerIP GESETZT WIRD
This commit is contained in:
parent
a1a1feb2d4
commit
dc15053fba
74
74_AMAD.pm
74
74_AMAD.pm
@ -35,7 +35,7 @@ use Time::HiRes qw(gettimeofday);
|
||||
use HttpUtils;
|
||||
use TcpServerUtils;
|
||||
|
||||
my $version = "0.7.1";
|
||||
my $version = "0.7.2";
|
||||
|
||||
|
||||
|
||||
@ -514,9 +514,6 @@ sub AMAD_SelectSetCmd($$@) {
|
||||
|
||||
readingsSingleUpdate( $hash, $cmd, $vol, 1 );
|
||||
|
||||
Log3 $name, 4, "AMAD ($name) - Starte Update GetUpdateLocal";
|
||||
AMAD_GetUpdateLocal( $hash );
|
||||
|
||||
return AMAD_HTTP_POST( $hash, $url );
|
||||
}
|
||||
|
||||
@ -541,9 +538,6 @@ sub AMAD_SelectSetCmd($$@) {
|
||||
|
||||
my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/setBrightness?brightness=$bri";
|
||||
|
||||
Log3 $name, 4, "AMAD ($name) - Starte Update GetUpdateLocal";
|
||||
AMAD_GetUpdateLocal( $hash );
|
||||
|
||||
return AMAD_HTTP_POST( $hash,$url );
|
||||
}
|
||||
|
||||
@ -552,9 +546,6 @@ sub AMAD_SelectSetCmd($$@) {
|
||||
|
||||
my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/setScreenOnOff?screen=$mod";
|
||||
|
||||
Log3 $name, 4, "AMAD ($name) - Starte Update GetUpdateLocal";
|
||||
AMAD_GetUpdateLocal( $hash );
|
||||
|
||||
return AMAD_HTTP_POST( $hash,$url );
|
||||
}
|
||||
|
||||
@ -563,9 +554,6 @@ sub AMAD_SelectSetCmd($$@) {
|
||||
|
||||
my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/setScreenOrientation?orientation=$mod";
|
||||
|
||||
Log3 $name, 4, "AMAD ($name) - Starte Update GetUpdateLocal";
|
||||
AMAD_GetUpdateLocal( $hash );
|
||||
|
||||
return AMAD_HTTP_POST( $hash,$url );
|
||||
}
|
||||
|
||||
@ -593,9 +581,6 @@ sub AMAD_SelectSetCmd($$@) {
|
||||
|
||||
my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/setAlarm?hour=".$alarm[0]."&minute=".$alarm[1];
|
||||
|
||||
Log3 $name, 4, "AMAD ($name) - Starte Update GetUpdateLocal";
|
||||
AMAD_GetUpdateLocal( $hash );
|
||||
|
||||
return AMAD_HTTP_POST( $hash, $url );
|
||||
}
|
||||
|
||||
@ -789,13 +774,12 @@ sub AMAD_CommBridge_Read($) {
|
||||
|
||||
my ( $hash ) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
#my $chash = $modules{AMAD}{defptr}{<ip>};
|
||||
my $brihash = $modules{AMAD}{defptr}{BRIDGE};
|
||||
|
||||
# Received chars stored in $c
|
||||
|
||||
if( $hash->{SERVERSOCKET} ) { # Accept and create a child
|
||||
TcpServer_Accept( $hash, "AMAD" );
|
||||
# my $chash = TcpServer_Accept( $hash, "AMAD" ); # Wird zum schließen der Verbindung benötigt, siehe unten
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -809,7 +793,7 @@ sub AMAD_CommBridge_Read($) {
|
||||
return;
|
||||
}
|
||||
|
||||
my $response = "header lines: \r\nAMADCommBridge recive Data complete\r\nPlease see next\r\n\r\nrunnin\r\n";
|
||||
my $response = "header lines: \r\n AMADCommBridge receive Data complete\r\n FHEM will process\r\n now\r\n";
|
||||
|
||||
my $c = $hash->{CD};
|
||||
print $c "HTTP/1.1 200 OK\r\n",
|
||||
@ -823,28 +807,60 @@ sub AMAD_CommBridge_Read($) {
|
||||
|
||||
|
||||
|
||||
|
||||
###
|
||||
## Consume Content
|
||||
###
|
||||
|
||||
my @data = split( '\R\R', $buf );
|
||||
if ( $data[0] =~ /FHEMCMD: setreading\b/ ) {
|
||||
|
||||
Log3 $name, 3, "setreading ist gleich $data[1]";
|
||||
if ( $data[0] =~ /FHEMCMD: setreading\b/ ) {
|
||||
my $tv = $data[1];
|
||||
|
||||
@data = split( '\R', $data[0] );
|
||||
$data[2] =~ s/FHEMDEVICE: //;
|
||||
my $chash = $defs{$data[2]};
|
||||
### Begin Response Processing
|
||||
|
||||
my @valuestring = split( '@@@@', $tv );
|
||||
my %buffer;
|
||||
|
||||
foreach( @valuestring ) {
|
||||
my @values = split( '@@' , $_ );
|
||||
$buffer{$values[0]} = $values[1];
|
||||
}
|
||||
|
||||
my $t;
|
||||
my $v;
|
||||
while( ( $t, $v ) = each %buffer ) {
|
||||
$v =~ s/null//g;
|
||||
|
||||
readingsBeginUpdate( $chash );
|
||||
readingsBulkUpdate( $chash, $t, $v ) if( defined( $v ) );
|
||||
}
|
||||
|
||||
readingsBulkUpdate( $chash, "lastStatusRequestState", "statusRequest_done" );
|
||||
readingsEndUpdate( $chash, 1 );
|
||||
### End Response Processing
|
||||
|
||||
return;
|
||||
#return AMAD_RetrieveAutomagicInfoFinished( "test", "err", $data[1] );
|
||||
}
|
||||
|
||||
elsif ( $data[0] =~ /FHEMCMD: set\b/ ) {
|
||||
readingsBeginUpdate( $brihash );
|
||||
readingsBulkUpdate ( $brihash, "lastCmd", $data[1] );
|
||||
my $fhemCmd = $data[1];
|
||||
|
||||
@data = split( '\n', $data[0] );
|
||||
fhem ("$fhemCmd") if( AttrVal( "AMADCommBridge", "Expert", "0" ) eq "1" );
|
||||
readingsSingleUpdate( $brihash, "receiveFhemCommand", $fhemCmd, 1 );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
elsif ( $data[0] =~ /FHEMCMD: statusrequest\b/ ) {
|
||||
|
||||
@data = split( '\R', $data[0] );
|
||||
$data[2] =~ s/FHEMDEVICE: //;
|
||||
my $chash = $defs{$data[2]};
|
||||
|
||||
readingsBulkUpdate ( $brihash, "lastCmdDevice", $data[2] );
|
||||
readingsEndUpdate( $brihash, 1 );
|
||||
return AMAD_GetUpdateLocal( $chash );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user