diff --git a/73_AMADCommBridge.pm b/73_AMADCommBridge.pm
index 02988ea..b1c5321 100644
--- a/73_AMADCommBridge.pm
+++ b/73_AMADCommBridge.pm
@@ -68,8 +68,8 @@ use TcpServerUtils;
eval "use JSON;1" or $missingModul .= "JSON ";
-my $modulversion = "3.9.61";
-my $flowsetversion = "3.9.62";
+my $modulversion = "3.9.65";
+my $flowsetversion = "3.9.65";
@@ -110,8 +110,10 @@ sub AMADCommBridge_Initialize($) {
$hash->{UndefFn} = "AMADCommBridge_Undef";
$hash->{AttrFn} = "AMADCommBridge_Attr";
- $hash->{AttrList} = "expertMode:1 ".
+ $hash->{AttrList} = "fhemControlMode:trigger,setControl,thirdPartControl ".
+ "debugJSON:0,1 ".
"disable:1 ".
+ "allowFrom ".
$readingFnAttributes;
foreach my $d(sort keys %{$modules{AMADCommBridge}{defptr}}) {
@@ -195,6 +197,19 @@ sub AMADCommBridge_Attr(@) {
}
}
+ elsif( $attrName eq "fhemControlMode" ) {
+ if( $cmd eq "set" ) {
+
+ CommandSet(undef,'set TYPE=AMADDevice:FILTER=deviceState=online statusRequest');
+ Log3 $name, 3, "AMADCommBridge ($name) - set fhemControlMode global Variable at Device";
+
+ } else {
+
+ CommandSet(undef,'set TYPE=AMADDevice:FILTER=deviceState=online statusRequest');
+ Log3 $name, 3, "AMADCommBridge ($name) - set fhemControlMode global Variable NONE at Device";
+ }
+ }
+
return undef;
}
@@ -705,7 +720,14 @@ sub AMADCommBridge_ResponseProcessing($$) {
if($@){
Log3 $bname, 4, "AMADCommBridge ($name) - ERROR while request: $@";
- readingsSingleUpdate($bhash, "JSON info", "JSON ERROR", 1);
+
+ if( AttrVal( $bname, 'debugJSON', 0 ) == 1 ) {
+ readingsBeginUpdate($bhash);
+ readingsBulkUpdate($bhash, 'JSON_ERROR', $@, 1);
+ readingsBulkUpdate($bhash, 'JSON_ERROR_STRING', $json, 1);
+ readingsEndUpdate($bhash, 1);
+ }
+
$response = "header lines: \r\n AMADCommBridge receive a JSON error\r\n AMADCommBridge to do nothing\r\n";
$c = $hash->{CD};
print $c "HTTP/1.1 200 OK\r\n",
@@ -773,8 +795,8 @@ sub AMADCommBridge_ResponseProcessing($$) {
elsif ( $fhemcmd eq 'set' ) {
my $fhemCmd = $decode_json->{payload}{setcmd};
- fhem ("set $fhemCmd") if( ReadingsVal( $bname, "expertMode", 0 ) eq "1" );
- readingsSingleUpdate( $bhash, "receiveFhemCommand", "set ".$fhemCmd, 0 );
+ fhem ("set $fhemCmd") if( AttrVal( $bname, 'fhemControlMode', 'trigger' ) eq 'setControl' );
+ readingsSingleUpdate( $bhash, "receiveFhemCommand", "set ".$fhemCmd, 1 ) if( AttrVal( $bname, 'fhemControlMode', 'trigger' ) eq 'trigger' );;
Log3 $bname, 4, "AMADCommBridge ($name) - AMADCommBridge_CommBridge: set reading receive fhem command";
$response = "header lines: \r\n AMADCommBridge receive Data complete\r\n FHEM execute set command now\r\n";
@@ -792,8 +814,8 @@ sub AMADCommBridge_ResponseProcessing($$) {
my $fhemCmd = $decode_json->{payload}{voiceinputdata};
readingsBeginUpdate( $bhash);
- readingsBulkUpdateIfChanged( $bhash, "receiveVoiceCommand", $fhemCmd, 1 );
- readingsBulkUpdateIfChanged( $bhash, "receiveVoiceDevice", $fhemDevice, 1 );
+ readingsBulkUpdate( $bhash, "receiveVoiceCommand", $fhemCmd, 1 );
+ readingsBulkUpdate( $bhash, "receiveVoiceDevice", $fhemDevice, 1 );
readingsEndUpdate( $bhash, 1 );
Log3 $bname, 4, "AMADCommBridge ($name) - AMADCommBridge_CommBridge: set reading receive voice command: $fhemCmd from Device $fhemDevice";
diff --git a/74_AMADDevice.pm b/74_AMADDevice.pm
index 19037f8..86f3a79 100644
--- a/74_AMADDevice.pm
+++ b/74_AMADDevice.pm
@@ -54,8 +54,8 @@ use Encode qw(encode);
eval "use JSON;1" or $missingModul .= "JSON ";
-my $modulversion = "3.9.61";
-my $flowsetversion = "3.9.62";
+my $modulversion = "3.9.65";
+my $flowsetversion = "3.9.65";
@@ -104,7 +104,6 @@ sub AMADDevice_Initialize($) {
"setTtsMsgLang:de,en ".
"setAPSSID ".
"root:0,1 ".
- "port ".
"disable:1 ".
$readingFnAttributes;
@@ -251,34 +250,6 @@ sub AMADDevice_Attr(@) {
InternalTimer( gettimeofday(), "AMADDevice_GetUpdate", $hash, 0 )
}
- elsif( $attrName eq "port" ) {
- if( $cmd eq "set" ) {
-
- $hash->{PORT} = $attrVal;
- Log3 $name, 3, "AMADDevice ($name) - set port to $attrVal";
-
- if( $hash->{BRIDGE} ) {
- delete $modules{AMADDevice}{defptr}{BRIDGE};
- TcpServer_Close( $hash );
- Log3 $name, 3, "AMADDevice ($name) - CommBridge Port changed. CommBridge are closed and new open!";
-
- AMADDevice_CommBridge_Open( $hash );
- }
- } else {
-
- $hash->{PORT} = 8090;
- Log3 $name, 3, "AMADDevice ($name) - set port to default";
-
- if( $hash->{BRIDGE} ) {
- delete $modules{AMADDevice}{defptr}{BRIDGE};
- TcpServer_Close( $hash );
- Log3 $name, 3, "AMADDevice ($name) - CommBridge Port changed. CommBridge are closed and new open!";
-
- AMADDevice_CommBridge_Open( $hash );
- }
- }
- }
-
elsif( $attrName eq "setScreenlockPIN" ) {
if( $cmd eq "set" && $attrVal ) {
@@ -320,7 +291,6 @@ sub AMADDevice_GetUpdate($) {
my $name = $hash->{NAME};
my $bname = $hash->{IODev}->{NAME};
- RemoveInternalTimer( $hash );
if( $init_done && ( ReadingsVal( $name, "deviceState", "unknown" ) eq "unknown" or ReadingsVal( $name, "deviceState", "online" ) eq "online" ) && AttrVal( $name, "disable", 0 ) ne "1" && ReadingsVal( $bname, "fhemServerIP", "not set" ) ne "not set" ) {
@@ -353,11 +323,12 @@ sub AMADDevice_statusRequest($) {
my $userFlowState = AttrVal( $name, "setUserFlowState", "none" );
my $apssid = AttrVal( $name, "setAPSSID", "none" );
my $fhemip = ReadingsVal($hash->{IODev}->{NAME}, "fhemServerIP", "none");
+ my $fhemCtlMode = AttrVal($hash->{IODev}->{NAME},'fhemControlMode','none' );
my $bport = $hash->{IODev}->{PORT};
$uri = $host . ":" . $port . "/fhem-amad/deviceInfo/"; # Pfad muß so im Automagic als http request Trigger drin stehen
- $header .= "\r\nfhemip: $fhemip\r\nfhemdevice: $name\r\nactivetask: $activetask\r\napssid: $apssid\r\nbport: $bport\r\nuserflowstate: $userFlowState\r\namadid: $amad_id";
+ $header .= "\r\nfhemip: $fhemip\r\nfhemdevice: $name\r\nactivetask: $activetask\r\napssid: $apssid\r\nbport: $bport\r\nuserflowstate: $userFlowState\r\namadid: $amad_id\r\nfhemctlmode: $fhemCtlMode";
$method = "GET";
@@ -390,7 +361,8 @@ sub AMADDevice_WriteReadings($$) {
$v =~ s/\bnull\b/off/g if( ($t eq "nextAlarmDay" or $t eq "nextAlarmTime") and $v eq "null" );
$v =~ s/\bnull\b//g;
- readingsBulkUpdateIfChanged( $hash, $t, $v, 1 ) if( defined( $v ) );
+ readingsBulkUpdateIfChanged($hash, $t, $v, 1) if( defined( $v ) );
+ readingsBulkUpdate($hash, '.'.$t, $v) if( $t eq 'deviceState' );
}
readingsBulkUpdateIfChanged( $hash, "deviceState", "offline", 1 ) if( $decode_json->{payload}{airplanemode} && $decode_json->{payload}{airplanemode} eq "on" );
@@ -790,12 +762,11 @@ sub AMADDevice_checkDeviceState($) {
Log3 $name, 4, "AMADDevice ($name) - AMADDevice_checkDeviceState: run Check";
- RemoveInternalTimer( $hash );
- if( ReadingsAge( $name, "deviceState", 240 ) > 240 ) {
+ if( ReadingsAge( $name, ".deviceState", 240 ) > 240 ) {
AMADDevice_statusRequest( $hash ) if( $hash->{helper}{deviceStateErrorCounter} == 0 );
- readingsSingleUpdate( $hash, "deviceState", "offline", 1 ) if( ReadingsAge( $name, "deviceState", 300) > 300 and $hash->{helper}{deviceStateErrorCounter} > 0 );
+ readingsSingleUpdate( $hash, "deviceState", "offline", 1 ) if( ReadingsAge( $name, ".deviceState", 300) > 300 and $hash->{helper}{deviceStateErrorCounter} > 0 );
$hash->{helper}{deviceStateErrorCounter} = ( $hash->{helper}{deviceStateErrorCounter} + 1 );
}
diff --git a/74_AMADautomagicFlowset_3.9.62.xml b/74_AMADautomagicFlowset_3.9.65.xml
similarity index 88%
rename from 74_AMADautomagicFlowset_3.9.62.xml
rename to 74_AMADautomagicFlowset_3.9.65.xml
index adaf11f..d08d17f 100644
--- a/74_AMADautomagicFlowset_3.9.62.xml
+++ b/74_AMADautomagicFlowset_3.9.65.xml
@@ -569,6 +569,11 @@ irname=getString("name")
Expression: global_activetask != null
global_activetask != null
+
+ true
+ Expression: global_fhemctlmode != "thirdPartControl"
+ global_fhemctlmode != "thirdPartControl"
+
true
Expression: global_fhemip != null or global_bridgeport != null
@@ -2054,6 +2059,9 @@ Connection: close
if (global_bridgeport != {header_bport}) {
global_bridgeport = {header_bport} }
+if (header_fhemctlmode != null or header_fhemctlmode != {global_fhemctlmode}) {
+ global_fhemctlmode = {header_fhemctlmode} }
+
if (header_fhemip != null or header_fhemip != {global_fhemip}) {
global_fhemip = {header_fhemip} }
@@ -2636,7 +2644,7 @@ fhemcmd = "setreading";
false
Script: Set FHEMDATA JSON
-