Flowset Updatemechanismus hinzugefügt, Bugfix beim erkennen von Bluetoothdevices
This commit is contained in:
		
							
								
								
									
										49
									
								
								74_AMAD.pm
									
									
									
									
									
								
							
							
						
						
									
										49
									
								
								74_AMAD.pm
									
									
									
									
									
								
							@@ -37,7 +37,8 @@ use TcpServerUtils;
 | 
			
		||||
use Encode qw(encode);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
my $version = "1.9.41";
 | 
			
		||||
my $modulversion = "1.9.53";
 | 
			
		||||
my $flowsetversion = "1.9.53";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -67,7 +68,7 @@ sub AMAD_Initialize($) {
 | 
			
		||||
    
 | 
			
		||||
    foreach my $d(sort keys %{$modules{AMAD}{defptr}}) {
 | 
			
		||||
	my $hash = $modules{AMAD}{defptr}{$d};
 | 
			
		||||
	$hash->{VERSION} 	= $version;
 | 
			
		||||
	$hash->{VERSIONMODUL} 	= $modulversion;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -88,7 +89,8 @@ sub AMAD_Define($$) {
 | 
			
		||||
    $hash->{HOST} 	= $host if( $host );
 | 
			
		||||
    $hash->{PORT} 	= $port;
 | 
			
		||||
    $hash->{APSSID}     = $apssid if( $hash->{HOST} );
 | 
			
		||||
    $hash->{VERSION} 	= $version;
 | 
			
		||||
    $hash->{VERSIONMODUL} 	= $modulversion;
 | 
			
		||||
    $hash->{VERSIONFLOWSET} 	= $flowsetversion;
 | 
			
		||||
    $hash->{helper}{infoErrorCounter} = 0 if( $hash->{HOST} );
 | 
			
		||||
    $hash->{helper}{setCmdErrorCounter} = 0 if( $hash->{HOST} );
 | 
			
		||||
 | 
			
		||||
@@ -482,6 +484,7 @@ sub AMAD_Set($$@) {
 | 
			
		||||
	$list .= "openURL ";
 | 
			
		||||
	$list .= "openApp:$apps " if( AttrVal( $name, "setOpenApp", "none" ) ne "none" );
 | 
			
		||||
	$list .= "nextAlarmTime:time ";
 | 
			
		||||
	$list .= "timer:time ";
 | 
			
		||||
	$list .= "statusRequest:noArg ";
 | 
			
		||||
	$list .= "system:reboot,shutdown,airplanemodeON " if( AttrVal( $name, "root", "0" ) eq "1" );
 | 
			
		||||
	$list .= "bluetooth:on,off ";
 | 
			
		||||
@@ -492,6 +495,7 @@ sub AMAD_Set($$@) {
 | 
			
		||||
	$list .= "volumeNotification:slider,0,1,7 ";
 | 
			
		||||
	$list .= "vibrate:noArg ";
 | 
			
		||||
	$list .= "sendIntent ";
 | 
			
		||||
	$list .= "currentFlowsetUpdate:noArg ";
 | 
			
		||||
 | 
			
		||||
	if( lc $cmd eq 'screenmsg'
 | 
			
		||||
	    || lc $cmd eq 'ttsmsg'
 | 
			
		||||
@@ -505,6 +509,7 @@ sub AMAD_Set($$@) {
 | 
			
		||||
	    || lc $cmd eq 'openurl'
 | 
			
		||||
	    || lc $cmd eq 'openapp'
 | 
			
		||||
	    || lc $cmd eq 'nextalarmtime'
 | 
			
		||||
	    || lc $cmd eq 'timer'
 | 
			
		||||
	    || lc $cmd eq 'bluetooth'
 | 
			
		||||
	    || lc $cmd eq 'system'
 | 
			
		||||
	    || lc $cmd eq 'notifysndfile'
 | 
			
		||||
@@ -515,6 +520,7 @@ sub AMAD_Set($$@) {
 | 
			
		||||
	    || lc $cmd eq 'screenlock'
 | 
			
		||||
	    || lc $cmd eq 'statusrequest'
 | 
			
		||||
	    || lc $cmd eq 'sendintent'
 | 
			
		||||
	    || lc $cmd eq 'currentflowsetupdate'
 | 
			
		||||
	    || lc $cmd eq 'vibrate') {
 | 
			
		||||
 | 
			
		||||
	    Log3 $name, 5, "AMAD ($name) - set $name $cmd ".join(" ", @val);
 | 
			
		||||
@@ -525,7 +531,7 @@ sub AMAD_Set($$@) {
 | 
			
		||||
	    return AMAD_SelectSetCmd( $hash, $cmd, @val ) if( @val ) && ( ReadingsVal( $name, "deviceState", "online" ) eq "offline" ) && ( lc $cmd eq 'devicestate' );
 | 
			
		||||
	    return "Cannot set command, FHEM Device is offline" if( ReadingsVal( $name, "deviceState", "online" ) eq "offline" );
 | 
			
		||||
	  
 | 
			
		||||
	    return AMAD_SelectSetCmd( $hash, $cmd, @val ) if( @val ) || ( lc $cmd eq 'statusrequest' ) || ( lc $cmd eq 'activatevoiceinput' ) || ( lc $cmd eq 'vibrate' );
 | 
			
		||||
	    return AMAD_SelectSetCmd( $hash, $cmd, @val ) if( @val ) || ( lc $cmd eq 'statusrequest' ) || ( lc $cmd eq 'activatevoiceinput' ) || ( lc $cmd eq 'vibrate' ) || ( lc $cmd eq 'currentflowsetupdate' );
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return "Unknown argument $cmd, bearword as argument or wrong parameter(s), choose one of $list";
 | 
			
		||||
@@ -696,6 +702,15 @@ sub AMAD_SelectSetCmd($$@) {
 | 
			
		||||
	return AMAD_HTTP_POST( $hash, $url );
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    elsif (lc $cmd eq 'timer') {
 | 
			
		||||
    
 | 
			
		||||
	my $timer = join( " ", @data );
 | 
			
		||||
 | 
			
		||||
	my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/setTimer?minute=".$timer;
 | 
			
		||||
	
 | 
			
		||||
	return AMAD_HTTP_POST( $hash, $url );
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    elsif( lc $cmd eq 'statusrequest' ) {
 | 
			
		||||
    
 | 
			
		||||
	AMAD_GetUpdate( $hash );
 | 
			
		||||
@@ -784,6 +799,13 @@ sub AMAD_SelectSetCmd($$@) {
 | 
			
		||||
	
 | 
			
		||||
	return AMAD_HTTP_POST( $hash,$url );
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    elsif( lc $cmd eq 'currentflowsetupdate' ) {
 | 
			
		||||
 | 
			
		||||
	my $url = "http://" . $host . ":" . $port . "/fhem-amad/currentFlowsetUpdate";
 | 
			
		||||
	
 | 
			
		||||
	return AMAD_HTTP_POST( $hash,$url );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return undef;
 | 
			
		||||
}
 | 
			
		||||
@@ -1001,8 +1023,21 @@ sub AMAD_CommBridge_Read($) {
 | 
			
		||||
    my $c;
 | 
			
		||||
    
 | 
			
		||||
    my $fhemcmd = $header->{FHEMCMD};
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    if ( $fhemcmd =~ /setreading\b/ ) {
 | 
			
		||||
    if ( $data[0] =~ /currentFlowsetUpdate.xml/ ) {
 | 
			
		||||
 | 
			
		||||
        $response = qx(cat /opt/fhem/FHEM/lib/74_AMADautomagicFlows_$flowsetversion.xml);
 | 
			
		||||
        $c = $hash->{CD};
 | 
			
		||||
        print $c "HTTP/1.1 200 OK\r\n",
 | 
			
		||||
            "Content-Type: text/plain\r\n",
 | 
			
		||||
            "Content-Length: ".length($response)."\r\n\r\n",
 | 
			
		||||
            $response;
 | 
			
		||||
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    elsif ( $fhemcmd =~ /setreading\b/ ) {
 | 
			
		||||
	my $tv = $data[1];
 | 
			
		||||
 | 
			
		||||
        Log3 $name, 4, "AMAD ($name) - AMAD_CommBridge: processing receive reading values - Device: $device Data: $tv";
 | 
			
		||||
@@ -1157,9 +1192,9 @@ sub AMAD_FHEM_Webdetails($$) {
 | 
			
		||||
        my ($FW_wname, $name, $room, $pageHash) = @_;       # pageHash is set for summaryFn.
 | 
			
		||||
        my $hash   = $defs{$name};
 | 
			
		||||
        
 | 
			
		||||
        return if( !defined( $hash->{VERSION} ) );
 | 
			
		||||
        return if( !defined( $hash->{VERSIONFLOWSET} ) );
 | 
			
		||||
        
 | 
			
		||||
        return "<u><b><a href='/fhem?cmd={`cat /opt/fhem/FHEM/lib/74_AMADautomagicFlows_".$version.".xml`}&XHR=1' target='_blank' type='text/xml' download='AMADautomagicFlows_".$version.".xml'>Download FlowSet-$version</a></b></u><br>"
 | 
			
		||||
        return "<br><br><u><b><a href='/fhem?cmd={`cat /opt/fhem/FHEM/lib/74_AMADautomagicFlows_".$flowsetversion.".xml`}&XHR=1' target='_blank' type='text/xml' download='AMADautomagicFlows_".$flowsetversion.".xml'>Download FlowSet-$flowsetversion</a></b></u><br><u><b><a href='/fhem?cmd={`cat /opt/fhem/FHEM/lib/74_AMADautomagicFlowsetUpdater.xml`}&XHR=1' target='_blank' type='text/xml' download='AMADautomagicFlowsetUpdater.xml'>Download FlowSet Updater</a></b></u><br><br>"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										54
									
								
								74_AMADautomagicFlowsUpdater.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								74_AMADautomagicFlowsUpdater.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,54 @@
 | 
			
		||||
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
 | 
			
		||||
<data version="1.30.0">
 | 
			
		||||
  <trigger type="http_request">
 | 
			
		||||
    <useDefaultName>false</useDefaultName>
 | 
			
		||||
    <name>HTTP Request: /fhem-amad/currentFlowsetUpdate</name>
 | 
			
		||||
    <enabled>true</enabled>
 | 
			
		||||
    <path>/fhem-amad/currentFlowsetUpdate</path>
 | 
			
		||||
    <port>8090</port>
 | 
			
		||||
    <acquireWifiLock>true</acquireWifiLock>
 | 
			
		||||
  </trigger>
 | 
			
		||||
  <action type="delete_files">
 | 
			
		||||
    <useDefaultName>true</useDefaultName>
 | 
			
		||||
    <name>Dateien löschen: /storage/emulated/0/Download/currentFlowsetUpdate.xml</name>
 | 
			
		||||
    <pathList>/storage/emulated/0/Download/currentFlowsetUpdate.xml</pathList>
 | 
			
		||||
    <showProgress>true</showProgress>
 | 
			
		||||
  </action>
 | 
			
		||||
  <action type="download_url">
 | 
			
		||||
    <useDefaultName>true</useDefaultName>
 | 
			
		||||
    <name>Download URL: http://{global_fhemip}:8090/currentFlowsetUpdate.xml to /storage/emulated/0/Download</name>
 | 
			
		||||
    <url>http://{global_fhemip}:8090/currentFlowsetUpdate.xml</url>
 | 
			
		||||
    <directory>/storage/emulated/0/Download</directory>
 | 
			
		||||
    <showProgress>true</showProgress>
 | 
			
		||||
  </action>
 | 
			
		||||
  <action type="import_flows">
 | 
			
		||||
    <useDefaultName>true</useDefaultName>
 | 
			
		||||
    <name>Flows/Widgets importieren: /storage/emulated/0/Download/currentFlowsetUpdate.xml</name>
 | 
			
		||||
    <path>/storage/emulated/0/Download/currentFlowsetUpdate.xml</path>
 | 
			
		||||
    <replace>true</replace>
 | 
			
		||||
  </action>
 | 
			
		||||
  <action type="set_flow_state">
 | 
			
		||||
    <useDefaultName>true</useDefaultName>
 | 
			
		||||
    <name>Setze Flow Status: Aktivieren {imported_flow_names,listformat,comma}</name>
 | 
			
		||||
    <enable>true</enable>
 | 
			
		||||
    <includeFlowNamePatternList>{imported_flow_names,listformat,comma}</includeFlowNamePatternList>
 | 
			
		||||
    <excludeFlowNamePatternList></excludeFlowNamePatternList>
 | 
			
		||||
  </action>
 | 
			
		||||
  <flow type="flow">
 | 
			
		||||
    <name>Update AMAD Flowset</name>
 | 
			
		||||
    <group>AMAD2 Flowset Updater</group>
 | 
			
		||||
    <enabled>true</enabled>
 | 
			
		||||
    <executionPolicy>PARALLEL</executionPolicy>
 | 
			
		||||
    <actioncontainer id="t1" x="70.0" y="1067.5">Dateien löschen: /storage/emulated/0/Download/currentFlowsetUpdate.xml</actioncontainer>
 | 
			
		||||
    <triggercontainer id="t2" x="70.0" y="52.5">
 | 
			
		||||
      <trigger>HTTP Request: /fhem-amad/currentFlowsetUpdate</trigger>
 | 
			
		||||
    </triggercontainer>
 | 
			
		||||
    <actioncontainer id="t3" x="70.0" y="787.5">Setze Flow Status: Aktivieren {imported_flow_names,listformat,comma}</actioncontainer>
 | 
			
		||||
    <actioncontainer id="t4" x="70.0" y="577.5">Flows/Widgets importieren: /storage/emulated/0/Download/currentFlowsetUpdate.xml</actioncontainer>
 | 
			
		||||
    <actioncontainer id="t5" x="70.0" y="297.5">Download URL: http://{global_fhemip}:8090/currentFlowsetUpdate.xml to /storage/emulated/0/Download</actioncontainer>
 | 
			
		||||
    <connection from="t2" to="t5" type="NORMAL" sourcePosition="SOUTH" targetPosition="NORTH" />
 | 
			
		||||
    <connection from="t3" to="t1" type="NORMAL" sourcePosition="SOUTH" targetPosition="NORTH" />
 | 
			
		||||
    <connection from="t4" to="t3" type="NORMAL" sourcePosition="SOUTH" targetPosition="NORTH" />
 | 
			
		||||
    <connection from="t5" to="t4" type="NORMAL" sourcePosition="SOUTH" targetPosition="NORTH" />
 | 
			
		||||
  </flow>
 | 
			
		||||
</data>
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user