diff --git a/73_AMADCommBridge.pm b/73_AMADCommBridge.pm
new file mode 100644
index 0000000..46315e0
--- /dev/null
+++ b/73_AMADCommBridge.pm
@@ -0,0 +1,1100 @@
+###############################################################################
+#
+# Developed with Kate
+#
+# (c) 2015-2017 Copyright: Marko Oldenburg (leongaultier at gmail dot com)
+# All rights reserved
+#
+# This script is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# any later version.
+#
+# The GNU General Public License can be found at
+# http://www.gnu.org/copyleft/gpl.html.
+# A copy is found in the textfile GPL.txt and important notices to the license
+# from the author is found in LICENSE.txt distributed with these scripts.
+#
+# This script is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+#
+# $Id$
+#
+###############################################################################
+##
+##
+## Das JSON Modul immer in einem eval aufrufen
+# $data = eval{decode_json($data)};
+#
+# if($@){
+# Log3($SELF, 2, "$TYPE ($SELF) - error while request: $@");
+#
+# readingsSingleUpdate($hash, "state", "error", 1);
+#
+# return;
+# }
+#
+#
+###### Möglicher Aufbau eines JSON Strings für die AMADCommBridge
+#
+# first initial String
+# {"amad": {"amad_id": "1495827100156","fhemcmd": "setreading"},"firstrun": {"fhemdevice": "TabletWohnzimmer","fhemserverip": "fhem02.tuxnet.local","amaddevice_ip": "10.6.9.35"}}
+# {"amad": {"amad_id": "1495827100156","fhemcmd": "setreading"},"firstrun": {"fhemdevice": "TabletWohnzimmer","fhemserverip": "fhem02.tuxnet.local","amaddevice_ip": "10.6.9.35"}}
+#
+# default String
+# {"amad": {"amad_id": "37836534","fhemcmd": "setreading"},"payload": {"reading0": "value0","reading1": "value1","readingX": "valueX"}}
+# Aufruf zum testens
+# curl --data '{"amad": {"amad_id": "37836534","fhemcmd": "setreading"},"payload": {"reading0": "value0","reading1": "value1","readingX": "valueX"}}' localhost:8090
+#
+#
+##
+##
+
+
+
+package main;
+
+
+my $missingModul = "";
+
+use strict;
+use warnings;
+
+use HttpUtils;
+use TcpServerUtils;
+
+eval "use Encode qw(encode encode_utf8);1" or $missingModul .= "Encode ";
+eval "use JSON;1" or $missingModul .= "JSON ";
+
+
+my $modulversion = "4.0.0";
+my $flowsetversion = "4.0.0";
+
+
+
+
+# Declare functions
+sub AMADCommBridge_Attr(@);
+sub AMADCommBridge_Open($);
+sub AMADCommBridge_Read($);
+sub AMADCommBridge_Define($$);
+sub AMADCommBridge_Initialize($);
+sub AMADCommBridge_Set($@);
+sub AMADCommBridge_Write($@);
+sub AMADCommBridge_Undef($$);
+sub AMADCommBridge_ResponseProcessing($$);
+sub AMADCommBridge_Close($);
+sub AMADCommBridge_ErrorHandling($$$);
+sub AMADCommBridge_ProcessRead($$);
+sub AMADCommBridge_ParseMsg($$);
+
+
+
+
+sub AMADCommBridge_Initialize($) {
+
+ my ($hash) = @_;
+
+
+ # Provider
+ $hash->{ReadFn} = "AMADCommBridge_Read";
+ $hash->{WriteFn} = "AMADCommBridge_Write";
+ $hash->{Clients} = ":AMADDevice:";
+ $hash->{MatchList} = { "1:AMADDevice" => '{"amad": \{"amad_id":.+}}' };
+
+
+ # Consumer
+ $hash->{SetFn} = "AMADCommBridge_Set";
+ $hash->{DefFn} = "AMADCommBridge_Define";
+ $hash->{UndefFn} = "AMADCommBridge_Undef";
+
+ $hash->{AttrFn} = "AMADCommBridge_Attr";
+ $hash->{AttrList} = "fhemControlMode:trigger,setControl,thirdPartControl ".
+ "debugJSON:0,1 ".
+ "disable:1 ".
+ "allowFrom ".
+ $readingFnAttributes;
+
+ foreach my $d(sort keys %{$modules{AMADCommBridge}{defptr}}) {
+
+ my $hash = $modules{AMADCommBridge}{defptr}{$d};
+ $hash->{VERSIONMODUL} = $modulversion;
+ $hash->{VERSIONFLOWSET} = $flowsetversion;
+ }
+}
+
+sub AMADCommBridge_Define($$) {
+
+ my ( $hash, $def ) = @_;
+
+ my @a = split( "[ \t][ \t]*", $def );
+
+
+ return "too few parameters: define AMADCommBridge ''" if( @a < 2 and @a > 3 );
+ return "Cannot define a HEOS device. Perl modul $missingModul is missing." if ( $missingModul );
+
+ my $name = $a[0];
+
+ my $port;
+ $port = $a[2] if($a[2]);
+ $port = 8090 if( not defined($port) and (!$port) );
+
+ $hash->{BRIDGE} = 1;
+ $hash->{PORT} = $port;
+ $hash->{VERSIONMODUL} = $modulversion;
+ $hash->{VERSIONFLOWSET} = $flowsetversion;
+
+
+ $attr{$name}{room} = "AMAD" if( !defined( $attr{$name}{room} ) );
+
+ Log3 $name, 3, "AMADCommBridge ($name) - defined AMADCommBridge with Socketport $port";
+
+ AMADCommBridge_Open( $hash );
+
+ $modules{AMADCommBridge}{defptr}{BRIDGE} = $hash;
+
+ return undef;
+}
+
+sub AMADCommBridge_Undef($$) {
+
+ my ( $hash, $arg ) = @_;
+
+
+ delete $modules{AMADCommBridge}{defptr}{BRIDGE} if( defined($modules{AMADCommBridge}{defptr}{BRIDGE}) and $hash->{BRIDGE} );
+ TcpServer_Close( $hash );
+
+ return undef;
+}
+
+sub AMADCommBridge_Attr(@) {
+
+ my ( $cmd, $name, $attrName, $attrVal ) = @_;
+ my $hash = $defs{$name};
+
+ my $orig = $attrVal;
+
+ if( $attrName eq "disable" ) {
+ if( $cmd eq "set" ) {
+ if( $attrVal eq "0" ) {
+
+ readingsSingleUpdate ( $hash, "state", "enabled", 1 );
+ AMADCommBridge_Open($hash);
+ Log3 $name, 3, "AMADCommBridge ($name) - enabled";
+ } else {
+
+ AMADCommBridge_Close($hash);
+ readingsSingleUpdate ( $hash, "state", "disabled", 1 ) if( not defined($hash->{FD}) );
+ Log3 $name, 3, "AMADCommBridge ($name) - disabled";
+ }
+
+ } else {
+
+ readingsSingleUpdate ( $hash, "state", "enabled", 1 );
+ AMADCommBridge_Open($hash);
+ Log3 $name, 3, "AMADCommBridge ($name) - enabled";
+ }
+ }
+
+ 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;
+}
+
+sub AMADCommBridge_Set($@) {
+
+ my ($hash, $name, $cmd, @args) = @_;
+ my ($arg, @params) = @args;
+
+
+ if( $cmd eq 'open' ) {
+
+ AMADCommBridge_Open($hash);
+
+ } elsif( $cmd eq 'close' ) {
+
+ AMADCommBridge_Close($hash);
+
+ } elsif( $cmd eq 'fhemServerIP' ) {
+
+ readingsSingleUpdate($hash,$cmd,$arg,1);
+
+ } else {
+ my $list = "open:noArg close:noArg fhemServerIP";
+ return "Unknown argument $cmd, choose one of $list";
+ }
+}
+
+sub AMADCommBridge_Write($@) {
+
+ my ($hash,$amad_id,$uri,$header,$method) = @_;
+ my $name = $hash->{NAME};
+
+
+ HttpUtils_NonblockingGet(
+ {
+ url => "http://" . $uri,
+ timeout => 15,
+ hash => $hash,
+ amad_id => $amad_id,
+ method => $method,
+ header => $header,
+ doTrigger => 1,
+ callback => \&AMADCommBridge_ErrorHandling,
+ }
+ );
+
+ Log3 $name, 5, "AMADCommBridge ($name) - Send with URI: $uri, HEADER: $header, METHOD: $method";
+}
+
+sub AMADCommBridge_ErrorHandling($$$) {
+
+ my ($param,$err,$data) = @_;
+
+ my $hash = $param->{hash};
+ #my $name = $hash->{NAME};
+ my $dhash = $modules{AMADDevice}{defptr}{$param->{'amad_id'}};
+ my $dname = $dhash->{NAME};
+
+
+
+
+ if( $param->{method} eq 'GET' ) {
+
+ ### Begin Error Handling
+ if( $dhash->{helper}{infoErrorCounter} > 0 ) {
+
+ readingsBeginUpdate( $dhash );
+ readingsBulkUpdateIfChanged( $dhash, "lastStatusRequestState", "statusRequest_error", 1 );
+
+ if( ReadingsVal( $dname, "flow_Informations", "active" ) eq "inactive" && ReadingsVal( $dname, "flow_SetCommands", "active" ) eq "inactive" ) {
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - statusRequestERROR: CHECK THE LAST ERROR READINGS FOR MORE INFO, DEVICE IS SET OFFLINE";
+
+ readingsBulkUpdateIfChanged( $dhash, "deviceState", "offline", 1 );
+ readingsBulkUpdateIfChanged ( $dhash, "state", "AMAD Flows inactive, device set offline",1);
+ }
+
+ elsif( $dhash->{helper}{infoErrorCounter} > 7 && $dhash->{helper}{setCmdErrorCounter} > 4 ) {
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - statusRequestERROR: UNKNOWN ERROR, PLEASE CONTACT THE DEVELOPER, DEVICE DISABLED";
+
+ $attr{$dname}{disable} = 1;
+ readingsBulkUpdateIfChanged ( $dhash, "state", "Unknown Error, device disabled", 1);
+
+ $dhash->{helper}{infoErrorCounter} = 0;
+ $dhash->{helper}{setCmdErrorCounter} = 0;
+
+ return;
+ }
+
+ elsif( ReadingsVal( $dname, "flow_Informations", "active" ) eq "inactive" ) {
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - statusRequestERROR: Informations Flow on your Device is inactive, will try to reactivate";
+ }
+
+ elsif( $dhash->{helper}{infoErrorCounter} > 7 ) {
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - statusRequestERROR: To many Errors please check your Network or Device Configuration, DEVICE IS SET OFFLINE";
+
+ readingsBulkUpdateIfChanged( $dhash, "deviceState", "offline", 1 );
+ readingsBulkUpdateIfChanged ( $dhash, "state", "To many Errors, device set offline", 1);
+ $dhash->{helper}{infoErrorCounter} = 0;
+ }
+
+ elsif($dhash->{helper}{infoErrorCounter} > 2 && ReadingsVal( $dname, "flow_Informations", "active" ) eq "active" ){
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - statusRequestERROR: Please check the AutomagicAPP on your Device";
+ }
+
+ readingsEndUpdate( $dhash, 1 );
+ }
+
+ if( defined( $err ) ) {
+ if( $err ne "" ) {
+
+ readingsBeginUpdate( $dhash );
+ readingsBulkUpdateIfChanged ( $dhash, "state", "$err") if( ReadingsVal( $dname, "state", 1 ) ne "initialized" );
+ $dhash->{helper}{infoErrorCounter} = ( $dhash->{helper}{infoErrorCounter} + 1 );
+
+ readingsBulkUpdateIfChanged( $dhash, "lastStatusRequestState", "statusRequest_error", 1 );
+
+ if( $err =~ /timed out/ ) {
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - statusRequestERROR: connect to your device is timed out. check network";
+ }
+
+ elsif( ( $err =~ /Keine Route zum Zielrechner/ ) && $dhash->{helper}{infoErrorCounter} > 1 ) {
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - statusRequestERROR: no route to target. bad network configuration or network is down";
+
+ } else {
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - statusRequestERROR: $err";
+ }
+
+ readingsEndUpdate( $dhash, 1 );
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - statusRequestERROR: AMADCommBridge_statusRequestErrorHandling: error while requesting AutomagicInfo: $err";
+
+ return;
+ }
+ }
+
+ if( $data eq "" and exists( $param->{code} ) && $param->{code} ne 200 ) {
+
+ readingsBeginUpdate( $dhash );
+ readingsBulkUpdateIfChanged ( $dhash, "state", $param->{code}, 1 ) if( ReadingsVal( $dname, "state", 1 ) ne "initialized" );
+ $dhash->{helper}{infoErrorCounter} = ( $dhash->{helper}{infoErrorCounter} + 1 );
+
+ readingsBulkUpdateIfChanged( $dhash, "lastStatusRequestState", "statusRequest_error", 1 );
+
+ if( $param->{code} ne 200 ) {
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - statusRequestERROR: ".$param->{code};
+ }
+
+ readingsEndUpdate( $dhash, 1 );
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - statusRequestERROR: received http code ".$param->{code}." without any data after requesting AMAD AutomagicInfo";
+
+ return;
+ }
+
+ if( ( $data =~ /Error/i ) and exists( $param->{code} ) ) {
+ readingsBeginUpdate( $dhash );
+ readingsBulkUpdateIfChanged( $dhash, "state", $param->{code}, 1 ) if( ReadingsVal( $dname, "state" ,0) ne "initialized" );
+ $dhash->{helper}{infoErrorCounter} = ( $dhash->{helper}{infoErrorCounter} + 1 );
+
+ readingsBulkUpdateIfChanged( $dhash, "lastStatusRequestState", "statusRequest_error", 1 );
+
+ if( $param->{code} eq 404 && ReadingsVal( $dname, "flow_Informations", "inactive" ) eq "inactive" ) {
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - statusRequestERROR: check the informations flow on your device";
+ }
+
+ elsif( $param->{code} eq 404 && ReadingsVal( $dname, "flow_Informations", "active" ) eq "active" ) {
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - statusRequestERROR: check the automagicApp on your device";
+
+ } else {
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - statusRequestERROR: http error ".$param->{code};
+ }
+
+ readingsEndUpdate( $dhash, 1 );
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - statusRequestERROR: received http code ".$param->{code}." receive Error after requesting AMAD AutomagicInfo";
+
+ return;
+ }
+
+ ### End Error Handling
+
+ $dhash->{helper}{infoErrorCounter} = 0;
+ }
+
+ elsif( $param->{method} eq 'POST' ) {
+
+ ### Begin Error Handling
+ if( $dhash->{helper}{setCmdErrorCounter} > 2 ) {
+
+ readingsBeginUpdate( $dhash );
+ readingsBulkUpdateIfChanged( $dhash, "lastSetCommandState", "statusRequest_error", 1 );
+
+ if( ReadingsVal( $dname, "flow_Informations", "active" ) eq "inactive" && ReadingsVal( $dname, "flow_SetCommands", "active" ) eq "inactive" ) {
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - setCommandERROR: CHECK THE LAST ERROR READINGS FOR MORE INFO, DEVICE IS SET OFFLINE";
+
+ readingsBulkUpdateIfChanged( $dhash, "deviceState", "offline", 1 );
+ readingsBulkUpdateIfChanged( $dhash, "state", "AMAD Flows inactive, device set offline", 1 );
+ }
+
+ elsif( $dhash->{helper}{infoErrorCounter} > 7 && $dhash->{helper}{setCmdErrorCounter} > 4 ) {
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - setCommandERROR: UNKNOWN ERROR, PLEASE CONTACT THE DEVELOPER, DEVICE DISABLED";
+
+ $attr{$dname}{disable} = 1;
+ readingsBulkUpdateIfChanged( $dhash, "state", "Unknown Error, device disabled", 1 );
+ $dhash->{helper}{infoErrorCounter} = 0;
+ $dhash->{helper}{setCmdErrorCounter} = 0;
+
+ return;
+ }
+
+ elsif( ReadingsVal( $dname, "flow_SetCommands", "active" ) eq "inactive" ) {
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - setCommandERROR: Flow SetCommands on your Device is inactive, will try to reactivate";
+ }
+
+ elsif( $dhash->{helper}{setCmdErrorCounter} > 9 ) {
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - setCommandERROR: To many Errors please check your Network or Device Configuration, DEVICE IS SET OFFLINE";
+
+ readingsBulkUpdateIfChanged( $dhash, "deviceState", "offline", 1 );
+ readingsBulkUpdateIfChanged( $dhash, "state", "To many Errors, device set offline", 1 );
+ $dhash->{helper}{setCmdErrorCounter} = 0;
+ }
+
+ elsif( $dhash->{helper}{setCmdErrorCounter} > 4 && ReadingsVal( $dname, "flow_SetCommands", "active" ) eq "active" ){
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - setCommandERROR: Please check the AutomagicAPP on your Device";
+ }
+
+ readingsEndUpdate( $dhash, 1 );
+ }
+
+ if( defined( $err ) ) {
+ if( $err ne "" ) {
+ readingsBeginUpdate( $dhash );
+ readingsBulkUpdateIfChanged( $dhash, "state", $err, 1 ) if( ReadingsVal( $dname, "state", 0 ) ne "initialized" );
+ $dhash->{helper}{setCmdErrorCounter} = ($dhash->{helper}{setCmdErrorCounter} + 1);
+
+ readingsBulkUpdateIfChanged( $dhash, "lastSetCommandState", "setCmd_error", 1 );
+
+ if( $err =~ /timed out/ ) {
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - setCommandERROR: connect to your device is timed out. check network";
+ }
+
+ elsif( $err =~ /Keine Route zum Zielrechner/ ) {
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - setCommandERROR: no route to target. bad network configuration or network is down";
+
+ } else {
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - setCommandERROR: $err";
+ }
+
+ readingsEndUpdate( $dhash, 1 );
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - setCommandERROR: error while POST Command: $err";
+
+ return;
+ }
+ }
+
+ if( $data eq "" and exists( $param->{code} ) && $param->{code} ne 200 ) {
+
+ readingsBeginUpdate( $dhash );
+ readingsBulkUpdateIfChanged( $dhash, "state", $param->{code}, 1 ) if( ReadingsVal( $dhash, "state", 0 ) ne "initialized" );
+
+ $dhash->{helper}{setCmdErrorCounter} = ( $dhash->{helper}{setCmdErrorCounter} + 1 );
+
+ readingsBulkUpdateIfChanged($dhash, "lastSetCommandState", "setCmd_error", 1 );
+
+ readingsEndUpdate( $dhash, 1 );
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - setCommandERROR: received http code ".$param->{code};
+
+ return;
+ }
+
+ if( ( $data =~ /Error/i ) and exists( $param->{code} ) ) {
+
+ readingsBeginUpdate( $dhash );
+ readingsBulkUpdateIfChanged( $dhash, "state", $param->{code}, 1 ) if( ReadingsVal( $dname, "state", 0 ) ne "initialized" );
+
+ $dhash->{helper}{setCmdErrorCounter} = ( $dhash->{helper}{setCmdErrorCounter} + 1 );
+
+ readingsBulkUpdateIfChanged( $dhash, "lastSetCommandState", "setCmd_error", 1 );
+
+ if( $param->{code} eq 404 ) {
+
+ readingsBulkUpdateIfChanged( $dhash, "lastSetCommandError", "", 1 );
+ Log3 $dname, 5, "AMADCommBridge ($dname) - setCommandERROR: setCommands flow is inactive on your device!";
+
+ } else {
+
+ Log3 $dname, 5, "AMADCommBridge ($dname) - setCommandERROR: http error ".$param->{code};
+ }
+
+ return;
+ }
+
+ ### End Error Handling
+
+ readingsSingleUpdate( $dhash, "lastSetCommandState", "setCmd_done", 1 );
+ $dhash->{helper}{setCmdErrorCounter} = 0;
+
+ return undef;
+ }
+
+
+}
+
+sub AMADCommBridge_Open($) {
+
+ my $hash = shift;
+ my $name = $hash->{NAME};
+ my $port = $hash->{PORT};
+
+
+ if( not defined($hash->{FD}) and (! $hash->{FD}) ) {
+ # Oeffnen des TCP Sockets
+ my $ret = TcpServer_Open( $hash, $port, "global" );
+
+ if( $ret && !$init_done ) {
+
+ Log3 $name, 3, "AMADCommBridge ($name) - $ret. Exiting.";
+ exit(1);
+ }
+
+ readingsSingleUpdate ( $hash, "state", "opened", 1 ) if( defined($hash->{FD}) );
+ Log3 $name, 3, "AMADCommBridge ($name) - Socket opened.";
+
+ return $ret;
+
+ } else {
+
+ Log3 $name, 3, "AMADCommBridge ($name) - Socket already opened";
+ }
+
+ return;
+}
+
+sub AMADCommBridge_Close($) {
+
+ my $hash = shift;
+
+ my $name = $hash->{NAME};
+
+ delete $modules{AMADCommBridge}{defptr}{BRIDGE};
+ TcpServer_Close( $hash );
+
+ if( not defined($hash->{FD}) ) {
+ readingsSingleUpdate ( $hash, "state", "closed", 1 );
+ Log3 $name, 3, "AMADCommBridge ($name) - Socket closed.";
+
+ } else {
+ Log3 $name, 3, "AMADCommBridge ($name) - can't close Socket.";
+ }
+
+ return;
+}
+
+sub AMADCommBridge_Read($) {
+
+ my $hash = shift;
+ my $name = $hash->{NAME};
+
+
+ if( $hash->{SERVERSOCKET} ) { # Accept and create a child
+ TcpServer_Accept( $hash, "AMADCommBridge" );
+ return;
+ }
+
+ # Read 1024 byte of data
+ my $buf;
+ my $ret = sysread($hash->{CD}, $buf, 2048);
+
+
+ # When there is an error in connection return
+ if( !defined($ret ) or $ret <= 0 ) {
+ CommandDelete( undef, $name );
+ Log3 $name, 5, "AMADCommBridge ($name) - Connection closed for $name";
+ return;
+ }
+
+ AMADCommBridge_ProcessRead($hash,$buf);
+}
+
+sub AMADCommBridge_ProcessRead($$) {
+
+ my ($hash, $buf) = @_;
+ my $name = $hash->{NAME};
+
+ my @data = split( '\R\R', $buf );
+ my $data = $data[0];
+ my $json = $data[1];
+ my $buffer = '';
+
+
+
+
+ Log3 $name, 4, "AMADCommBridge ($name) - process read";
+
+
+ my $response;
+ my $c;
+
+ if ( $data =~ /currentFlowsetUpdate.xml/ ) {
+
+ my $fhempath = $attr{global}{modpath};
+ $response = qx(cat $fhempath/FHEM/lib/74_AMADautomagicFlowset_$flowsetversion.xml);
+ $c = $hash->{CD};
+ print $c "HTTP/1.1 200 OK\r\n",
+ "Content-Type: text/plain\r\n",
+ "Connection: close\r\n",
+ "Content-Length: ".length($response)."\r\n\r\n",
+ $response;
+
+ return;
+ }
+
+ elsif ( $data =~ /installFlow_([^.]*.xml)/ ) {
+
+ if( defined($1) ){
+ $response = qx(cat /tmp/$1);
+ $c = $hash->{CD};
+ print $c "HTTP/1.1 200 OK\r\n",
+ "Content-Type: text/plain\r\n",
+ "Connection: close\r\n",
+ "Content-Length: ".length($response)."\r\n\r\n",
+ $response;
+
+ return;
+ }
+ }
+
+
+ if(defined($hash->{PARTIAL}) and $hash->{PARTIAL}) {
+
+ Log3 $name, 5, "AMADCommBridge ($name) - PARTIAL: " . $hash->{PARTIAL};
+ $buffer = $hash->{PARTIAL};
+
+ } else {
+
+ Log3 $name, 4, "AMADCommBridge ($name) - No PARTIAL buffer";
+ }
+
+ Log3 $name, 5, "AMADCommBridge ($name) - Incoming data: " . $json;
+
+ $buffer = $buffer . $json;
+ Log3 $name, 4, "AMADCommBridge ($name) - Current processing buffer (PARTIAL + incoming data): " . $buffer;
+
+ my ($correct_json,$tail) = AMADCommBridge_ParseMsg($hash, $buffer);
+
+
+ while($correct_json) {
+
+ $hash->{LAST_RECV} = time();
+
+ Log3 $name, 5, "AMADCommBridge ($name) - Decoding JSON message. Length: " . length($correct_json) . " Content: " . $correct_json;
+ Log3 $name, 5, "AMADCommBridge ($name) - Vor Sub: Laenge JSON: " . length($correct_json) . " Content: " . $correct_json . " Tail: " . $tail;
+
+ AMADCommBridge_ResponseProcessing($hash,$correct_json)
+ unless(not defined($tail) and not ($tail));
+
+ ($correct_json,$tail) = AMADCommBridge_ParseMsg($hash, $tail);
+
+ Log3 $name, 5, "AMADCommBridge ($name) - Nach Sub: Laenge JSON: " . length($correct_json) . " Content: " . $correct_json . " Tail: " . $tail;
+ }
+
+
+ $hash->{PARTIAL} = $tail;
+ Log3 $name, 4, "AMADCommBridge ($name) - PARTIAL lenght: " . length($tail);
+
+
+ Log3 $name, 5, "AMADCommBridge ($name) - Tail: " . $tail;
+ Log3 $name, 5, "AMADCommBridge ($name) - PARTIAL: " . $hash->{PARTIAL};
+
+}
+
+sub AMADCommBridge_ResponseProcessing($$) {
+
+ my ($hash,$json) = @_;
+
+ my $name = $hash->{NAME};
+ my $bhash = $modules{AMADCommBridge}{defptr}{BRIDGE};
+ my $bname = $bhash->{NAME};
+
+
+
+
+ #### Verarbeitung der Daten welche über die AMADCommBridge kommen ####
+
+ Log3 $bname, 4, "AMADCommBridge ($name) - Receive RAW Message in Debugging Mode: $json";
+
+
+ my $response;
+ my $c;
+
+
+ my $decode_json = eval{decode_json($json)};
+ if($@){
+ Log3 $bname, 4, "AMADCommBridge ($name) - JSON error while request: $@";
+
+ 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",
+ "Content-Type: text/plain\r\n",
+ "Connection: close\r\n",
+ "Content-Length: ".length($response)."\r\n\r\n",
+ $response;
+ return;
+ }
+
+ my $amad_id = $decode_json->{amad}{amad_id};
+ my $fhemcmd = $decode_json->{amad}{fhemcmd};
+ my $fhemDevice;
+
+ if( defined($decode_json->{firstrun}) and ($decode_json->{firstrun}) ) {
+
+ $fhemDevice = $decode_json->{firstrun}{fhemdevice} if( defined($decode_json->{firstrun}{fhemdevice}) );
+
+ } else {
+
+ $fhemDevice = $modules{AMADDevice}{defptr}{$amad_id}->{NAME};
+ }
+
+
+
+
+ if( !defined($amad_id) ) {
+ readingsSingleUpdate( $bhash, "transmitterERROR", $hash->{NAME}." has no device name sends", 1 ) if( AttrVal( $bname, "expertMode", 0 ) eq "1" );
+ Log3 $bname, 4, "AMADCommBridge ($name) - ERROR - no device name given. please check your global variable in automagic";
+
+ $response = "header lines: \r\n AMADCommBridge receive no device name. please check your global variable in automagic\r\n FHEM to do nothing\r\n";
+ $c = $hash->{CD};
+ print $c "HTTP/1.1 200 OK\r\n",
+ "Content-Type: text/plain\r\n",
+ "Connection: close\r\n",
+ "Content-Length: ".length($response)."\r\n\r\n",
+ $response;
+
+ return;
+ }
+
+
+ if( defined($fhemcmd) and ($fhemcmd) ) {
+ if ( $fhemcmd eq 'setreading' ) {
+ return Log3 $bname, 3, "AMADCommBridge ($name) - AMADCommBridge: processing receive no reading values from Device: $fhemDevice"
+ unless( (defined($decode_json->{payload}) and ($decode_json->{payload})) or (defined($decode_json->{firstrun}) and ($decode_json->{firstrun})) );
+
+ Log3 $bname, 4, "AMADCommBridge ($bname) - AMADCommBridge: processing receive reading values - Device: $fhemDevice Data: $decode_json->{payload}" unless( defined($decode_json->{payload}) and ($decode_json->{payload}) );
+
+ Dispatch($bhash,$json,undef);
+ Log3 $bname, 4, "AMADCommBridge ($bname) - call Dispatcher";
+ readingsSingleUpdate($bhash,'fhemServerIP',$decode_json->{firstrun}{'fhemserverip'},1) if( defined($decode_json->{firstrun}{'fhemserverip'}));
+
+ $response = "header lines: \r\n AMADCommBridge receive Data complete\r\n FHEM was processes\r\n";
+ $c = $hash->{CD};
+ print $c "HTTP/1.1 200 OK\r\n",
+ "Content-Type: text/plain\r\n",
+ "Connection: close\r\n",
+ "Content-Length: ".length($response)."\r\n\r\n",
+ $response;
+
+ return;
+ }
+
+ elsif ( $fhemcmd eq 'set' ) {
+ my $fhemCmd = $decode_json->{payload}{setcmd};
+
+ 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";
+ $c = $hash->{CD};
+ print $c "HTTP/1.1 200 OK\r\n",
+ "Content-Type: text/plain\r\n",
+ "Connection: close\r\n",
+ "Content-Length: ".length($response)."\r\n\r\n",
+ $response;
+
+ return;
+ }
+
+ elsif ( $fhemcmd eq 'voiceinputvalue' ) {
+ my $fhemCmd = lc(encode_utf8($decode_json->{payload}{voiceinputdata}));
+
+ readingsBeginUpdate( $bhash);
+ 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";
+
+ $response = "header lines: \r\n AMADCommBridge receive Data complete\r\n FHEM was processes\r\n";
+ $c = $hash->{CD};
+ print $c "HTTP/1.1 200 OK\r\n",
+ "Content-Type: text/plain\r\n",
+ "Connection: close\r\n",
+ "Content-Length: ".length($response)."\r\n\r\n",
+ $response;
+
+ return;
+ }
+
+ elsif ( $fhemcmd eq 'readingsval' ) {
+ my $fhemCmd = $decode_json->{payload}{readingsvalcmd};
+ my @datavalue = split( ' ', $fhemCmd );
+
+ $response = ReadingsVal( $datavalue[0], $datavalue[1], $datavalue[2] );
+ $c = $hash->{CD};
+ print $c "HTTP/1.1 200 OK\r\n",
+ "Content-Type: text/plain\r\n",
+ "Connection: close\r\n",
+ "Content-Length: ".length($response)."\r\n\r\n",
+ $response;
+
+ return;
+ }
+
+
+# elsif ( $fhemcmd =~ /fhemfunc\b/ ) {
+# my $fhemCmd = $data[1];
+#
+# Log3 $bname, 4, "AMADCommBridge ($name) - AMADCommBridge_CommBridge: receive fhem-function command";
+#
+# if( $fhemCmd =~ /^{.*}$/ ) {
+#
+# $response = $fhemCmd if( ReadingsVal( $name, "expertMode", 0 ) eq "1" );
+#
+# } else {
+#
+# $response = "header lines: \r\n AMADCommBridge receive no typical FHEM function\r\n FHEM to do nothing\r\n";
+# }
+#
+# $c = $hash->{CD};
+# print $c "HTTP/1.1 200 OK\r\n",
+# "Content-Type: text/plain\r\n",
+# "Connection: close\r\n",
+# "Content-Length: ".length($response)."\r\n\r\n",
+# $response;
+#
+# return;
+# }
+
+ }
+
+
+ $response = "header lines: \r\n AMADCommBridge receive incomplete or corrupt Data\r\n FHEM to do nothing\r\n";
+ $c = $hash->{CD};
+ print $c "HTTP/1.1 200 OK\r\n",
+ "Content-Type: text/plain\r\n",
+ "Connection: close\r\n",
+ "Content-Length: ".length($response)."\r\n\r\n",
+ $response;
+}
+
+
+##################
+### my little helper
+##################
+
+sub AMADCommBridge_ParseMsg($$) {
+
+ my ($hash, $buffer) = @_;
+
+ my $name = $hash->{NAME};
+ my $open = 0;
+ my $close = 0;
+ my $msg = '';
+ my $tail = '';
+
+
+ if($buffer) {
+ foreach my $c (split //, $buffer) {
+ if($open == $close && $open > 0) {
+ $tail .= $c;
+ Log3 $name, 5, "AMADCommBridge ($name) - $open == $close && $open > 0";
+
+ } elsif(($open == $close) && ($c ne '{')) {
+
+ Log3 $name, 5, "AMADCommBridge ($name) - Garbage character before message: " . $c;
+
+ } else {
+
+ if($c eq '{') {
+
+ $open++;
+
+ } elsif($c eq '}') {
+
+ $close++;
+ }
+
+ $msg .= $c;
+ }
+ }
+
+ if($open != $close) {
+
+ $tail = $msg;
+ $msg = '';
+ }
+ }
+
+ Log3 $name, 5, "AMADCommBridge ($name) - return msg: $msg and tail: $tail";
+ return ($msg,$tail);
+}
+
+##### bleibt zu Anschauungszwecken erhalten
+#sub AMADCommBridge_Header2Hash($) {
+#
+# my $string = shift;
+# my %hash = ();
+#
+# foreach my $line (split("\r\n", $string)) {
+# my ($key,$value) = split( ": ", $line );
+# next if( !$value );
+#
+# $value =~ s/^ //;
+# $hash{$key} = $value;
+# }
+#
+# return \%hash;
+#}
+
+
+
+
+
+
+
+
+
+1;
+
+=pod
+
+=item device
+=item summary Integrates Android devices into FHEM and displays several settings.
+=item summary_DE Integriert Android-Geräte in FHEM und zeigt verschiedene Einstellungen an.
+
+=begin html
+
+
+AMADCommBridge
+
+ AMAD - Automagic Android Device
+ AMADCommBridge - Communication bridge for all AMAD devices
+
+ This module is the central point for the successful integration of Android devices in FHEM. It also provides a link level between AMAD supported devices and FHEM. All communication between AMAD Android and FHEM runs through this interface.
+ Therefore, the initial setup of an AMAD device is also performed exactly via this module instance.
+
+ In order to successfully establish an Android device in FHEM, an AMADCommBridge device must be created in the first step.
+
+
+ Define
+
+ define <name> AMADCommBridge
+
+ Example:
+
+ define AMADBridge AMADCommBridge
+
+
+ This statement creates a new AMADCommBridge device named AMADBridge.
+
+ In the following, only the Flowset has to be installed on the Android device and the Flow 'First Run Assistant' run. (Simply press the Homebutton)
+ The wizard then guides you through the setup of your AMAD device and ensures that at the end of the installation process the Android device is created as an AMAD device in FHEM.
+
+
+
+ Readings
+
+ - JSON_ERROR - JSON Error message reported by Perl
+ - JSON_ERROR_STRING - The string that caused the JSON error message
+ - fhemServerIP - The IP address of the FHEM server, is set by the module based on the JSON string from the installation wizard. Can also be set by user using set command
+ - receiveFhemCommand - is set the fhemControlMode attribute to trigger, the reading is set as soon as an FHEM command is sent. A notification can then be triggered.
+ If set instead of trigger setControl as value for fhemControlMode, the reading is not executed but the set command executed immediately.
+ - receiveVoiceCommand - The speech control is activated by AMAD (set DEVICE activateVoiceInput), the last recognized voice command is written into this reading.
+ - receiveVoiceDevice - Name of the device from where the last recognized voice command was sent
+ - state - state of the Bridge, open, closed
+
+
+
+ Attributes
+
+ - allowFrom - Regexp the allowed IP addresses or hostnames. If this attribute is set, only connections from these addresses are accepted.
+ Attention: If allowfrom is not set, and no kind allowed instance is defined, and the remote has a non-local address, then the connection is rejected. The following addresses are considered local:
+ IPV4: 127/8, 10/8, 192.168/16, 172.16/10, 169.254/16
+ IPV6: ::1, fe80/10
+ - debugJSON - If set to 1, JSON error messages are written in readings. See JSON_ERROR * under Readings
+ - fhemControlMode - Controls the permissible type of control of FHEM devices. You can control the bridge in two ways FHEM devices. Either by direct FHEM command from a flow, or as a voice command by means of voice control (set DEVICE activateVoiceInput)
+
- trigger - If the value trigger is set, all FHEM set commands sent to the bridge are written to the reading receiveFhemCommand and can be executed using notify. Voice control is possible; readings receiveVoice * are set. On the Android device several voice commands can be linked by means of "and". Example: turn on the light scene in the evening and turn on the TV
+ - setControl - All set commands sent via the flow are automatically executed. The triggering of a reading is not necessary. The control by means of language behaves like the value trigger
+ - thirdPartControl - Behaves as triggered, but in the case of voice control, a series of voice commands by means of "and" is not possible. Used for voice control via modules of other module authors ((z.B. 39_TEERKO.pm)
+
+
+
+ If you have problems with the wizard, an Android device can also be applied manually, you will find in the Commandref to the AMADDevice module.
+
+
+=end html
+=begin html_DE
+
+
+AMADCommBridge
+
+ AMAD - Automagic Android Device
+ AMADCommBridge - Kommunikationsbrücke für alle AMAD Geräte
+
+ Dieses Modul ist das Ausgangsmodul zur erfolgreichen Integration von Androidgeräten in FHEM. Es stellt ferner eine Verbindungsebene zwischen AMAD unterstützten Geräten und FHEM zur Verfügung. Alle Kommunikation zwischen AMAD Android und FHEM läuft über diese Schnittstelle.
+ Daher erfolgt die Ersteinrichtung eines AMAD Devices auch genau über diese Modulinstanz.
+
+ Damit erfolgreich ein Androidgerät in FHEM eingerichtet werden kann, muss im ersten Schritt ein AMADCommBridge Device angelegt werden.
+
+
+ Define
+
+ define <name> AMADCommBridge
+
+ Beispiel:
+
+ define AMADBridge AMADCommBridge
+
+
+ Diese Anweisung erstellt ein neues AMADCommBridge Device Namens AMADBridge.
+
+ Im folgenden muß lediglich das Flowset auf dem Android Gerät installiert werden und der Flow 'First Run Assistent' ausgeführt werden. (einfach den Homebutton drücken)
+ Der Assistent geleitet Dich dann durch die Einrichtung Deines AMAD Gerätes und sorgt dafür das am Ende des Installationsprozess das Androidgerät als AMAD Device in FHEM angelegt wird.
+
+
+
+ Readings
+
+ - JSON_ERROR - JSON Fehlermeldung welche von Perl gemeldet wird
+ - JSON_ERROR_STRING - der String welcher die JSON Fehlermeldung verursacht hat
+ - fhemServerIP - die Ip-Adresse des FHEM Servers, wird vom Modul auf Basis des JSON Strings vom Installationsassistenten gesetzt. Kann aber auch mittels set Befehles vom User gesetzt werden
+ - receiveFhemCommand - ist das Attribut fhemControlMode auf trigger gestellt, wird das Reading gesetzt sobald ein FHEM Befehl übersendet wird. Hierauf kann dann ein Notify triggern.
+ Wird anstelle von trigger setControl als Wert für fhemControlMode eingestellt, wird das Reading nicht gestzt sondern der set Befehl sofort ausgeführt.
+ - receiveVoiceCommand - wird die Sprachsteuerung von AMAD aktiviert (set DEVICE activateVoiceInput) so wird der letzte erkannten Sprachbefehle in dieses Reading geschrieben.
+ - receiveVoiceDevice - Name des Devices von wo aus der letzte erkannte Sprachbefehl gesendet wurde
+ - state - Status der Bridge, open, closed
+
+
+
+ Attribute
+
+ - allowFrom - Regexp der erlaubten IP-Adressen oder Hostnamen. Wenn dieses Attribut gesetzt wurde, werden ausschließlich Verbindungen von diesen Adressen akzeptiert.
+ Achtung: falls allowfrom nicht gesetzt ist, und keine gütige allowed Instanz definiert ist, und die Gegenstelle eine nicht lokale Adresse hat, dann wird die Verbindung abgewiesen. Folgende Adressen werden als local betrachtet:
+ IPV4: 127/8, 10/8, 192.168/16, 172.16/10, 169.254/16
+ IPV6: ::1, fe80/10
+ - debugJSON - wenn auf 1 gesetzt, werden JSON Fehlermeldungen in Readings geschrieben. Siehe hierzu JSON_ERROR* unter Readings
+ - fhemControlMode - steuert die zulässige Art der Kontrolle von FHEM Devices. Du kannst über die Bridge auf 2 Arten FHEM Devices steuern. Entweder per direktem FHEM Befehl aus einem Flow heraus, oder als Sprachbefehl mittels Sprachsteuerung (set DEVICE activateVoiceInput)
+
- trigger - ist der Wert trigger gesetzt, werden alle an die Bridge gesendeten FHEM set Befehle in das Reading receiveFhemCommand geschrieben und können so mittels notify ausgeführt werden. Sprachsteuerung ist möglich, es werden Readings receiveVoice* gesetzt. Auf dem Androidgerät können bei Sprachsteuerung mehrere Sprachbefehle mittels "und" verknüpft/aneinander gereiht werden. Bsp: schalte die Lichtszene Abends an und schalte den Fernsehr an
+ - setControl - alle set Befehle welche mittels eines Flows über die Bridge gesendet werden, werden automatisch ausgeführt. Das triggern eines Readings ist nicht nötig. Die Steuerung mittels Sprache verhält sich wie beim Wert trigger
+ - thirdPartControl - verhält sich wie trigger, bei der Sprachsteuerung ist jedoch ein anreihen von Sprachbefehlen mittels "und" nicht möglich. Dient der Sprachsteuerung über Module anderer Modulautoren ((z.B. 39_TEERKO.pm)
+
+
+
+ Wie man bei Problemen mit dem Assistenten ein Androidgerät auch von Hand anlegen kann, erfährst Du in der Commandref zum AMADDevice Modul.
+
+
+=end html_DE
+=cut
diff --git a/74_AMAD.pm b/74_AMAD.pm
deleted file mode 100644
index 4e1b38f..0000000
--- a/74_AMAD.pm
+++ /dev/null
@@ -1,1865 +0,0 @@
-###############################################################################
-#
-# Developed with Kate
-#
-# (c) 2015-2017 Copyright: Marko Oldenburg (leongaultier at gmail dot com)
-# All rights reserved
-#
-# This script is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# any later version.
-#
-# The GNU General Public License can be found at
-# http://www.gnu.org/copyleft/gpl.html.
-# A copy is found in the textfile GPL.txt and important notices to the license
-# from the author is found in LICENSE.txt distributed with these scripts.
-#
-# This script is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-#
-# $Id$
-#
-###############################################################################
-##
-##
-## Das JSON Modul immer in einem eval aufrufen
-# $data = eval{decode_json($data)};
-#
-# if($@){
-# Log3($SELF, 2, "$TYPE ($SELF) - error while request: $@");
-#
-# readingsSingleUpdate($hash, "state", "error", 1);
-#
-# return;
-# }
-##
-##
-
-
-
-package main;
-
-use strict;
-use warnings;
-use Time::HiRes qw(gettimeofday);
-
-use HttpUtils;
-use TcpServerUtils;
-use Encode qw(encode);
-
-
-my $modulversion = "2.6.13";
-my $flowsetversion = "2.6.12";
-
-
-
-
-# Declare functions
-sub AMAD_Attr(@);
-sub AMAD_checkDeviceState($);
-sub AMAD_CommBridge_Open($);
-sub AMAD_CommBridge_Read($);
-sub AMAD_decrypt($);
-sub AMAD_Define($$);
-sub AMAD_encrypt($);
-sub AMAD_GetUpdate($);
-sub AMAD_Header2Hash($);
-sub AMAD_HTTP_POST($$);
-sub AMAD_HTTP_POSTerrorHandling($$$);
-sub AMAD_Initialize($);
-sub AMAD_ResponseProcessing($$);
-sub AMAD_SelectSetCmd($$@);
-sub AMAD_Set($$@);
-sub AMAD_statusRequest($);
-sub AMAD_statusRequestErrorHandling($$$);
-sub AMAD_Undef($$);
-
-
-
-
-sub AMAD_Initialize($) {
-
- my ($hash) = @_;
-
- $hash->{SetFn} = "AMAD_Set";
- $hash->{DefFn} = "AMAD_Define";
- $hash->{UndefFn} = "AMAD_Undef";
- $hash->{AttrFn} = "AMAD_Attr";
- $hash->{ReadFn} = "AMAD_CommBridge_Read";
-
- $hash->{AttrList} = "setOpenApp ".
- "checkActiveTask ".
- "setFullscreen:0,1 ".
- "setScreenOrientation:0,1 ".
- "setScreenBrightness:noArg ".
- "setBluetoothDevice ".
- "setScreenlockPIN ".
- "setScreenOnForTimer ".
- "setOpenUrlBrowser ".
- "setNotifySndFilePath ".
- "setTtsMsgSpeed ".
- "setUserFlowState ".
- "setTtsMsgLang:de,en ".
- "setAPSSID ".
- "root:0,1 ".
- "port ".
- "disable:1 ".
- $readingFnAttributes;
-
- foreach my $d(sort keys %{$modules{AMAD}{defptr}}) {
-
- my $hash = $modules{AMAD}{defptr}{$d};
- $hash->{VERSIONMODUL} = $modulversion;
- $hash->{VERSIONFLOWSET} = $flowsetversion;
- }
-}
-
-sub AMAD_Define($$) {
-
- my ( $hash, $def ) = @_;
-
- my @a = split( "[ \t][ \t]*", $def );
-
-
- return "too few parameters: define AMAD " if( $a[0] ne "AMADCommBridge" and @a < 2 and @a > 4 );
-
- my $name = $a[0];
- my $host = $a[2] if( $a[2] );
- $a[3] =~ s/@@/ /g if( $a[3] );
- my $apssid = $a[3] if( $a[3] );
- my $port = 8090;
-
- $hash->{HOST} = $host if( $host );
- $hash->{PORT} = $port;
- $hash->{APSSID} = $apssid if( $hash->{HOST} );
- $hash->{VERSIONMODUL} = $modulversion;
- $hash->{VERSIONFLOWSET} = $flowsetversion;
- $hash->{helper}{infoErrorCounter} = 0 if( $hash->{HOST} );
- $hash->{helper}{setCmdErrorCounter} = 0 if( $hash->{HOST} );
- $hash->{helper}{deviceStateErrorCounter} = 0 if( $hash->{HOST} );
-
-
-
-
- if( ! $hash->{HOST} ) {
- return "there is already a AMAD Bridge, did you want to define a AMAD host use: define AMAD " if( $modules{AMAD}{defptr}{BRIDGE} );
-
- $hash->{BRIDGE} = 1;
- $modules{AMAD}{defptr}{BRIDGE} = $hash;
- $attr{$name}{room} = "AMAD" if( !defined( $attr{$name}{room} ) );
-
- Log3 $name, 3, "AMAD ($name) - defined Bridge with Socketport $hash->{PORT}";
- Log3 $name, 3, "AMAD ($name) - Attention!!! By the first run, dont forget to \"set $name fhemServerIP \"";
-
- AMAD_CommBridge_Open( $hash );
-
- } else {
- if( ! $modules{AMAD}{defptr}{BRIDGE} && $init_done ) {
- CommandDefine( undef, "AMADCommBridge AMAD" );
- }
-
- Log3 $name, 3, "AMAD ($name) - defined with host $hash->{HOST} on port $hash->{PORT} and AccessPoint-SSID $hash->{APSSID}" if( $hash->{APSSID} );
- Log3 $name, 3, "AMAD ($name) - defined with host $hash->{HOST} on port $hash->{PORT} and NONE AccessPoint-SSID" if( ! $hash->{APSSID} );
-
- $attr{$name}{room} = "AMAD" if( !defined( $attr{$name}{room} ) );
-
- readingsSingleUpdate ( $hash, "state", "initialized", 1 ) if( $hash->{HOST} );
- readingsSingleUpdate ( $hash, "deviceState", "unknown", 1 ) if( $hash->{HOST} );
-
- RemoveInternalTimer($hash);
-
-
- if( $init_done ) {
-
- AMAD_GetUpdate($hash);
-
- } else {
-
- InternalTimer( gettimeofday()+30, "AMAD_GetUpdate", $hash, 0 ) if( ($hash->{HOST}) );
- }
-
- $modules{AMAD}{defptr}{$hash->{HOST}} = $hash;
-
- return undef;
- }
-}
-
-sub AMAD_Undef($$) {
-
- my ( $hash, $arg ) = @_;
-
- if( $hash->{BRIDGE} or $hash->{TEMPORARY} == 1 ) {
- delete $modules{AMAD}{defptr}{BRIDGE} if( defined($modules{AMAD}{defptr}{BRIDGE}) and $hash->{BRIDGE} );
- TcpServer_Close( $hash );
- }
-
- elsif( $hash->{HOST} ) {
-
- delete $modules{AMAD}{defptr}{$hash->{HOST}};
- RemoveInternalTimer( $hash );
-
- foreach my $d(sort keys %{$modules{AMAD}{defptr}}) {
- my $hash = $modules{AMAD}{defptr}{$d};
- my $host = $hash->{HOST};
-
- return if( $host );
- my $name = $hash->{NAME};
- CommandDelete( undef, $name );
- }
- }
-
- return undef;
-}
-
-sub AMAD_Attr(@) {
-
- my ( $cmd, $name, $attrName, $attrVal ) = @_;
- my $hash = $defs{$name};
-
- my $orig = $attrVal;
-
- if( $attrName eq "disable" ) {
- if( $cmd eq "set" ) {
- if( $attrVal eq "0" ) {
-
- RemoveInternalTimer( $hash );
- InternalTimer( gettimeofday()+2, "AMAD_GetUpdate", $hash, 0 ) if( ReadingsVal( $hash->{NAME}, "state", 0 ) eq "disabled" );
- readingsSingleUpdate ( $hash, "state", "active", 1 );
- Log3 $name, 3, "AMAD ($name) - enabled";
- } else {
-
- readingsSingleUpdate ( $hash, "state", "disabled", 1 );
- RemoveInternalTimer( $hash );
- Log3 $name, 3, "AMAD ($name) - disabled";
- }
-
- } else {
-
- RemoveInternalTimer( $hash );
- InternalTimer( gettimeofday()+2, "AMAD_GetUpdate", $hash, 0 ) if( ReadingsVal( $hash->{NAME}, "state", 0 ) eq "disabled" );
- readingsSingleUpdate ( $hash, "state", "active", 1 );
- Log3 $name, 3, "AMAD ($name) - enabled";
- }
- }
-
- elsif( $attrName eq "checkActiveTask" ) {
- if( $cmd eq "del" ) {
- CommandDeleteReading( undef, "$name checkActiveTask" );
- }
-
- Log3 $name, 3, "AMAD ($name) - $cmd $attrName $attrVal and run statusRequest";
- RemoveInternalTimer( $hash );
- InternalTimer( gettimeofday(), "AMAD_GetUpdate", $hash, 0 )
- }
-
- elsif( $attrName eq "port" ) {
- if( $cmd eq "set" ) {
-
- $hash->{PORT} = $attrVal;
- Log3 $name, 3, "AMAD ($name) - set port to $attrVal";
-
- if( $hash->{BRIDGE} ) {
- delete $modules{AMAD}{defptr}{BRIDGE};
- TcpServer_Close( $hash );
- Log3 $name, 3, "AMAD ($name) - CommBridge Port changed. CommBridge are closed and new open!";
-
- AMAD_CommBridge_Open( $hash );
- }
- } else {
-
- $hash->{PORT} = 8090;
- Log3 $name, 3, "AMAD ($name) - set port to default";
-
- if( $hash->{BRIDGE} ) {
- delete $modules{AMAD}{defptr}{BRIDGE};
- TcpServer_Close( $hash );
- Log3 $name, 3, "AMAD ($name) - CommBridge Port changed. CommBridge are closed and new open!";
-
- AMAD_CommBridge_Open( $hash );
- }
- }
- }
-
- elsif( $attrName eq "setScreenlockPIN" ) {
- if( $cmd eq "set" && $attrVal ) {
-
- $attrVal = AMAD_encrypt($attrVal);
-
- } else {
-
- CommandDeleteReading( undef, "$name screenLock" );
- }
- }
-
- elsif( $attrName eq "setUserFlowState" ) {
- if( $cmd eq "del" ) {
-
- CommandDeleteReading( undef, "$name userFlowState" );
- }
-
- Log3 $name, 3, "AMAD ($name) - $cmd $attrName $attrVal and run statusRequest";
- RemoveInternalTimer( $hash );
- InternalTimer( gettimeofday(), "AMAD_GetUpdate", $hash, 0 )
- }
-
-
-
- if( $cmd eq "set" ) {
- if( $attrVal && $orig ne $attrVal ) {
-
- $attr{$name}{$attrName} = $attrVal;
- return $attrName ." set to ". $attrVal if( $init_done );
- }
- }
-
- return undef;
-}
-
-sub AMAD_GetUpdate($) {
-
- my ( $hash ) = @_;
- my $name = $hash->{NAME};
- my $bhash = $modules{AMAD}{defptr}{BRIDGE};
- my $bname = $bhash->{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" ) {
-
- AMAD_statusRequest( $hash );
- AMAD_checkDeviceState( $hash );
-
- } else {
-
- Log3 $name, 4, "AMAD ($name) - GetUpdate, FHEM or Device not ready yet";
- Log3 $name, 3, "AMAD ($bname) - GetUpdate, Please set $bname fhemServerIP NOW!" if( ReadingsVal( $bname, "fhemServerIP", "none" ) eq "none" );
-
- InternalTimer( gettimeofday()+15, "AMAD_GetUpdate", $hash, 0 );
- }
-}
-
-sub AMAD_statusRequest($) {
-
- my ($hash) = @_;
- my $bhash = $modules{AMAD}{defptr}{BRIDGE};
- my $bname = $bhash->{NAME};
- my $name = $hash->{NAME};
- my $host = $hash->{HOST};
- my $port = $hash->{PORT};
- my $bport = $bhash->{PORT};
- my $fhemip = ReadingsVal( $bname, "fhemServerIP", "none" );
- my $activetask = AttrVal( $name, "checkActiveTask", "none" );
- my $userFlowState = AttrVal( $name, "setUserFlowState", "none" );
- my $apssid = "none";
- $apssid = $hash->{APSSID} if( defined($hash->{APSSID}) );
- $apssid = $attr{$name}{setAPSSID} if( defined($attr{$name}{setAPSSID}) );
-
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/deviceInfo/"; # Pfad muß so im Automagic als http request Trigger drin stehen
-
- HttpUtils_NonblockingGet(
- {
- url => $url,
- timeout => 5,
- hash => $hash,
- method => "GET",
- header => "Connection: close\r\nfhemip: $fhemip\r\nfhemdevice: $name\r\nactivetask: $activetask\r\napssid: $apssid\r\nbport: $bport\r\nuserflowstate: $userFlowState",
- doTrigger => 1,
- callback => \&AMAD_statusRequestErrorHandling,
- }
- );
-
- Log3 $name, 5, "AMAD ($name) - Send statusRequest with URL: \"$url\" and Header: \"fhemIP: $fhemip\r\nfhemDevice: $name\r\nactiveTask: $activetask\r\napSSID: $apssid\"";
-}
-
-sub AMAD_statusRequestErrorHandling($$$) {
-
- my ( $param, $err, $data ) = @_;
- my $hash = $param->{hash};
- my $doTrigger = $param->{doTrigger};
- my $name = $hash->{NAME};
- my $host = $hash->{HOST};
-
-
- ### Begin Error Handling
- if( $hash->{helper}{infoErrorCounter} > 0 ) {
-
- readingsBeginUpdate( $hash );
- readingsBulkUpdate( $hash, "lastStatusRequestState", "statusRequest_error" );
-
- if( ReadingsVal( $name, "flow_Informations", "active" ) eq "inactive" && ReadingsVal( $name, "flow_SetCommands", "active" ) eq "inactive" ) {
-
- Log3 $name, 5, "AMAD ($name) - statusRequestERROR: CHECK THE LAST ERROR READINGS FOR MORE INFO, DEVICE IS SET OFFLINE";
-
- readingsBulkUpdate( $hash, "deviceState", "offline" );
- readingsBulkUpdate ( $hash, "state", "AMAD Flows inactive, device set offline");
- }
-
- elsif( $hash->{helper}{infoErrorCounter} > 7 && $hash->{helper}{setCmdErrorCounter} > 4 ) {
-
- Log3 $name, 5, "AMAD ($name) - statusRequestERROR: UNKNOWN ERROR, PLEASE CONTACT THE DEVELOPER, DEVICE DISABLED";
-
- $attr{$name}{disable} = 1;
- readingsBulkUpdate ( $hash, "state", "Unknown Error, device disabled");
-
- $hash->{helper}{infoErrorCounter} = 0;
- $hash->{helper}{setCmdErrorCounter} = 0;
-
- return;
- }
-
- elsif( ReadingsVal( $name, "flow_Informations", "active" ) eq "inactive" ) {
-
- Log3 $name, 5, "AMAD ($name) - statusRequestERROR: Informations Flow on your Device is inactive, will try to reactivate";
- }
-
- elsif( $hash->{helper}{infoErrorCounter} > 7 ) {
-
- Log3 $name, 5, "AMAD ($name) - statusRequestERROR: To many Errors please check your Network or Device Configuration, DEVICE IS SET OFFLINE";
-
- readingsBulkUpdate( $hash, "deviceState", "offline" );
- readingsBulkUpdate ( $hash, "state", "To many Errors, device set offline");
- $hash->{helper}{infoErrorCounter} = 0;
- }
-
- elsif($hash->{helper}{infoErrorCounter} > 2 && ReadingsVal( $name, "flow_Informations", "active" ) eq "active" ){
-
- Log3 $name, 5, "AMAD ($name) - statusRequestERROR: Please check the AutomagicAPP on your Device";
- }
-
- readingsEndUpdate( $hash, 1 );
- }
-
- if( defined( $err ) ) {
- if( $err ne "" ) {
-
- readingsBeginUpdate( $hash );
- readingsBulkUpdate ( $hash, "state", "$err") if( ReadingsVal( $name, "state", 1 ) ne "initialized" );
- $hash->{helper}{infoErrorCounter} = ( $hash->{helper}{infoErrorCounter} + 1 );
-
- readingsBulkUpdate( $hash, "lastStatusRequestState", "statusRequest_error" );
-
- if( $err =~ /timed out/ ) {
-
- Log3 $name, 5, "AMAD ($name) - statusRequestERROR: connect to your device is timed out. check network";
- }
-
- elsif( ( $err =~ /Keine Route zum Zielrechner/ ) && $hash->{helper}{infoErrorCounter} > 1 ) {
-
- Log3 $name, 5, "AMAD ($name) - statusRequestERROR: no route to target. bad network configuration or network is down";
-
- } else {
-
- Log3 $name, 5, "AMAD ($name) - statusRequestERROR: $err";
- }
-
- readingsEndUpdate( $hash, 1 );
-
- Log3 $name, 5, "AMAD ($name) - statusRequestERROR: AMAD_statusRequestErrorHandling: error while requesting AutomagicInfo: $err";
-
- return;
- }
- }
-
- if( $data eq "" and exists( $param->{code} ) && $param->{code} ne 200 ) {
-
- readingsBeginUpdate( $hash );
- readingsBulkUpdate ( $hash, "state", $param->{code} ) if( ReadingsVal( $name, "state", 1 ) ne "initialized" );
- $hash->{helper}{infoErrorCounter} = ( $hash->{helper}{infoErrorCounter} + 1 );
-
- readingsBulkUpdate( $hash, "lastStatusRequestState", "statusRequest_error" );
-
- if( $param->{code} ne 200 ) {
-
- Log3 $name, 5, "AMAD ($name) - statusRequestERROR: ".$param->{code};
- }
-
- readingsEndUpdate( $hash, 1 );
-
- Log3 $name, 5, "AMAD ($name) - statusRequestERROR: received http code ".$param->{code}." without any data after requesting AMAD AutomagicInfo";
-
- return;
- }
-
- if( ( $data =~ /Error/i ) and exists( $param->{code} ) ) {
- readingsBeginUpdate( $hash );
- readingsBulkUpdate( $hash, "state", $param->{code} ) if( ReadingsVal( $name, "state" ,0) ne "initialized" );
- $hash->{helper}{infoErrorCounter} = ( $hash->{helper}{infoErrorCounter} + 1 );
-
- readingsBulkUpdate( $hash, "lastStatusRequestState", "statusRequest_error" );
-
- if( $param->{code} eq 404 && ReadingsVal( $name, "flow_Informations", "inactive" ) eq "inactive" ) {
-
- Log3 $name, 5, "AMAD ($name) - statusRequestERROR: check the informations flow on your device";
- }
-
- elsif( $param->{code} eq 404 && ReadingsVal( $name, "flow_Informations", "active" ) eq "active" ) {
-
- Log3 $name, 5, "AMAD ($name) - statusRequestERROR: check the automagicApp on your device";
-
- } else {
-
- Log3 $name, 5, "AMAD ($name) - statusRequestERROR: http error ".$param->{code};
- }
-
- readingsEndUpdate( $hash, 1 );
-
- Log3 $name, 5, "AMAD ($name) - statusRequestERROR: received http code ".$param->{code}." receive Error after requesting AMAD AutomagicInfo";
-
- return;
- }
-
- ### End Error Handling
-
- $hash->{helper}{infoErrorCounter} = 0;
-}
-
-sub AMAD_ResponseProcessing($$) {
-
- my ( $hash, $data ) = @_;
-
- my $name = $hash->{NAME};
- my $host = $hash->{HOST};
-
- ### Begin Response Processing
- Log3 $name, 5, "AMAD ($name) - Processing data: $data";
- readingsSingleUpdate( $hash, "state", "active", 1) if( ReadingsVal( $name, "state", 0 ) ne "initialized" or ReadingsVal( $name, "state", 0 ) ne "active" );
-
- my @valuestring = split( '@@@@', $data );
- my %buffer;
-
- foreach( @valuestring ) {
-
- my @values = split( '@@' , $_ );
- $buffer{$values[0]} = $values[1];
- }
-
-
- readingsBeginUpdate( $hash );
-
- my $t;
- my $v;
- while( ( $t, $v ) = each %buffer ) {
- if( defined( $v ) ) {
-
- readingsBulkUpdate( $hash, "deviceState", "offline" ) if( $t eq "airplanemode" && $v eq "on" );
- readingsBulkUpdate( $hash, "deviceState", "online" ) if( $t eq "airplanemode" && $v eq "off" );
- $v =~ s/\bnull\b/off/g if( ($t eq "nextAlarmDay" || $t eq "nextAlarmTime") && $v eq "null" );
-
-
- $v =~ s/\bnull\b//g;
-
- readingsBulkUpdate( $hash, $t, $v );
- }
- }
-
- readingsBulkUpdate( $hash, "lastStatusRequestState", "statusRequest_done" );
-
-
-
- $hash->{helper}{infoErrorCounter} = 0;
- ### End Response Processing
-
- readingsBulkUpdate( $hash, "state", "active" ) if( ReadingsVal( $name, "state", 0 ) eq "initialized" );
- readingsEndUpdate( $hash, 1 );
-
- $hash->{helper}{deviceStateErrorCounter} = 0 if( $hash->{helper}{deviceStateErrorCounter} > 0 and ReadingsVal( $name, "deviceState", "offline") eq "online" );
-
- return undef;
-}
-
-sub AMAD_Set($$@) {
-
- my ( $hash, $name, $cmd, @val ) = @_;
-
- my $bhash = $modules{AMAD}{defptr}{BRIDGE};
- my $bname = $bhash->{NAME};
-
- if( $name ne "$bname" ) {
- my $apps = AttrVal( $name, "setOpenApp", "none" );
- my $btdev = AttrVal( $name, "setBluetoothDevice", "none" );
- my $activetask = AttrVal( $name, "setActiveTask", "none" );
-
- my $list = "";
- $list .= "screenMsg ";
- $list .= "ttsMsg ";
- $list .= "volume:slider,0,1,15 ";
- $list .= "mediaGoogleMusic:play/pause,stop,next,back " if( ReadingsVal( $bname, "fhemServerIP", "none" ) ne "none");
- $list .= "mediaAmazonMusic:play/pause,stop,next,back " if( ReadingsVal( $bname, "fhemServerIP", "none" ) ne "none");
- $list .= "mediaSpotifyMusic:play/pause,stop,next,back " if( ReadingsVal( $bname, "fhemServerIP", "none" ) ne "none");
- $list .= "mediaTuneinRadio:play/pause,stop,next,back " if( ReadingsVal( $bname, "fhemServerIP", "none" ) ne "none");
- $list .= "mediaAldiMusic:play/pause,stop,next,back " if( ReadingsVal( $bname, "fhemServerIP", "none" ) ne "none");
- $list .= "mediaYouTube:play/pause,stop,next,back " if( ReadingsVal( $bname, "fhemServerIP", "none" ) ne "none");
- $list .= "mediaVlcPlayer:play/pause,stop,next,back " if( ReadingsVal( $bname, "fhemServerIP", "none" ) ne "none");
- $list .= "mediaAudible:play/pause,stop,next,back " if( ReadingsVal( $bname, "fhemServerIP", "none" ) ne "none");
- $list .= "screenBrightness:slider,0,1,255 ";
- $list .= "screen:on,off,lock,unlock ";
- $list .= "screenOrientation:auto,landscape,portrait " if( AttrVal( $name, "setScreenOrientation", "0" ) eq "1" );
- $list .= "screenFullscreen:on,off " if( AttrVal( $name, "setFullscreen", "0" ) eq "1" );
- $list .= "openURL ";
- $list .= "openApp:$apps " if( AttrVal( $name, "setOpenApp", "none" ) ne "none" );
- $list .= "nextAlarmTime:time ";
- $list .= "timer:slider,1,1,60 ";
- $list .= "statusRequest:noArg ";
- $list .= "system:reboot,shutdown,airplanemodeON " if( AttrVal( $name, "root", "0" ) eq "1" );
- $list .= "bluetooth:on,off ";
- $list .= "notifySndFile ";
- $list .= "clearNotificationBar:All,Automagic ";
- $list .= "changetoBTDevice:$btdev " if( AttrVal( $name, "setBluetoothDevice", "none" ) ne "none" );
- $list .= "activateVoiceInput:noArg ";
- $list .= "volumeNotification:slider,0,1,7 ";
- $list .= "volumeRingSound:slider,0,1,7 ";
- $list .= "vibrate:noArg ";
- $list .= "sendIntent ";
- $list .= "openCall ";
- $list .= "closeCall:noArg ";
- $list .= "currentFlowsetUpdate:noArg ";
- $list .= "installFlowSource ";
- $list .= "doNotDisturb:never,always,alarmClockOnly,onlyImportant ";
- $list .= "userFlowState ";
- $list .= "sendSMS ";
- $list .= "startDaydream:noArg ";
-
- if( lc $cmd eq 'screenmsg'
- || lc $cmd eq 'ttsmsg'
- || lc $cmd eq 'volume'
- || lc $cmd eq 'mediagooglemusic'
- || lc $cmd eq 'mediaamazonmusic'
- || lc $cmd eq 'mediaspotifymusic'
- || lc $cmd eq 'mediatuneinradio'
- || lc $cmd eq 'mediaaldimusic'
- || lc $cmd eq 'mediayoutube'
- || lc $cmd eq 'mediavlcplayer'
- || lc $cmd eq 'mediaaudible'
- || lc $cmd eq 'screenbrightness'
- || lc $cmd eq 'screenorientation'
- || lc $cmd eq 'screenfullscreen'
- || lc $cmd eq 'screen'
- || 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'
- || lc $cmd eq 'changetobtdevice'
- || lc $cmd eq 'clearnotificationbar'
- || lc $cmd eq 'activatevoiceinput'
- || lc $cmd eq 'volumenotification'
- || lc $cmd eq 'volumeringsound'
- || lc $cmd eq 'screenlock'
- || lc $cmd eq 'statusrequest'
- || lc $cmd eq 'sendsms'
- || lc $cmd eq 'sendintent'
- || lc $cmd eq 'currentflowsetupdate'
- || lc $cmd eq 'installflowsource'
- || lc $cmd eq 'opencall'
- || lc $cmd eq 'closecall'
- || lc $cmd eq 'donotdisturb'
- || lc $cmd eq 'userflowstate'
- || lc $cmd eq 'startdaydream'
- || lc $cmd eq 'vibrate') {
-
- Log3 $name, 5, "AMAD ($name) - set $name $cmd ".join(" ", @val);
-
- return AMAD_SelectSetCmd( $hash, $cmd, @val ) if( lc $cmd eq 'statusrequest' );
- return "set command only works if state not equal initialized" if( ReadingsVal( $hash->{NAME}, "state", 0 ) eq "initialized");
- return "Cannot set command, FHEM Device is disabled" if( AttrVal( $name, "disable", "0" ) eq "1" );
-
- return "Cannot set command, FHEM Device is unknown" if( ReadingsVal( $name, "deviceState", "online" ) eq "unknown" );
- return "Cannot set command, FHEM Device is offline" if( ReadingsVal( $name, "deviceState", "online" ) eq "offline" );
-
- return AMAD_SelectSetCmd( $hash, $cmd, @val ) if( (@val) or (lc $cmd eq 'activatevoiceinput') or (lc $cmd eq 'vibrate') or (lc $cmd eq 'currentflowsetupdate') or (lc $cmd eq 'closecall') or (lc $cmd eq 'startdaydream') );
- }
-
- return "Unknown argument $cmd, bearword as argument or wrong parameter(s), choose one of $list";
-
- } elsif( $modules{AMAD}{defptr}{BRIDGE} ) {
-
- my $list = "";
-
- ## set Befehle für die AMAD_CommBridge
- $list .= "expertMode:0,1 " if( $modules{AMAD}{defptr}{BRIDGE} );
- $list .= "fhemServerIP " if( $modules{AMAD}{defptr}{BRIDGE} );
-
- if( lc $cmd eq 'expertmode'
- || lc $cmd eq 'fhemserverip' ) {
-
- readingsSingleUpdate( $hash, $cmd, $val[0], 0 );
-
- return;
- }
-
- return "Unknown argument $cmd, bearword as argument or wrong parameter(s), choose one of $list";
- }
-}
-
-sub AMAD_SelectSetCmd($$@) {
-
- my ( $hash, $cmd, @data ) = @_;
- my $name = $hash->{NAME};
- my $host = $hash->{HOST};
- my $port = $hash->{PORT};
-
- if( lc $cmd eq 'screenmsg' ) {
- my $msg = join( " ", @data );
-
- $msg =~ s/%/%25/g;
- $msg =~ s/\s/%20/g;
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/screenMsg?message=$msg";
- Log3 $name, 4, "AMAD ($name) - Sub AMAD_SetScreenMsg";
-
- return AMAD_HTTP_POST( $hash,$url );
- }
-
- elsif( lc $cmd eq 'ttsmsg' ) {
-
- my $msg = join( " ", @data );
- my $speed = AttrVal( $name, "setTtsMsgSpeed", "1.0" );
- my $lang = AttrVal( $name, "setTtsMsgLang","de" );
-
- $msg =~ s/%/%25/g;
- $msg =~ s/\s/%20/g;
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/ttsMsg?message=".$msg."&msgspeed=".$speed."&msglang=".$lang;
-
- return AMAD_HTTP_POST( $hash,$url );
- }
-
- elsif( lc $cmd eq 'userflowstate' ) {
-
- my $datas = join( " ", @data );
- my ($flow,$state) = split( ":", $datas);
-
- $flow =~ s/\s/%20/g;
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/flowState?flowstate=".$state."&flowname=".$flow;
-
- return AMAD_HTTP_POST( $hash,$url );
- }
-
- elsif( lc $cmd eq 'volume' ) {
-
- my $vol = join( " ", @data );
-
- if( $vol =~ /^\+(.*)/ or $vol =~ /^-(.*)/ ) {
-
- if( $vol =~ /^\+(.*)/ ) {
-
- $vol =~ s/^\+//g;
- $vol = ReadingsVal( $name, "volume", 15 ) + $vol;
- }
-
- elsif( $vol =~ /^-(.*)/ ) {
-
- $vol =~ s/^-//g;
- printf $vol;
- $vol = ReadingsVal( $name, "volume", 15 ) - $vol;
- }
- }
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/setVolume?volume=$vol";
-
- return AMAD_HTTP_POST( $hash, $url );
- }
-
- elsif( lc $cmd eq 'volumenotification' ) {
-
- my $vol = join( " ", @data );
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/setNotifiVolume?notifivolume=$vol";
-
- return AMAD_HTTP_POST( $hash, $url );
- }
-
- elsif( lc $cmd eq 'volumeringsound' ) {
-
- my $vol = join( " ", @data );
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/setRingSoundVolume?ringsoundvolume=$vol";
-
- return AMAD_HTTP_POST( $hash, $url );
- }
-
- elsif( lc $cmd =~ /^media/ ) {
-
- my $btn = join( " ", @data );
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/multimediaControl?mplayer=".$cmd."&button=".$btn;
-
- return AMAD_HTTP_POST( $hash,$url );
- }
-
- elsif( lc $cmd eq 'screenbrightness' ) {
-
- my $bri = join( " ", @data );
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/setBrightness?brightness=$bri";
-
- return AMAD_HTTP_POST( $hash,$url );
- }
-
- elsif( lc $cmd eq 'screen' ) {
-
- my $mod = join( " ", @data );
- my $scot = AttrVal( $name, "setScreenOnForTimer", undef );
- $scot = 60 if( !$scot );
-
- if ($mod eq "on" || $mod eq "off") {
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/setScreenOnOff?screen=".$mod."&screenontime=".$scot if ($mod eq "on" || $mod eq "off");
-
- return AMAD_HTTP_POST( $hash,$url );
- }
-
- elsif ($mod eq "lock" || $mod eq "unlock") {
-
- return "Please set \"setScreenlockPIN\" Attribut first" if( AttrVal( $name, "setScreenlockPIN", "none" ) eq "none" );
- my $PIN = AttrVal( $name, "setScreenlockPIN", undef );
- $PIN = AMAD_decrypt($PIN);
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/screenlock?lockmod=".$mod."&lockPIN=".$PIN;
-
- return AMAD_HTTP_POST( $hash,$url );
- }
- }
-
- elsif( lc $cmd eq 'screenorientation' ) {
-
- my $mod = join( " ", @data );
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/setScreenOrientation?orientation=$mod";
-
- return AMAD_HTTP_POST( $hash,$url );
- }
-
- elsif( lc $cmd eq 'activatevoiceinput' ) {
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/setvoicecmd";
-
- return AMAD_HTTP_POST( $hash,$url );
- }
-
- elsif( lc $cmd eq 'screenfullscreen' ) {
-
- my $mod = join( " ", @data );
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/setScreenFullscreen?fullscreen=$mod";
-
- readingsSingleUpdate( $hash, $cmd, $mod, 1 );
-
- return AMAD_HTTP_POST( $hash, $url );
- }
-
- elsif( lc $cmd eq 'openurl' ) {
-
- my $openurl = join( " ", @data );
- my $browser = AttrVal( $name, "setOpenUrlBrowser", "com.android.chrome|com.google.android.apps.chrome.Main" );
- my @browserapp = split( /\|/, $browser );
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/openURL?url=".$openurl."&browserapp=".$browserapp[0]."&browserappclass=".$browserapp[1];
-
- return AMAD_HTTP_POST( $hash, $url );
- }
-
- elsif (lc $cmd eq 'nextalarmtime') {
-
- my $value = join( " ", @data );
- my @alarm = split( ":", $value );
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/setAlarm?hour=".$alarm[0]."&minute=".$alarm[1];
-
- 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_statusRequest( $hash );
- return undef;
- }
-
- elsif( lc $cmd eq 'openapp' ) {
-
- my $app = join( " ", @data );
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/openApp?app=$app";
-
- return AMAD_HTTP_POST( $hash,$url );
- }
-
- elsif( lc $cmd eq 'system' ) {
-
- my $systemcmd = join( " ", @data );
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/systemcommand?syscmd=$systemcmd";
-
- readingsSingleUpdate( $hash, "airplanemode", "on", 1 ) if( $systemcmd eq "airplanemodeON" );
- readingsSingleUpdate( $hash, "deviceState", "offline", 1 ) if( $systemcmd eq "airplanemodeON" || $systemcmd eq "shutdown" );
-
- return AMAD_HTTP_POST( $hash,$url );
- }
-
- elsif( lc $cmd eq 'donotdisturb' ) {
-
- my $disturbmod = join( " ", @data );
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/donotdisturb?disturbmod=$disturbmod";
-
- return AMAD_HTTP_POST( $hash,$url );
- }
-
- elsif( lc $cmd eq 'bluetooth' ) {
-
- my $mod = join( " ", @data );
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/setbluetooth?bluetooth=$mod";
-
- return AMAD_HTTP_POST( $hash,$url );
- }
-
- elsif( lc $cmd eq 'notifysndfile' ) {
-
- my $notify = join( " ", @data );
- my $filepath = AttrVal( $name, "setNotifySndFilePath", "/storage/emulated/0/Notifications/" );
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/playnotifysnd?notifyfile=".$notify."¬ifypath=".$filepath;
-
- return AMAD_HTTP_POST( $hash,$url );
- }
-
- elsif( lc $cmd eq 'changetobtdevice' ) {
-
- my $swToBtDevice = join( " ", @data );
- my @swToBtMac = split( /\|/, $swToBtDevice );
- my $btDevices = AttrVal( $name, "setBluetoothDevice", "none" ) if( AttrVal( $name, "setBluetoothDevice", "none" ) ne "none" );
- my @btDevice = split( ',', $btDevices );
- my @btDeviceOne = split( /\|/, $btDevice[0] );
- my @btDeviceTwo = split( /\|/, $btDevice[1] );
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/setbtdevice?swToBtDeviceMac=".$swToBtMac[1]."&btDeviceOne=".$btDeviceOne[1]."&btDeviceTwo=".$btDeviceTwo[1];
-
- return AMAD_HTTP_POST( $hash,$url );
- }
-
- elsif( lc $cmd eq 'clearnotificationbar' ) {
-
- my $appname = join( " ", @data );
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/clearnotificationbar?app=$appname";
-
- return AMAD_HTTP_POST( $hash,$url );
- }
-
- elsif( lc $cmd eq 'vibrate' ) {
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/setvibrate";
-
- return AMAD_HTTP_POST( $hash,$url );
- }
-
- elsif( lc $cmd eq 'sendintent' ) {
-
- my $intentstring = join( " ", @data );
- my ( $action, $exkey1, $exval1, $exkey2, $exval2 ) = split( "[ \t][ \t]*", $intentstring );
- $exkey1 = "" if( !$exkey1 );
- $exval1 = "" if( !$exval1 );
- $exkey2 = "" if( !$exkey2 );
- $exval2 = "" if( !$exval2 );
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/sendIntent?action=".$action."&exkey1=".$exkey1."&exval1=".$exval1."&exkey2=".$exkey2."&exval2=".$exval2;
-
- return AMAD_HTTP_POST( $hash,$url );
- }
-
- elsif( lc $cmd eq 'installflowsource' ) {
-
- my $flowname = join( " ", @data );
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/installFlow?flowname=$flowname";
-
- return AMAD_HTTP_POST( $hash,$url );
- }
-
- elsif( lc $cmd eq 'opencall' ) {
-
- my $string = join( " ", @data );
- my ($callnumber, $time) = split( "[ \t][ \t]*", $string );
- $time = "none" if( !$time );
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/openCall?callnumber=".$callnumber."&hanguptime=".$time;
-
- return AMAD_HTTP_POST( $hash,$url );
- }
-
- elsif( lc $cmd eq 'closecall' ) {
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/closeCall";
-
- return AMAD_HTTP_POST( $hash,$url );
- }
-
- elsif( lc $cmd eq 'startdaydream' ) {
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/startDaydream";
-
- 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 );
- }
-
- elsif( lc $cmd eq 'sendsms' ) {
- my $string = join( " ", @data );
- my ($smsmessage, $smsnumber) = split( "\\|", $string );
-
- $smsmessage =~ s/%/%25/g;
- $smsmessage =~ s/\s/%20/g;
-
- my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/sendSms?smsmessage=".$smsmessage."&smsnumber=".$smsnumber;
-
- return AMAD_HTTP_POST( $hash,$url );
- }
-
- return undef;
-}
-
-sub AMAD_HTTP_POST($$) {
-
- my ( $hash, $url ) = @_;
- my $name = $hash->{NAME};
-
- my $state = ReadingsVal( $name, "state", 0 );
-
- readingsSingleUpdate( $hash, "state", "Send HTTP POST", 1 );
-
- HttpUtils_NonblockingGet(
- {
- url => $url,
- timeout => 15,
- hash => $hash,
- method => "POST",
- header => "Connection: close",
- doTrigger => 1,
- callback => \&AMAD_HTTP_POSTerrorHandling,
- }
- );
-
- Log3 $name, 4, "AMAD ($name) - Send HTTP POST with URL $url";
-
- readingsSingleUpdate( $hash, "state", $state, 1 );
-
- return undef;
-}
-
-sub AMAD_HTTP_POSTerrorHandling($$$) {
-
- my ( $param, $err, $data ) = @_;
- my $hash = $param->{hash};
- my $name = $hash->{NAME};
-
-
- ### Begin Error Handling
- if( $hash->{helper}{setCmdErrorCounter} > 2 ) {
-
- readingsBeginUpdate( $hash );
- readingsBulkUpdate( $hash, "lastSetCommandState", "statusRequest_error" );
-
- if( ReadingsVal( $name, "flow_Informations", "active" ) eq "inactive" && ReadingsVal( $name, "flow_SetCommands", "active" ) eq "inactive" ) {
-
- Log3 $name, 5, "AMAD ($name) - setCommandERROR: CHECK THE LAST ERROR READINGS FOR MORE INFO, DEVICE IS SET OFFLINE";
-
- readingsBulkUpdate( $hash, "deviceState", "offline" );
- readingsBulkUpdate( $hash, "state", "AMAD Flows inactive, device set offline" );
- }
-
- elsif( $hash->{helper}{infoErrorCounter} > 7 && $hash->{helper}{setCmdErrorCounter} > 4 ) {
-
- Log3 $name, 5, "AMAD ($name) - setCommandERROR: UNKNOWN ERROR, PLEASE CONTACT THE DEVELOPER, DEVICE DISABLED";
-
- $attr{$name}{disable} = 1;
- readingsBulkUpdate( $hash, "state", "Unknown Error, device disabled" );
- $hash->{helper}{infoErrorCounter} = 0;
- $hash->{helper}{setCmdErrorCounter} = 0;
-
- return;
- }
-
- elsif( ReadingsVal( $name, "flow_SetCommands", "active" ) eq "inactive" ) {
-
- Log3 $name, 5, "AMAD ($name) - setCommandERROR: Flow SetCommands on your Device is inactive, will try to reactivate";
- }
-
- elsif( $hash->{helper}{setCmdErrorCounter} > 9 ) {
-
- Log3 $name, 5, "AMAD ($name) - setCommandERROR: To many Errors please check your Network or Device Configuration, DEVICE IS SET OFFLINE";
-
- readingsBulkUpdate( $hash, "deviceState", "offline" );
- readingsBulkUpdate( $hash, "state", "To many Errors, device set offline" );
- $hash->{helper}{setCmdErrorCounter} = 0;
- }
-
- elsif( $hash->{helper}{setCmdErrorCounter} > 4 && ReadingsVal( $name, "flow_SetCommands", "active" ) eq "active" ){
-
- Log3 $name, 5, "AMAD ($name) - setCommandERROR: Please check the AutomagicAPP on your Device";
- }
-
- readingsEndUpdate( $hash, 1 );
- }
-
- if( defined( $err ) ) {
- if( $err ne "" ) {
- readingsBeginUpdate( $hash );
- readingsBulkUpdate( $hash, "state", $err ) if( ReadingsVal( $name, "state", 0 ) ne "initialized" );
- $hash->{helper}{setCmdErrorCounter} = ($hash->{helper}{setCmdErrorCounter} + 1);
-
- readingsBulkUpdate( $hash, "lastSetCommandState", "setCmd_error" );
-
- if( $err =~ /timed out/ ) {
-
- Log3 $name, 5, "AMAD ($name) - setCommandERROR: connect to your device is timed out. check network";
- }
-
- elsif( $err =~ /Keine Route zum Zielrechner/ ) {
-
- Log3 $name, 5, "AMAD ($name) - setCommandERROR: no route to target. bad network configuration or network is down";
-
- } else {
-
- Log3 $name, 5, "AMAD ($name) - setCommandERROR: $err";
- }
-
- readingsEndUpdate( $hash, 1 );
-
- Log3 $name, 5, "AMAD ($name) - setCommandERROR: error while POST Command: $err";
-
- return;
- }
- }
-
- if( $data eq "" and exists( $param->{code} ) && $param->{code} ne 200 ) {
-
- readingsBeginUpdate( $hash );
- readingsBulkUpdate( $hash, "state", $param->{code} ) if( ReadingsVal( $hash, "state", 0 ) ne "initialized" );
-
- $hash->{helper}{setCmdErrorCounter} = ( $hash->{helper}{setCmdErrorCounter} + 1 );
-
- readingsBulkUpdate($hash, "lastSetCommandState", "setCmd_error" );
-
- readingsEndUpdate( $hash, 1 );
-
- Log3 $name, 5, "AMAD ($name) - setCommandERROR: received http code ".$param->{code};
-
- return;
- }
-
- if( ( $data =~ /Error/i ) and exists( $param->{code} ) ) {
-
- readingsBeginUpdate( $hash );
- readingsBulkUpdate( $hash, "state", $param->{code} ) if( ReadingsVal( $name, "state", 0 ) ne "initialized" );
-
- $hash->{helper}{setCmdErrorCounter} = ( $hash->{helper}{setCmdErrorCounter} + 1 );
-
- readingsBulkUpdate( $hash, "lastSetCommandState", "setCmd_error" );
-
- if( $param->{code} eq 404 ) {
-
- readingsBulkUpdate( $hash, "lastSetCommandError", "" );
- Log3 $name, 5, "AMAD ($name) - setCommandERROR: setCommands flow is inactive on your device!";
-
- } else {
-
- Log3 $name, 5, "AMAD ($name) - setCommandERROR: http error ".$param->{code};
- }
-
- return;
- }
-
- ### End Error Handling
-
- readingsSingleUpdate( $hash, "lastSetCommandState", "setCmd_done", 1 );
- $hash->{helper}{setCmdErrorCounter} = 0;
-
- return undef;
-}
-
-sub AMAD_checkDeviceState($) {
-
- my ( $hash ) = @_;
- my $name = $hash->{NAME};
-
- Log3 $name, 4, "AMAD ($name) - AMAD_checkDeviceState: run Check";
-
- RemoveInternalTimer( $hash );
-
- if( ReadingsAge( $name, "deviceState", 90 ) > 90 ) {
-
- AMAD_statusRequest( $hash ) if( $hash->{helper}{deviceStateErrorCounter} == 0 );
- readingsSingleUpdate( $hash, "deviceState", "offline", 1 ) if( ReadingsAge( $name, "deviceState", 180) > 180 and $hash->{helper}{deviceStateErrorCounter} > 0 );
- $hash->{helper}{deviceStateErrorCounter} = ( $hash->{helper}{deviceStateErrorCounter} + 1 );
- }
-
- InternalTimer( gettimeofday()+90, "AMAD_checkDeviceState", $hash, 0 );
-
- Log3 $name, 4, "AMAD ($name) - AMAD_checkDeviceState: set new Timer";
-}
-
-sub AMAD_CommBridge_Open($) {
-
- my ( $hash ) = @_;
- my $name = $hash->{NAME};
- my $port = $hash->{PORT};
-
-
- # Oeffnen des TCP Sockets
- my $ret = TcpServer_Open( $hash, $port, "global" );
-
- if( $ret && !$init_done ) {
-
- Log3 $name, 3, "$ret. Exiting.";
- exit(1);
- }
-
- readingsSingleUpdate ( $hash, "state", "opened", 1 );
- Log3 $name, 5, "Socket wird geöffnet.";
-
- return $ret;
-}
-
-sub AMAD_CommBridge_Read($) {
-
- my ( $hash ) = @_;
- my $name = $hash->{NAME};
- my $bhash = $modules{AMAD}{defptr}{BRIDGE};
- my $bname = $bhash->{NAME};
-
-
-
- if( $hash->{SERVERSOCKET} ) { # Accept and create a child
- TcpServer_Accept( $hash, "AMAD" );
- return;
- }
-
- # Read 1024 byte of data
- my $buf;
- my $ret = sysread($hash->{CD}, $buf, 1024);
-
-
-
- # When there is an error in connection return
- if( !defined($ret ) || $ret <= 0 ) {
- CommandDelete( undef, $hash->{NAME} );
- return;
- }
-
-
- #### Verarbeitung der Daten welche über die AMADCommBridge kommen ####
-
- Log3 $bname, 5, "AMAD ($bname) - Receive RAW Message in Debugging Mode: $buf";
-
- ###
- ## Consume Content
- ###
-
- my @data = split( '\R\R', $buf );
-
- my $header = AMAD_Header2Hash( $data[0] );
- my $response;
- my $c;
- my $device = $header->{FHEMDEVICE} if(defined($header->{FHEMDEVICE}));
- my $fhemcmd = $header->{FHEMCMD} if(defined($header->{FHEMCMD}));
- my $dhash = $defs{$device} if(defined($device));
-
-
-
-
- if ( $data[0] =~ /currentFlowsetUpdate.xml/ ) {
-
- my $fhempath = $attr{global}{modpath};
- $response = qx(cat $fhempath/FHEM/lib/74_AMADautomagicFlowset_$flowsetversion.xml);
- $c = $hash->{CD};
- print $c "HTTP/1.1 200 OK\r\n",
- "Content-Type: text/plain\r\n",
- "Connection: close\r\n",
- "Content-Length: ".length($response)."\r\n\r\n",
- $response;
-
- return;
- }
-
- elsif ( $data[0] =~ /installFlow_([^.]*.xml)/ ) {
-
- if( defined($1) ){
- $response = qx(cat /tmp/$1);
- $c = $hash->{CD};
- print $c "HTTP/1.1 200 OK\r\n",
- "Content-Type: text/plain\r\n",
- "Connection: close\r\n",
- "Content-Length: ".length($response)."\r\n\r\n",
- $response;
-
- return;
- }
- }
-
-
-
- elsif( !defined($device) ) {
- readingsSingleUpdate( $bhash, "transmitterERROR", $name." has no device name sends", 1 ) if( ReadingsVal( $bname, "expertMode", 0 ) eq "1" );
- Log3 $name, 4, "AMAD ($name) - ERROR - no device name given. please check your global variable in automagic";
-
- $response = "header lines: \r\n AMADCommBridge receive no device name. please check your global variable in automagic\r\n FHEM to do nothing\r\n";
- $c = $hash->{CD};
- print $c "HTTP/1.1 200 OK\r\n",
- "Content-Type: text/plain\r\n",
- "Connection: close\r\n",
- "Content-Length: ".length($response)."\r\n\r\n",
- $response;
-
- return;
- }
-
-
-
- if( defined($fhemcmd) and ($fhemcmd) ) {
- if ( $fhemcmd =~ /setreading\b/ ) {
- my $tv = $data[1];
- return Log3 $bname, 3, "AMAD ($bname) - AMAD_CommBridge: processing receive no reading values from Device: $device"
- unless( defined($tv) and ($tv) );
-
- Log3 $bname, 4, "AMAD ($bname) - AMAD_CommBridge: processing receive reading values - Device: $device Data: $tv";
-
- AMAD_ResponseProcessing($dhash,$tv);
-
- $response = "header lines: \r\n AMADCommBridge receive Data complete\r\n FHEM was processes\r\n";
- $c = $hash->{CD};
- print $c "HTTP/1.1 200 OK\r\n",
- "Content-Type: text/plain\r\n",
- "Connection: close\r\n",
- "Content-Length: ".length($response)."\r\n\r\n",
- $response;
-
- return;
- }
-
- elsif ( $fhemcmd =~ /set\b/ ) {
- my $fhemCmd = $data[1];
-
- fhem ("set $fhemCmd") if( ReadingsVal( $bname, "expertMode", 0 ) eq "1" );
- readingsSingleUpdate( $bhash, "receiveFhemCommand", "set ".$fhemCmd, 0 );
- Log3 $bname, 4, "AMAD ($bname) - AMAD_CommBridge: set reading receive fhem command";
-
- $response = "header lines: \r\n AMADCommBridge receive Data complete\r\n FHEM execute set command now\r\n";
- $c = $hash->{CD};
- print $c "HTTP/1.1 200 OK\r\n",
- "Content-Type: text/plain\r\n",
- "Connection: close\r\n",
- "Content-Length: ".length($response)."\r\n\r\n",
- $response;
-
- return;
- }
-
- elsif ( $fhemcmd =~ /voiceinputvalue\b/ ) {
- my $fhemCmd = lc $data[1];
-
- readingsBeginUpdate( $bhash);
- readingsBulkUpdate( $bhash, "receiveVoiceCommand", $fhemCmd );
- readingsBulkUpdate( $bhash, "receiveVoiceDevice", $device );
- readingsEndUpdate( $bhash, 1 );
- Log3 $bname, 4, "AMAD ($bname) - AMAD_CommBridge: set reading receive voice command: $fhemCmd from Device $device";
-
- $response = "header lines: \r\n AMADCommBridge receive Data complete\r\n FHEM was processes\r\n";
- $c = $hash->{CD};
- print $c "HTTP/1.1 200 OK\r\n",
- "Content-Type: text/plain\r\n",
- "Connection: close\r\n",
- "Content-Length: ".length($response)."\r\n\r\n",
- $response;
-
- return;
- }
-
- elsif ( $fhemcmd =~ /readingsval\b/ ) {
- my $fhemCmd = $data[1];
- my @datavalue = split( ' ', $fhemCmd );
-
- $response = ReadingsVal( $datavalue[0], $datavalue[1], $datavalue[2] );
- $c = $hash->{CD};
- print $c "HTTP/1.1 200 OK\r\n",
- "Content-Type: text/plain\r\n",
- "Connection: close\r\n",
- "Content-Length: ".length($response)."\r\n\r\n",
- $response;
-
- Log3 $bname, 4, "AMAD ($bname) - AMAD_CommBridge: response ReadingsVal Value to Automagic Device";
- return;
- }
-
- elsif ( $fhemcmd =~ /fhemfunc\b/ ) {
- my $fhemCmd = $data[1];
-
- Log3 $bname, 4, "AMAD ($bname) - AMAD_CommBridge: receive fhem-function command";
-
- if( $fhemCmd =~ /^{.*}$/ ) {
-
- $response = $fhemCmd if( ReadingsVal( $bname, "expertMode", 0 ) eq "1" );
-
- } else {
-
- $response = "header lines: \r\n AMADCommBridge receive no typical FHEM function\r\n FHEM to do nothing\r\n";
- }
-
- $c = $hash->{CD};
- print $c "HTTP/1.1 200 OK\r\n",
- "Content-Type: text/plain\r\n",
- "Connection: close\r\n",
- "Content-Length: ".length($response)."\r\n\r\n",
- $response;
-
- return;
- }
-
- }
-
-
- $response = "header lines: \r\n AMADCommBridge receive incomplete or corrupt Data\r\n FHEM to do nothing\r\n";
- $c = $hash->{CD};
- print $c "HTTP/1.1 200 OK\r\n",
- "Content-Type: text/plain\r\n",
- "Connection: close\r\n",
- "Content-Length: ".length($response)."\r\n\r\n",
- $response;
-}
-
-sub AMAD_Header2Hash($) {
-
- my ( $string ) = @_;
- my %hash = ();
-
- foreach my $line (split("\r\n", $string)) {
- my ($key,$value) = split( ": ", $line );
- next if( !$value );
-
- $value =~ s/^ //;
- $hash{$key} = $value;
- }
-
- return \%hash;
-}
-
-sub AMAD_encrypt($) {
-
- my ($decodedPIN) = @_;
- my $key = getUniqueId();
- my $encodedPIN;
-
- return $decodedPIN if( $decodedPIN =~ /^crypt:(.*)/ );
-
- for my $char (split //, $decodedPIN) {
- my $encode = chop($key);
- $encodedPIN .= sprintf("%.2x",ord($char)^ord($encode));
- $key = $encode.$key;
- }
-
- return 'crypt:'. $encodedPIN;
-}
-
-sub AMAD_decrypt($) {
-
- my ($encodedPIN) = @_;
- my $key = getUniqueId();
- my $decodedPIN;
-
- $encodedPIN = $1 if( $encodedPIN =~ /^crypt:(.*)/ );
-
- for my $char (map { pack('C', hex($_)) } ($encodedPIN =~ /(..)/g)) {
- my $decode = chop($key);
- $decodedPIN .= chr(ord($char)^ord($decode));
- $key = $decode.$key;
- }
-
- return $decodedPIN;
-}
-
-
-
-
-1;
-
-=pod
-
-=item device
-=item summary Integrates Android devices into FHEM and displays several settings.
-=item summary_DE Integriert Android-Geräte in FHEM und zeigt verschiedene Einstellungen an.
-
-=begin html
-
-
-AMAD
-
- AMAD - Automagic Android Device
-
- This module integrates Android devices into FHEM and displays several settings using the Android app "Automagic".
- Automagic is comparable to the "Tasker" app for automating tasks and configuration settings. But Automagic is more user-friendly. The "Automagic Premium" app currently costs EUR 2.90.
-
- Any information retrievable by Automagic can be displayed in FHEM by this module. Just define your own Automagic-"flow" and send the data to the AMADCommBridge. One even can control several actions on Android devices.
-
- To be able to make use of all these functions the Automagic app and additional flows need to be installed on the Android device. The flows can be retrieved from the FHEM directory, the app can be bought in Google Play Store.
-
- How to use AMAD?
-
- - install the "Automagic Premium" app from the Google Play store.
- - install the flowset 74_AMADautomagicFlowset$VERSION.xml from the directory $INSTALLFHEM/FHEM/lib/ on your Android device and activate.
-
-
- Now you need to define a device in FHEM.
-
-
- Define
-
- define <name> AMAD <IP-ADDRESS>
-
- Example:
-
- define WandTabletWohnzimmer AMAD 192.168.0.23
-
-
- With this command two new AMAD devices in a room called AMAD are created. The parameter <IP-ADDRESS< defines the IP address of your Android device. The second device created is the AMADCommBridge which serves as a communication device from each Android device to FHEM.
- !!!Coming Soon!!! The communication port of each AMAD device may be set by the definition of the "port" attribute. One needs background knowledge of Automagic and HTTP requests as this port will be set in the HTTP request trigger of both flows, therefore the port also needs to be set there.
-
- The communication port of the AMADCommBridge device can easily be changed within the attribut "port".
-
- AMAD Communication Bridge
-
- Creating your first AMAD device automatically creates the AMADCommBridge device in the room AMAD. With the help of the AMADCommBridge any Android device communicates initially to FHEM.To make the IP addresse of the FHEM server known to the Android device, the FHEM server IP address needs to be configured in the AMADCommBridge. WITHOUT THIS STEP THE AMADCommBridge WILL NOT WORK PROPERLY.
- Please us the following command for configuration of the FHEM server IP address in the AMADCommBridge: set AMADCommBridge fhemServerIP <FHEM-IP>.
- Additionally the expertMode may be configured. By this setting a direct communication with FHEM will be established without the restriction of needing to make use of a notify to execute set commands.
-
-
- You are finished now! After 15 seconds latest the readings of your AMAD Android device should be updated. Consequently each 15 seconds a status request will be sent. If the state of your AMAD Android device does not change to "active" over a longer period of time one should take a look into the log file for error messages.
-
-
- Readings
-
- - airplanemode - on/off, state of the aeroplane mode
- - androidVersion - currently installed version of Android
- - automagicState - state of the Automagic App (prerequisite Android >4.3). In case you have Android >4.3 and the reading says "not supported", you need to enable Automagic inside Android / Settings / Sound & notification / Notification access
- - batteryHealth - the health of the battery (1=unknown, 2=good, 3=overheat, 4=dead, 5=over voltage, 6=unspecified failure, 7=cold)
- - batterytemperature - the temperature of the battery
- - bluetooth - on/off, bluetooth state
- - checkActiveTask - state of an app (needs to be defined beforehand). 0=not active or not active in foreground, 1=active in foreground, see note below
- - connectedBTdevices - list of all devices connected via bluetooth
- - connectedBTdevicesMAC - list of MAC addresses of all devices connected via bluetooth
- - currentMusicAlbum - currently playing album of mediaplayer
- - currentMusicApp - currently playing player app (Amazon Music, Google Play Music, Google Play Video, Spotify, YouTube, TuneIn Player, Aldi Life Music)
- - currentMusicArtist - currently playing artist of mediaplayer
- - currentMusicIcon - cover of currently play albumNoch nicht fertig implementiert
- - currentMusicState - state of currently/last used mediaplayer
- - currentMusicTrack - currently playing song title of mediaplayer
- - daydream - on/off, daydream currently active
- - deviceState - state of Android devices. unknown, online, offline.
- - doNotDisturb - state of do not Disturb Mode
- - dockingState - undocked/docked, Android device in docking station
- - flow_SetCommands - active/inactive, state of SetCommands flow
- - flow_informations - active/inactive, state of Informations flow
- - flowsetVersionAtDevice - currently installed version of the flowsets on the Android device
- - incomingCallerName - Callername from last Call
- - incomingCallerNumber - Callernumber from last Call
- - incommingWhatsAppMessageFrom - last WhatsApp message
- - incommingWhatsTelegramMessageFrom - last telegram message
- - intentRadioName - name of the most-recent streamed intent radio
- - intentRadioState - state of intent radio player
- - keyguardSet - 0/1 keyguard set, 0=no 1=yes, does not indicate whether it is currently active
- - lastSetCommandError - last error message of a set command
- - lastSetCommandState - last state of a set command, command send successful/command send unsuccessful
- - lastStatusRequestError - last error message of a statusRequest command
- - lastStatusRequestState - ast state of a statusRequest command, command send successful/command send unsuccessful
- - nextAlarmDay - currently set day of alarm
- - nextAlarmState - alert/done, current state of "Clock" stock-app
- - nextAlarmTime - currently set time of alarm
- - powerLevel - state of battery in %
- - powerPlugged - 0=no/1,2=yes, power supply connected
- - screen - on locked,unlocked/off locked,unlocked, state of display
- - screenBrightness - 0-255, level of screen-brightness
- - screenFullscreen - on/off, full screen mode
- - screenOrientation - Landscape/Portrait, screen orientation (horizontal,vertical)
- - screenOrientationMode - auto/manual, mode for screen orientation
- - state - current state of AMAD device
- - userFlowState - current state of a Flow, established under setUserFlowState Attribut
- - volume - media volume setting
- - volumeNotification - notification volume setting
-
- Prerequisite for using the reading checkActivTask the package name of the application to be checked needs to be defined in the attribute checkActiveTask. Example: attr Nexus10Wohnzimmer
- checkActiveTask com.android.chrome für den Chrome Browser.
-
-
-
-
- Set
-
- - activateVoiceInput - start voice input on Android device
- - bluetooth - on/off, switch bluetooth on/off
- - clearNotificationBar - All/Automagic, deletes all or only Automagic notifications in status bar
- - closeCall - hang up a running call
- - currentFlowsetUpdate - start flowset update on Android device
- - installFlowSource - install a Automagic flow on device, XML file must be stored in /tmp/ with extension xml. Example: set TabletWohnzimmer installFlowSource WlanUebwerwachen.xml
- - doNotDisturb - sets the do not Disturb Mode, always Disturb, never Disturb, alarmClockOnly alarm Clock only, onlyImportant only important Disturbs
- - mediaAmazonMusic - play/stop/next/back , controlling the amazon music media player
- - mediaGoogleMusic - play/stop/next/back , controlling the google play music media player
- - mediaSpotifyMusic - play/stop/next/back , controlling the spotify media player
- - mediaTuneinRadio - play/stop/next/back , controlling the TuneinRadio media player
- - mediaAldiMusic - play/stop/next/back , controlling the Aldi music media player
- - mediaAudible - play/stop/next/back , controlling the Audible media player
- - mediaYouTube - play/stop/next/back , controlling the YouTube media player
- - mediaVlcPlayer - play/stop/next/back , controlling the VLC media player
- - nextAlarmTime - sets the alarm time. Only valid for the next 24 hours.
- - notifySndFile - plays a media-file which by default needs to be stored in the folder "/storage/emulated/0/Notifications/" of the Android device. You may use the attribute setNotifySndFilePath for defining a different folder.
- - openCall - initial a call and hang up after optional time / set DEVICE openCall 0176354 10 call this number and hang up after 10s
- - screenBrightness - 0-255, set screen brighness
- - screenMsg - display message on screen of Android device
- - sendintent - send intent string Example: set $AMADDEVICE sendIntent org.smblott.intentradio.PLAY url http://stream.klassikradio.de/live/mp3-192/stream.klassikradio.de/play.m3u name Klassikradio, first parameter contains the action, second parameter contains the extra. At most two extras can be used.
- - sendSMS - Sends an SMS to a specific phone number. Bsp.: sendSMS Dies ist ein Test|555487263
- - startDaydream - start Daydream
- - statusRequest - Get a new status report of Android device. Not all readings can be updated using a statusRequest as some readings are only updated if the value of the reading changes.
- - timer - set a countdown timer in the "Clock" stock app. Only seconds are allowed as parameter.
- - ttsMsg - send a message which will be played as voice message
- - userFlowState - set Flow/s active or inactive,set Nexus7Wohnzimmer Badezimmer:inactive vorheizen or set Nexus7Wohnzimmer Badezimmer vorheizen,Nachtlicht Steven:inactive
- - vibrate - vibrate Android device
- - volume - set media volume. Works on internal speaker or, if connected, bluetooth speaker or speaker connected via stereo jack
- - volumeNotification - set notifications volume
-
-
- Set (depending on attribute values)
-
- - changetoBtDevice - switch to another bluetooth device. Attribute setBluetoothDevice needs to be set. See note below!
- - openApp - start an app. attribute setOpenApp
- - openURL - opens a URLS in the standard browser as long as no other browser is set by the attribute setOpenUrlBrowser.Example: attr Tablet setOpenUrlBrowser de.ozerov.fully|de.ozerov.fully.MainActivity, first parameter: package name, second parameter: Class Name
- - screen - on/off/lock/unlock, switch screen on/off or lock/unlock screen. In Automagic "Preferences" the "Device admin functions" need to be enabled, otherwise "Screen off" does not work. attribute setScreenOnForTimer changes the time the display remains switched on!
- - screenFullscreen - on/off, activates/deactivates full screen mode. attribute setFullscreen
- - screenLock - Locks screen with request for PIN. attribute setScreenlockPIN - enter PIN here. Only use numbers, 4-16 numbers required.
- - screenOrientation - Auto,Landscape,Portait, set screen orientation (automatic, horizontal, vertical). attribute setScreenOrientation
- - system - issue system command (only with rooted Android devices). reboot,shutdown,airplanemodeON (can only be switched ON) attribute root, in Automagic "Preferences" "Root functions" need to be enabled.
- - setAPSSID - set WLAN AccesPoint SSID to prevent WLAN sleeps
- - setNotifySndFilePath - set systempath to notifyfile (default /storage/emulated/0/Notifications/
- - setTtsMsgSpeed - set speaking speed for TTS (Value between 0.5 - 4.0, 0.5 Step) default is 1.0
- - setTtsMsgLang - set speaking language for TTS, de or en (default is de)
-
- To be able to use "openApp" the corresponding attribute "setOpenApp" needs to contain the app package name.
-
- To be able to switch between bluetooth devices the attribute "setBluetoothDevice" needs to contain (a list of) bluetooth devices defined as follows: attr <DEVICE> BTdeviceName1|MAC,BTDeviceName2|MAC No spaces are allowed in any BTdeviceName. Defining MAC please make sure to use the character : (colon) after each second digit/character.
- Example: attr Nexus10Wohnzimmer setBluetoothDevice Logitech_BT_Adapter|AB:12:CD:34:EF:32,Anker_A3565|GH:56:IJ:78:KL:76
-
-
-
- state
-
- - initialized - shown after initial define.
- - active - device is active.
- - disabled - device is disabled by the attribute "disable".
-
-
- Further examples and reading:
-
-
-
-
-=end html
-=begin html_DE
-
-
-AMAD
-
- AMAD - Automagic Android Device
-
- Dieses Modul liefert, in Verbindung mit der Android APP Automagic, diverse Informationen von Android Geräten.
- Die AndroidAPP Automagic (welche nicht von mir stammt und 2.90 Euro kostet) funktioniert wie Tasker, ist aber bei weitem User freundlicher.
-
- Mit etwas Einarbeitung können jegliche Informationen welche Automagic bereit stellt in FHEM angezeigt werden. Hierzu bedarf es lediglich eines eigenen Flows welcher seine Daten an die AMADCommBridge sendet. Das Modul gibt auch die Möglichkeit Androidgeräte zu steuern.
-
- Für all diese Aktionen und Informationen wird auf dem Androidgerät "Automagic" und ein so genannter Flow benötigt. Die App ist über den Google PlayStore zu beziehen. Das benötigte Flowset bekommt man aus dem FHEM Verzeichnis.
-
- Wie genau verwendet man nun AMAD?
-
- - man installiert die App "Automagic Premium" aus dem PlayStore.
- - dann installiert man das Flowset 74_AMADautomagicFlowset$VERSION.xml aus dem Ordner $INSTALLFHEM/FHEM/lib/ auf dem Androidgerät und aktiviert die Flows.
-
-
- Es muß noch ein Device in FHEM anlegt werden.
-
-
- Define
-
- define <name> AMAD <IP-ADRESSE>
-
- Beispiel:
-
- define WandTabletWohnzimmer AMAD 192.168.0.23
-
-
- Diese Anweisung erstellt zwei neues AMAD-Device im Raum AMAD.Der Parameter <IP-ADRESSE> legt die IP Adresse des Android Gerätes fest.
- Das zweite Device ist die AMADCommBridge welche als Kommunikationsbrücke vom Androidgerät zu FHEM diehnt. !!!Comming Soon!!! Wer den Port ändern möchte, kann dies über das Attribut "port" tun. Ihr solltet aber wissen was Ihr tut, da dieser Port im HTTP Request Trigger der beiden Flows eingestellt ist. Demzufolge muß der Port dort auch geändert werden. Der Port für die Bridge kann ohne Probleme im Bridge Device mittels dem Attribut "port" verändert werden.
-
- Der Port für die Bridge kann ohne Probleme im Bridge Device mittels dem Attribut "port" verändert werden.
-
- AMAD Communication Bridge
-
- Beim ersten anlegen einer AMAD Deviceinstanz wird automatisch ein Gerät Namens AMADCommBridge im Raum AMAD mit angelegt. Dieses Gerät diehnt zur Kommunikation vom Androidgerät zu FHEM ohne das zuvor eine Anfrage von FHEM aus ging. Damit das Androidgerät die IP von FHEM kennt, muss diese sofort nach dem anlegen der Bridge über den set Befehl in ein entsprechendes Reading in die Bridge geschrieben werden. DAS IST SUPER WICHTIG UND FÜR DIE FUNKTION DER BRIDGE NOTWENDIG.
- Hierfür muß folgender Befehl ausgeführt werden. set AMADCommBridge fhemServerIP <FHEM-IP>.
- Als zweites Reading kann expertMode gesetzen werden. Mit diesem Reading wird eine unmittelbare Komminikation mit FHEM erreicht ohne die Einschränkung über ein
- Notify gehen zu müssen und nur reine set Befehle ausführen zu können.
-
- NUN bitte die Flows AKTIVIEREN!!!
-
- Fertig! Nach anlegen der Geräteinstanz und dem eintragen der fhemServerIP in der CommBridge sollten nach spätestens 15 Sekunden bereits die ersten Readings reinkommen. Nun wird alle 15 Sekunden probiert einen Status Request erfolgreich ab zu schließen. Wenn der Status sich über einen längeren Zeitraum nicht auf "active" ändert, sollte man im Log nach eventuellen Fehlern suchen.
-
-
- Readings
-
- - airplanemode - Status des Flugmodus
- - androidVersion - aktuell installierte Androidversion
- - automagicState - Statusmeldungen von der AutomagicApp (Voraussetzung Android >4.3). Ist Android größer 4.3 vorhanden und im Reading steht "wird nicht unterstützt", muß in den Androideinstellungen unter Ton und Benachrichtigungen -> Benachrichtigungszugriff ein Haken für Automagic gesetzt werden
- - batteryHealth - Zustand der Battery (1=unbekannt, 2=gut, 3=Überhitzt, 4=tot, 5=Überspannung, 6=unbekannter Fehler, 7=kalt)
- - batterytemperature - Temperatur der Batterie
- - bluetooth - on/off, Bluetooth Status an oder aus
- - checkActiveTask - Zustand einer zuvor definierten APP. 0=nicht aktiv oder nicht aktiv im Vordergrund, 1=aktiv im Vordergrund, siehe Hinweis unten
- - connectedBTdevices - eine Liste der verbundenen Gerät
- - connectedBTdevicesMAC - eine Liste der MAC Adressen aller verbundender BT Geräte
- - currentMusicAlbum - aktuell abgespieltes Musikalbum des verwendeten Mediaplayers
- - currentMusicApp - aktuell verwendeter Mediaplayer (Amazon Music, Google Play Music, Google Play Video, Spotify, YouTube, TuneIn Player, Aldi Life Music)
- - currentMusicArtist - aktuell abgespielter Musikinterpret des verwendeten Mediaplayers
- - currentMusicIcon - Cover vom aktuell abgespielten Album Noch nicht fertig implementiert
- - currentMusicState - Status des aktuellen/zuletzt verwendeten Mediaplayers
- - currentMusicTrack - aktuell abgespielter Musiktitel des verwendeten Mediaplayers
- - daydream - on/off, Daydream gestartet oder nicht
- - deviceState - Status des Androidgerätes. unknown, online, offline.
- - doNotDisturb - aktueller Status des nicht stören Modus
- - dockingState - undocked/docked Status ob sich das Gerät in einer Dockinstation befindet.
- - flow_SetCommands - active/inactive, Status des SetCommands Flow
- - flow_informations - active/inactive, Status des Informations Flow
- - flowsetVersionAtDevice - aktuell installierte Flowsetversion auf dem Device
- - incomingCallerName - Anrufername des eingehenden Anrufes
- - incomingCallerNumber - Anrufernummer des eingehenden Anrufes
- - incommingWhatsAppMessageFrom - letzte WhatsApp Nachricht
- - incommingWhatsTelegramMessageFrom - letzte Telegram Nachricht
- - intentRadioName - zuletzt gesrreamter Intent Radio Name
- - intentRadioState - Status des IntentRadio Players
- - keyguardSet - 0/1 Displaysperre gesetzt 0=nein 1=ja, bedeutet nicht das sie gerade aktiv ist
- - lastSetCommandError - letzte Fehlermeldung vom set Befehl
- - lastSetCommandState - letzter Status vom set Befehl, Befehl erfolgreich/nicht erfolgreich gesendet
- - lastStatusRequestError - letzte Fehlermeldung vom statusRequest Befehl
- - lastStatusRequestState - letzter Status vom statusRequest Befehl, Befehl erfolgreich/nicht erfolgreich gesendet
- - nextAlarmDay - aktiver Alarmtag
- - nextAlarmState - aktueller Status des "Androidinternen" Weckers
- - nextAlarmTime - aktive Alarmzeit
- - powerLevel - Status der Batterie in %
- - powerPlugged - Netzteil angeschlossen? 0=NEIN, 1|2=JA
- - screen - on locked/unlocked, off locked/unlocked gibt an ob der Bildschirm an oder aus ist und gleichzeitig gesperrt oder nicht gesperrt
- - screenBrightness - Bildschirmhelligkeit von 0-255
- - screenFullscreen - on/off, Vollbildmodus (An,Aus)
- - screenOrientation - Landscape,Portrait, Bildschirmausrichtung (Horizontal,Vertikal)
- - screenOrientationMode - auto/manual, Modus für die Ausrichtung (Automatisch, Manuell)
- - state - aktueller Status
- - userFlowState - aktueller Status eines Flows, festgelegt unter dem setUserFlowState Attribut
- - volume - Media Lautstärkewert
- - volumeNotification - Benachrichtigungs Lautstärke
-
- Beim Reading checkActivTask muß zuvor der Packagename der zu prüfenden App als Attribut checkActiveTask angegeben werden. Beispiel: attr Nexus10Wohnzimmer
- checkActiveTask com.android.chrome für den Chrome Browser.
-
-
-
-
- Set
-
- - activateVoiceInput - aktiviert die Spracheingabe
- - bluetooth - on/off, aktiviert/deaktiviert Bluetooth
- - clearNotificationBar - All,Automagic, löscht alle Meldungen oder nur die Automagic Meldungen in der Statusleiste
- - closeCall - beendet einen laufenden Anruf
- - currentFlowsetUpdate - fürt ein Flowsetupdate auf dem Device durch
- - doNotDisturb - schaltet den nicht stören Modus, always immer stören, never niemals stören, alarmClockOnly nur Wecker darf stören, onlyImportant nur wichtige Störungen
- - installFlowSource - installiert einen Flow auf dem Device, das XML File muss unter /tmp/ liegen und die Endung xml haben. Bsp: set TabletWohnzimmer installFlowSource WlanUebwerwachen.xml
- - mediaAmazonMusic - play, stop, next, back ,steuert den Amazon Musik Mediaplayer
- - mediaGoogleMusic - play, stop, next, back ,steuert den Google Play Musik Mediaplayer
- - mediaSpotifyMusic - play, stop, next, back ,steuert den Spotify Mediaplayer
- - mediaTuneinRadio - play, stop, next, back ,steuert den TuneIn Radio Mediaplayer
- - mediaAldiMusic - play, stop, next, back ,steuert den Aldi Musik Mediaplayer
- - mediaAudible - play, stop, next, back ,steuert den Audible Mediaplayer
- - mediaYouTube - play, stop, next, back ,steuert den YouTube Mediaplayer
- - mediaVlcPlayer - play, stop, next, back ,steuert den VLC Mediaplayer
- - nextAlarmTime - setzt die Alarmzeit. gilt aber nur innerhalb der nächsten 24Std.
- - openCall - ruft eine Nummer an und legt optional nach X Sekunden auf / set DEVICE openCall 01736458 10 / ruft die Nummer an und beendet den Anruf nach 10s
- - screenBrightness - setzt die Bildschirmhelligkeit, von 0-255.
- - screenMsg - versendet eine Bildschirmnachricht
- - sendintent - sendet einen Intentstring Bsp: set $AMADDEVICE sendIntent org.smblott.intentradio.PLAY url http://stream.klassikradio.de/live/mp3-192/stream.klassikradio.de/play.m3u name Klassikradio, der erste Befehl ist die Aktion und der zweite das Extra. Es können immer zwei Extras mitgegeben werden.
- - sendSMS - sendet eine SMS an eine bestimmte Telefonnummer. Bsp.: sendSMS Dies ist ein Test|555487263
- - startDaydream - startet den Daydream
- - statusRequest - Fordert einen neuen Statusreport beim Device an. Es können nicht von allen Readings per statusRequest die Daten geholt werden. Einige wenige geben nur bei Statusänderung ihren Status wieder.
- - timer - setzt einen Timer innerhalb der als Standard definierten ClockAPP auf dem Device. Es können nur Sekunden angegeben werden.
- - ttsMsg - versendet eine Nachricht welche als Sprachnachricht ausgegeben wird
- - userFlowState - aktiviert oder deaktiviert einen oder mehrere Flows,set Nexus7Wohnzimmer Badezimmer vorheizen:inactive oder set Nexus7Wohnzimmer Badezimmer vorheizen,Nachtlicht Steven:inactive
- - vibrate - lässt das Androidgerät vibrieren
- - volume - setzt die Medialautstärke. Entweder die internen Lautsprecher oder sofern angeschlossen die Bluetoothlautsprecher und per Klinkenstecker angeschlossene Lautsprecher, + oder - vor dem Wert reduziert die aktuelle Lautstärke um den Wert
- - volumeNotification - setzt die Benachrichtigungslautstärke.
-
-
- Set abhängig von gesetzten Attributen
-
- - changetoBtDevice - wechselt zu einem anderen Bluetooth Gerät. Attribut setBluetoothDevice muß gesetzt sein. Siehe Hinweis unten!
- - notifySndFile - spielt die angegebene Mediadatei auf dem Androidgerät ab. Die aufzurufende Mediadatei sollte sich im Ordner /storage/emulated/0/Notifications/ befinden. Ist dies nicht der Fall kann man über das Attribut setNotifySndFilePath einen Pfad vorgeben.
- - openApp - öffnet eine ausgewählte App. Attribut setOpenApp
- - openURL - öffnet eine URL im Standardbrowser, sofern kein anderer Browser über das Attribut setOpenUrlBrowser ausgewählt wurde. Bsp: attr Tablet setOpenUrlBrowser de.ozerov.fully|de.ozerov.fully.MainActivity, das erste ist der Package Name und das zweite der Class Name
- - setAPSSID - setzt die AccessPoint SSID um ein WLAN sleep zu verhindern
- - screen - on/off/lock/unlock schaltet den Bildschirm ein/aus oder sperrt/entsperrt ihn, in den Automagic Einstellungen muss "Admin Funktion" gesetzt werden sonst funktioniert "Screen off" nicht. Attribut setScreenOnForTimer ändert die Zeit wie lange das Display an bleiben soll!
- - screenFullscreen - on/off, (aktiviert/deaktiviert) den Vollbildmodus. Attribut setFullscreen
- - screenLock - Sperrt den Bildschirm mit Pinabfrage. Attribut setScreenlockPIN - hier die Pin dafür eingeben. Erlaubt sind nur Zahlen. Es müßen mindestens 4, bis max 16 Zeichen verwendet werden.
- - screenOrientation - Auto,Landscape,Portait, aktiviert die Bildschirmausrichtung (Automatisch,Horizontal,Vertikal). Attribut setScreenOrientation
- - system - setzt Systembefehle ab (nur bei gerootetet Geräen). reboot,shutdown,airplanemodeON (kann nur aktiviert werden) Attribut root, in den Automagic Einstellungen muss "Root Funktion" gesetzt werden
- - setNotifySndFilePath - setzt den korrekten Systempfad zur Notifydatei (default ist /storage/emulated/0/Notifications/
- - setTtsMsgSpeed - setzt die Sprachgeschwindigkeit bei der Sprachausgabe(Werte zwischen 0.5 bis 4.0 in 0.5er Schritten) default ist 1.0
- - setTtsMsgSpeed - setzt die Sprache bei der Sprachausgabe, de oder en (default ist de)
-
- Um openApp verwenden zu können, muss als Attribut der Package Name der App angegeben werden.
-
- Um zwischen Bluetoothgeräten wechseln zu können, muß das Attribut setBluetoothDevice mit folgender Syntax gesetzt werden. attr <DEVICE> BTdeviceName1|MAC,BTDeviceName2|MAC Es muss
- zwingend darauf geachtet werden das beim BTdeviceName kein Leerzeichen vorhanden ist. Am besten zusammen oder mit Unterstrich. Achtet bei der MAC darauf das Ihr wirklich nach jeder zweiten Zahl auch
- einen : drin habt
- Beispiel: attr Nexus10Wohnzimmer setBluetoothDevice Logitech_BT_Adapter|AB:12:CD:34:EF:32,Anker_A3565|GH:56:IJ:78:KL:76
-
-
-
- state
-
- - initialized - Ist der Status kurz nach einem define.
- - active - die Geräteinstanz ist im aktiven Status.
- - disabled - die Geräteinstanz wurde über das Attribut disable deaktiviert
-
-
- Anwendungsbeispiele:
-
-
-
-
-=end html_DE
-=cut
diff --git a/74_AMADDevice.pm b/74_AMADDevice.pm
new file mode 100644
index 0000000..6410b46
--- /dev/null
+++ b/74_AMADDevice.pm
@@ -0,0 +1,1220 @@
+###############################################################################
+#
+# Developed with Kate
+#
+# (c) 2015-2017 Copyright: Marko Oldenburg (leongaultier at gmail dot com)
+# All rights reserved
+#
+# This script is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# any later version.
+#
+# The GNU General Public License can be found at
+# http://www.gnu.org/copyleft/gpl.html.
+# A copy is found in the textfile GPL.txt and important notices to the license
+# from the author is found in LICENSE.txt distributed with these scripts.
+#
+# This script is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+#
+# $Id$
+#
+###############################################################################
+##
+##
+## Das JSON Modul immer in einem eval aufrufen
+# $data = eval{decode_json($data)};
+#
+# if($@){
+# Log3($SELF, 2, "$TYPE ($SELF) - error while request: $@");
+#
+# readingsSingleUpdate($hash, "state", "error", 1);
+#
+# return;
+# }
+#
+#
+
+
+
+
+package main;
+
+
+my $missingModul = "";
+
+use strict;
+use warnings;
+
+eval "use Encode qw(encode encode_utf8);1" or $missingModul .= "Encode ";
+eval "use JSON;1" or $missingModul .= "JSON ";
+
+
+my $modulversion = "4.0.0";
+my $flowsetversion = "4.0.0";
+
+
+
+
+# Declare functions
+sub AMADDevice_Attr(@);
+sub AMADDevice_checkDeviceState($);
+sub AMADDevice_decrypt($);
+sub AMADDevice_Define($$);
+sub AMADDevice_encrypt($);
+sub AMADDevice_GetUpdate($);
+sub AMADDevice_Initialize($);
+sub AMADDevice_WriteReadings($$);
+sub AMADDevice_Set($$@);
+sub AMADDevice_Undef($$);
+sub AMADDevice_Parse($$);
+sub AMADDevice_statusRequest($);
+
+
+
+
+sub AMADDevice_Initialize($) {
+
+ my ($hash) = @_;
+
+ $hash->{Match} = '{"amad": \{"amad_id":.+}}';
+
+
+ $hash->{SetFn} = "AMADDevice_Set";
+ $hash->{DefFn} = "AMADDevice_Define";
+ $hash->{UndefFn} = "AMADDevice_Undef";
+ $hash->{AttrFn} = "AMADDevice_Attr";
+ $hash->{ParseFn} = "AMADDevice_Parse";
+
+ $hash->{AttrList} = "setOpenApp ".
+ "checkActiveTask ".
+ "setFullscreen:0,1 ".
+ "setScreenOrientation:0,1 ".
+ "setScreenBrightness:noArg ".
+ "setBluetoothDevice ".
+ "setScreenlockPIN ".
+ "setScreenOnForTimer ".
+ "setOpenUrlBrowser ".
+ "setNotifySndFilePath ".
+ "setTtsMsgSpeed ".
+ "setUserFlowState ".
+ "setTtsMsgLang:de,en ".
+ "setVolUpDownStep:1,2,4,5 ".
+ "setVolMax ".
+ "setVolFactor:2,3,4,5 ".
+ "setNotifyVolMax ".
+ "setRingSoundVolMax ".
+ "setAPSSID ".
+ "root:0,1 ".
+ "disable:1 ".
+ $readingFnAttributes;
+
+ foreach my $d(sort keys %{$modules{AMADDevice}{defptr}}) {
+
+ my $hash = $modules{AMADDevice}{defptr}{$d};
+ $hash->{VERSIONMODUL} = $modulversion;
+ $hash->{VERSIONFLOWSET} = $flowsetversion;
+ }
+}
+
+sub AMADDevice_Define($$) {
+
+ my ( $hash, $def ) = @_;
+ my @a = split( "[ \t]+", $def );
+ splice( @a, 1, 1 );
+ my $iodev;
+ my $i = 0;
+
+
+ foreach my $param ( @a ) {
+ if( $param =~ m/IODev=([^\s]*)/ ) {
+
+ $iodev = $1;
+ splice( @a, $i, 3 );
+ last;
+ }
+
+ $i++;
+ }
+
+ return "too few parameters: define AMADDevice " if( @a != 3 );
+ return "Cannot define a AMAD device. Perl modul $missingModul is missing." if ( $missingModul );
+
+
+ my ($name,$host,$amad_id) = @a;
+
+ $hash->{HOST} = $host;
+ $hash->{AMAD_ID} = $amad_id;
+ $hash->{PORT} = 8090;
+ $hash->{VERSIONMODUL} = $modulversion;
+ $hash->{VERSIONFLOWSET} = $flowsetversion;
+ $hash->{helper}{infoErrorCounter} = 0;
+ $hash->{helper}{setCmdErrorCounter} = 0;
+ $hash->{helper}{deviceStateErrorCounter} = 0;
+
+
+
+
+ AssignIoPort($hash,$iodev) if( !$hash->{IODev} );
+
+ if(defined($hash->{IODev}->{NAME})) {
+
+ Log3 $name, 3, "AMADDevice ($name) - I/O device is " . $hash->{IODev}->{NAME};
+
+ } else {
+
+ Log3 $name, 1, "AMADDevice ($name) - no I/O device";
+ }
+
+
+ $iodev = $hash->{IODev}->{NAME};
+
+ my $d = $modules{AMADDevice}{defptr}{$amad_id};
+
+ return "AMADDevice device $name on AMADCommBridge $iodev already defined."
+ if( defined($d) && $d->{IODev} == $hash->{IODev} && $d->{NAME} ne $name );
+
+ Log3 $name, 3, "AMADDevice ($name) - defined with AMAD_ID: $amad_id on port $hash->{PORT}";
+
+ $attr{$name}{room} = "AMAD" if( !defined( $attr{$name}{room} ) );
+
+ readingsBeginUpdate($hash);
+ readingsBulkUpdateIfChanged( $hash, "state", "initialized",1);
+ readingsBulkUpdateIfChanged( $hash, "deviceState", "unknown",1);
+ readingsEndUpdate($hash,1);
+
+
+ if( $init_done ) {
+
+ InternalTimer( gettimeofday()+3, "AMADDevice_GetUpdate", $hash, 0 ) if( ($hash->{HOST}) );
+
+ } else {
+
+ InternalTimer( gettimeofday()+15, "AMADDevice_GetUpdate", $hash, 0 ) if( ($hash->{HOST}) );
+ }
+
+ $modules{AMADDevice}{defptr}{$amad_id} = $hash;
+
+ return undef;
+}
+
+sub AMADDevice_Undef($$) {
+
+ my ( $hash, $arg ) = @_;
+ my $name = $hash->{NAME};
+ my $amad_id = $hash->{AMAD_ID};
+
+
+ RemoveInternalTimer( $hash );
+ delete $modules{AMADDevice}{defptr}{$amad_id};
+
+ return undef;
+}
+
+sub AMADDevice_Attr(@) {
+
+ my ( $cmd, $name, $attrName, $attrVal ) = @_;
+ my $hash = $defs{$name};
+
+ my $orig = $attrVal;
+
+ if( $attrName eq "disable" ) {
+ if( $cmd eq "set" ) {
+ if( $attrVal eq "0" ) {
+
+ RemoveInternalTimer( $hash );
+ InternalTimer( gettimeofday()+2, "AMADDevice_GetUpdate", $hash, 0 ) if( ReadingsVal( $hash->{NAME}, "state", 0 ) eq "disabled" );
+ readingsSingleUpdate ( $hash, "state", "active", 1 );
+ Log3 $name, 3, "AMADDevice ($name) - enabled";
+ } else {
+
+ readingsSingleUpdate ( $hash, "state", "disabled", 1 );
+ RemoveInternalTimer( $hash );
+ Log3 $name, 3, "AMADDevice ($name) - disabled";
+ }
+
+ } else {
+
+ RemoveInternalTimer( $hash );
+ InternalTimer( gettimeofday()+2, "AMADDevice_GetUpdate", $hash, 0 ) if( ReadingsVal( $hash->{NAME}, "state", 0 ) eq "disabled" );
+ readingsSingleUpdate ( $hash, "state", "active", 1 );
+ Log3 $name, 3, "AMADDevice ($name) - enabled";
+ }
+ }
+
+ elsif( $attrName eq "checkActiveTask" ) {
+ if( $cmd eq "del" ) {
+ CommandDeleteReading( undef, "$name checkActiveTask" );
+ }
+
+ Log3 $name, 3, "AMADDevice ($name) - $cmd $attrName $attrVal and run statusRequest";
+ RemoveInternalTimer( $hash );
+ InternalTimer( gettimeofday(), "AMADDevice_GetUpdate", $hash, 0 )
+ }
+
+ elsif( $attrName eq "setScreenlockPIN" ) {
+ if( $cmd eq "set" && $attrVal ) {
+
+ $attrVal = AMADDevice_encrypt($attrVal);
+
+ } else {
+
+ CommandDeleteReading( undef, "$name screenLock" );
+ }
+ }
+
+ elsif( $attrName eq "setAPSSID" ) {
+ if( $cmd eq "set" && $attrVal ) {
+
+ AMADDevice_statusRequest($hash);
+
+ } else {
+
+ AMADDevice_statusRequest($hash);
+ }
+ }
+
+ elsif( $attrName eq "setUserFlowState" ) {
+ if( $cmd eq "del" ) {
+
+ CommandDeleteReading( undef, "$name userFlowState" );
+ }
+
+ Log3 $name, 3, "AMADDevice ($name) - $cmd $attrName $attrVal and run statusRequest";
+ RemoveInternalTimer( $hash );
+ InternalTimer( gettimeofday(), "AMADDevice_GetUpdate", $hash, 0 )
+ }
+
+
+
+ if( $cmd eq "set" ) {
+ if( $attrVal && $orig ne $attrVal ) {
+
+ $attr{$name}{$attrName} = $attrVal;
+ return $attrName ." set to ". $attrVal if( $init_done );
+ }
+ }
+
+ return undef;
+}
+
+sub AMADDevice_GetUpdate($) {
+
+ my ( $hash ) = @_;
+ my $name = $hash->{NAME};
+ my $bname = $hash->{IODev}->{NAME};
+
+
+ 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" ) {
+
+ AMADDevice_statusRequest($hash);
+ AMADDevice_checkDeviceState( $hash );
+
+ } else {
+
+ Log3 $name, 4, "AMADDevice ($name) - GetUpdate, FHEM or Device not ready yet";
+ Log3 $name, 3, "AMADDevice ($bname) - GetUpdate, Please set $bname fhemServerIP NOW!" if( ReadingsVal( $bname, "fhemServerIP", "none" ) eq "none" );
+
+ InternalTimer( gettimeofday()+15, "AMADDevice_GetUpdate", $hash, 0 );
+ }
+}
+
+sub AMADDevice_statusRequest($) {
+
+ my $hash = shift;
+ my $name = $hash->{NAME};
+
+ my $host = $hash->{HOST};
+ my $port = $hash->{PORT};
+ my $amad_id = $hash->{AMAD_ID};
+ my $uri;
+ my $header = 'Connection: close';
+ my $method;
+
+
+ my $activetask = AttrVal( $name, "checkActiveTask", "none" );
+ 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\r\nfhemctlmode: $fhemCtlMode";
+ $method = "GET";
+
+
+ IOWrite($hash,$amad_id,$uri,$header,$method);
+ Log3 $name, 5, "AMADDevice ($name) - IOWrite: $uri $method IODevHash=$hash->{IODev}";
+}
+
+sub AMADDevice_WriteReadings($$) {
+
+ my ( $hash, $decode_json ) = @_;
+
+ my $name = $hash->{NAME};
+
+
+ ############################
+ #### schreiben der Readings
+
+ Log3 $name, 5, "AMADDevice ($name) - Processing data: $decode_json";
+ readingsSingleUpdate( $hash, "state", "active", 1) if( ReadingsVal( $name, "state", 0 ) ne "initialized" and ReadingsVal( $name, "state", 0 ) ne "active" );
+
+ ### Event Readings
+ my $t;
+ my $v;
+
+
+ readingsBeginUpdate($hash);
+
+ while( ( $t, $v ) = each %{$decode_json->{payload}} ) {
+
+ $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 ) and ($t ne 'deviceState'
+ or $t ne 'incomingCallerName'
+ or $t ne 'incomingCallerNumber')
+ );
+
+ readingsBulkUpdateIfChanged( $hash, $t, ($v / AttrVal($name,'setVolFactor',1)) ) if( $t eq 'volume' and AttrVal($name,'setVolFactor',1) > 1 );
+ readingsBulkUpdate( $hash, '.'.$t, $v ) if( $t eq 'deviceState' );
+ readingsBulkUpdate( $hash, $t, $v ) if( $t eq 'incomingCallerName' );
+ readingsBulkUpdate( $hash, $t, $v ) if( $t eq 'incomingCallerNumber' );
+ }
+
+ readingsBulkUpdateIfChanged( $hash, "deviceState", "offline", 1 ) if( $decode_json->{payload}{airplanemode} && $decode_json->{payload}{airplanemode} eq "on" );
+ readingsBulkUpdateIfChanged( $hash, "deviceState", "online", 1 ) if( $decode_json->{payload}{airplanemode} && $decode_json->{payload}{airplanemode} eq "off" );
+
+ readingsBulkUpdateIfChanged( $hash, "lastStatusRequestState", "statusRequest_done", 1 );
+
+ if( ReadingsVal($name,'volume',1) > 0 ) {
+ readingsBulkUpdateIfChanged( $hash, "mute", "off", 1 );
+ } else {
+ readingsBulkUpdateIfChanged( $hash, "mute", "on", 1 );
+ }
+
+ $hash->{helper}{infoErrorCounter} = 0;
+ ### End Response Processing
+
+ readingsBulkUpdateIfChanged( $hash, "state", "active", 1 ) if( ReadingsVal( $name, "state", 0 ) eq "initialized" );
+ readingsEndUpdate( $hash, 1 );
+
+ $hash->{helper}{deviceStateErrorCounter} = 0 if( $hash->{helper}{deviceStateErrorCounter} > 0 and ReadingsVal( $name, "deviceState", "offline") eq "online" );
+
+ return undef;
+}
+
+sub AMADDevice_Set($$@) {
+
+ my ($hash, $name, @aa) = @_;
+ my ($cmd, @args) = @aa;
+
+ my $host = $hash->{HOST};
+ my $port = $hash->{PORT};
+ my $amad_id = $hash->{AMAD_ID};
+ my $uri;
+ my $header = 'Connection: close';
+ my $method;
+
+ my $volMax = AttrVal($name,'setVolMax',15);
+ my $notifyVolMax = AttrVal($name,'setNotifyVolMax',7);
+ my $ringSoundVolMax = AttrVal($name,'setRingSoundVolMax',7);
+
+
+ if( lc $cmd eq 'screenmsg' ) {
+ my $msg = join( " ", @args );
+
+ $msg =~ s/%/%25/g;
+ $msg =~ s/\s/%20/g;
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/screenMsg?message=$msg";
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'ttsmsg' ) {
+
+ my $msg = join( " ", @args );
+ my $speed = AttrVal( $name, "setTtsMsgSpeed", "1.0" );
+ my $lang = AttrVal( $name, "setTtsMsgLang","de" );
+
+ $msg =~ s/%/%25/g;
+ $msg =~ s/\s/%20/g;
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/ttsMsg?message=".$msg."&msgspeed=".$speed."&msglang=".$lang;
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'userflowstate' ) {
+
+ my $datas = join( " ", @args );
+ my ($flow,$state) = split( ":", $datas);
+
+ $flow =~ s/\s/%20/g;
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/flowState?flowstate=".$state."&flowname=".$flow;
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'volume' or $cmd eq 'mute' or $cmd =~ 'volume[Down|Up]' ) {
+
+ my $vol;
+
+ if( $cmd eq 'volume' ) {
+ $vol = join( " ", @args );
+
+ if( $vol =~ /^\+(.*)/ or $vol =~ /^-(.*)/ ) {
+
+ if( $vol =~ /^\+(.*)/ ) {
+
+ $vol =~ s/^\+//g;
+ $vol = ReadingsVal( $name, "volume", 0 ) + $vol;
+ }
+
+ elsif( $vol =~ /^-(.*)/ ) {
+
+ $vol =~ s/^-//g;
+ printf $vol;
+ $vol = ReadingsVal( $name, "volume", 15 ) - $vol;
+ }
+ }
+
+ } elsif( $cmd eq 'mute') {
+ if($args[0] eq 'on') {
+ $vol = 0;
+ readingsSingleUpdate($hash,'.volume',ReadingsVal($name,'volume',0),0);
+ } else {
+ $vol = ReadingsVal($name,'.volume',0);
+ }
+
+ } elsif( $cmd =~ 'volume[Down|Up]') {
+ if( $cmd eq 'volumeUp' ) {
+ $vol = ReadingsVal( $name, "volume", 0 ) + AttrVal($name,'setVolUpDownStep',3);
+ } else {
+ $vol = ReadingsVal( $name, "volume", 0 ) - AttrVal($name,'setVolUpDownStep',3);
+ }
+ }
+
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/setVolume?volume=$vol";
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'volumenotification' ) {
+
+ my $vol = join( " ", @args );
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/setNotifiVolume?notifivolume=$vol";
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'volumeringsound' ) {
+
+ my $vol = join( " ", @args );
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/setRingSoundVolume?ringsoundvolume=$vol";
+ $method = "POST";
+ }
+
+ elsif( lc $cmd =~ /^media/ ) {
+
+ my $btn = join( " ", @args );
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/multimediaControl?mplayer=".$cmd."&button=".$btn;
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'screenbrightness' ) {
+
+ my $bri = join( " ", @args );
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/setBrightness?brightness=$bri";
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'screen' ) {
+
+ my $mod = join( " ", @args );
+ my $scot = AttrVal( $name, "setScreenOnForTimer", undef );
+ $scot = 60 if( !$scot );
+
+ if ($mod eq "on" || $mod eq "off") {
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/setScreenOnOff?screen=".$mod."&screenontime=".$scot if ($mod eq "on" || $mod eq "off");
+ $method = "POST";
+ }
+
+ elsif ($mod eq "lock" || $mod eq "unlock") {
+
+ return "Please set \"setScreenlockPIN\" Attribut first" if( AttrVal( $name, "setScreenlockPIN", "none" ) eq "none" );
+ my $PIN = AttrVal( $name, "setScreenlockPIN", undef );
+ $PIN = AMADDevice_decrypt($PIN);
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/screenlock?lockmod=".$mod."&lockPIN=".$PIN;
+ $method = "POST";
+ }
+ }
+
+ elsif( lc $cmd eq 'screenorientation' ) {
+
+ my $mod = join( " ", @args );
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/setScreenOrientation?orientation=$mod";
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'activatevoiceinput' ) {
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/setvoicecmd";
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'screenfullscreen' ) {
+
+ my $mod = join( " ", @args );
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/setScreenFullscreen?fullscreen=$mod";
+ $method = "POST";
+ readingsSingleUpdate( $hash, $cmd, $mod, 1 );
+ }
+
+ elsif( lc $cmd eq 'openurl' ) {
+
+ my $openurl = join( " ", @args );
+ my $browser = AttrVal( $name, "setOpenUrlBrowser", "com.android.chrome|com.google.android.apps.chrome.Main" );
+ my @browserapp = split( /\|/, $browser );
+
+ my $uri = $host . ":" . $port . "/fhem-amad/setCommands/openURL?url=".$openurl."&browserapp=".$browserapp[0]."&browserappclass=".$browserapp[1];
+ $method = "POST";
+ }
+
+ elsif (lc $cmd eq 'nextalarmtime') {
+
+ my $value = join( " ", @args );
+ my @alarm = split( ":", $value );
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/setAlarm?hour=".$alarm[0]."&minute=".$alarm[1];
+ $method = "POST";
+ }
+
+ elsif (lc $cmd eq 'timer') {
+
+ my $timer = join( " ", @args );
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/setTimer?minute=$timer";
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'statusrequest' ) {
+
+ AMADDevice_statusRequest($hash);
+ return;
+ }
+
+ elsif( lc $cmd eq 'openapp' ) {
+
+ my $app = join( " ", @args );
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/openApp?app=$app";
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'system' ) {
+
+ my $systemcmd = join( " ", @args );
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/systemcommand?syscmd=$systemcmd";
+ $method = "POST";
+ readingsSingleUpdate( $hash, "airplanemode", "on", 1 ) if( $systemcmd eq "airplanemodeON" );
+ readingsSingleUpdate( $hash, "deviceState", "offline", 1 ) if( $systemcmd eq "airplanemodeON" || $systemcmd eq "shutdown" );
+ }
+
+ elsif( lc $cmd eq 'donotdisturb' ) {
+
+ my $disturbmod = join( " ", @args );
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/donotdisturb?disturbmod=$disturbmod";
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'bluetooth' ) {
+
+ my $mod = join( " ", @args );
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/setbluetooth?bluetooth=$mod";
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'notifysndfile' ) {
+
+ my $notify = join( " ", @args );
+ my $filepath = AttrVal( $name, "setNotifySndFilePath", "/storage/emulated/0/Notifications/" );
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/playnotifysnd?notifyfile=".$notify."¬ifypath=".$filepath;
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'changetobtdevice' ) {
+
+ my $swToBtDevice = join( " ", @args );
+ my @swToBtMac = split( /\|/, $swToBtDevice );
+ my $btDevices = AttrVal( $name, "setBluetoothDevice", "none" ) if( AttrVal( $name, "setBluetoothDevice", "none" ) ne "none" );
+ my @btDevice = split( ',', $btDevices );
+ my @btDeviceOne = split( /\|/, $btDevice[0] );
+ my @btDeviceTwo = split( /\|/, $btDevice[1] );
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/setbtdevice?swToBtDeviceMac=".$swToBtMac[1]."&btDeviceOne=".$btDeviceOne[1]."&btDeviceTwo=".$btDeviceTwo[1];
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'clearnotificationbar' ) {
+
+ my $appname = join( " ", @args );
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/clearnotificationbar?app=$appname";
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'vibrate' ) {
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/setvibrate";
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'sendintent' ) {
+
+ my $intentstring = join( " ", @args );
+ my ( $action, $exkey1, $exval1, $exkey2, $exval2 ) = split( "[ \t][ \t]*", $intentstring );
+ $exkey1 = "" if( !$exkey1 );
+ $exval1 = "" if( !$exval1 );
+ $exkey2 = "" if( !$exkey2 );
+ $exval2 = "" if( !$exval2 );
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/sendIntent?action=".$action."&exkey1=".$exkey1."&exval1=".$exval1."&exkey2=".$exkey2."&exval2=".$exval2;
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'installflowsource' ) {
+
+ my $flowname = join( " ", @args );
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/installFlow?flowname=$flowname";
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'opencall' ) {
+
+ my $string = join( " ", @args );
+ my ($callnumber, $time) = split( "[ \t][ \t]*", $string );
+ $time = "none" if( !$time );
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/openCall?callnumber=".$callnumber."&hanguptime=".$time;
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'closecall' ) {
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/closeCall";
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'startdaydream' ) {
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/startDaydream";
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'currentflowsetupdate' ) {
+
+ $uri = $host . ":" . $port . "/fhem-amad/currentFlowsetUpdate";
+ $method = "POST";
+ }
+
+ elsif( lc $cmd eq 'sendsms' ) {
+ my $string = join( " ", @args );
+ my ($smsmessage, $smsnumber) = split( "\\|", $string );
+
+ $smsmessage =~ s/%/%25/g;
+ $smsmessage =~ s/\s/%20/g;
+
+ $uri = $host . ":" . $port . "/fhem-amad/setCommands/sendSms?smsmessage=".$smsmessage."&smsnumber=".$smsnumber;
+ $method = "POST";
+
+ } else {
+
+ my $apps = AttrVal( $name, "setOpenApp", "none" );
+ my $btdev = AttrVal( $name, "setBluetoothDevice", "none" );
+
+
+ my $list = "screenMsg ttsMsg mediaGoogleMusic:play/pause,stop,next,back mediaSamsungMusic:play/pause,stop,next,back mediaAmazonMusic:play/pause,stop,next,back mediaSpotifyMusic:play/pause,stop,next,back mediaTuneinRadio:play/pause,stop,next,back mediaAldiMusic:play/pause,stop,next,back mediaYouTube:play/pause,stop,next,back mediaVlcPlayer:play/pause,stop,next,back mediaAudible:play/pause,stop,next,back screenBrightness:slider,0,1,255 screen:on,off,lock,unlock openURL nextAlarmTime:time timer:slider,1,1,60 statusRequest:noArg bluetooth:on,off notifySndFile clearNotificationBar:All,Automagic activateVoiceInput:noArg vibrate:noArg sendIntent openCall closeCall:noArg currentFlowsetUpdate:noArg installFlowSource doNotDisturb:never,always,alarmClockOnly,onlyImportant userFlowState sendSMS startDaydream:noArg volumeUp:noArg volumeDown:noArg mute:on,off";
+
+ $list .= " screenOrientation:auto,landscape,portrait" if( AttrVal( $name, "setScreenOrientation", "0" ) eq "1" );
+ $list .= " screenFullscreen:on,off" if( AttrVal( $name, "setFullscreen", "0" ) eq "1" );
+ $list .= " openApp:$apps" if( AttrVal( $name, "setOpenApp", "none" ) ne "none" );
+ $list .= " system:reboot,shutdown,airplanemodeON" if( AttrVal( $name, "root", "0" ) eq "1" );
+ $list .= " changetoBTDevice:$btdev" if( AttrVal( $name, "setBluetoothDevice", "none" ) ne "none" );
+ $list .= " volume:slider,0,1,$volMax";
+ $list .= " volumeNotification:slider,0,1,$notifyVolMax";
+ $list .= " volumeRingSound:slider,0,1,$ringSoundVolMax";
+
+
+
+ return "Unknown argument $cmd, choose one of $list";
+ }
+
+
+ IOWrite($hash,$amad_id,$uri,$header,$method);
+ Log3 $name, 5, "AMADDevice ($name) - IOWrite: $uri $method IODevHash=$hash->{IODev}";
+
+ return undef;
+}
+
+sub AMADDevice_Parse($$) {
+
+ my ($io_hash,$json) = @_;
+ my $name = $io_hash->{NAME};
+
+
+ my $decode_json = eval{decode_json(encode_utf8($json))};
+ if($@){
+ Log3 $name, 3, "AMADDevice ($name) - JSON error while request: $@";
+ return;
+ }
+
+ Log3 $name, 4, "AMADDevice ($name) - ParseFn was called";
+ Log3 $name, 5, "AMADDevice ($name) - ParseFn was called, !!! AMAD_ID: $decode_json->{amad}{amad_id}";
+
+
+ my $fhemDevice = $decode_json->{firstrun}{fhemdevice} if( defined($decode_json->{firstrun}) and defined($decode_json->{firstrun}{fhemdevice}) );
+ my $amad_id = $decode_json->{amad}{amad_id};
+
+ if( my $hash = $modules{AMADDevice}{defptr}{$amad_id} ) {
+ my $name = $hash->{NAME};
+
+ AMADDevice_WriteReadings($hash,$decode_json);
+ Log3 $name, 4, "AMADDevice ($name) - find logical device: $hash->{NAME}";
+
+ return $hash->{NAME};
+
+ } else {
+
+ return "UNDEFINED $fhemDevice AMADDevice $decode_json->{firstrun}{'amaddevice_ip'} $decode_json->{amad}{'amad_id'} IODev=$name";
+ }
+}
+
+##################################
+##################################
+#### my little helpers ###########
+
+sub AMADDevice_checkDeviceState($) {
+
+ my ( $hash ) = @_;
+ my $name = $hash->{NAME};
+
+ Log3 $name, 4, "AMADDevice ($name) - AMADDevice_checkDeviceState: run Check";
+
+
+ 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 and ReadingsVal($name,'deviceState','online') ne 'offline' );
+ $hash->{helper}{deviceStateErrorCounter} = ( $hash->{helper}{deviceStateErrorCounter} + 1 );
+ }
+
+ InternalTimer( gettimeofday()+240, "AMADDevice_checkDeviceState", $hash, 0 );
+
+ Log3 $name, 4, "AMADDevice ($name) - AMADDevice_checkDeviceState: set new Timer";
+}
+
+sub AMADDevice_encrypt($) {
+
+ my ($decodedPIN) = @_;
+ my $key = getUniqueId();
+ my $encodedPIN;
+
+ return $decodedPIN if( $decodedPIN =~ /^crypt:(.*)/ );
+
+ for my $char (split //, $decodedPIN) {
+ my $encode = chop($key);
+ $encodedPIN .= sprintf("%.2x",ord($char)^ord($encode));
+ $key = $encode.$key;
+ }
+
+ return 'crypt:'. $encodedPIN;
+}
+
+sub AMADDevice_decrypt($) {
+
+ my ($encodedPIN) = @_;
+ my $key = getUniqueId();
+ my $decodedPIN;
+
+ $encodedPIN = $1 if( $encodedPIN =~ /^crypt:(.*)/ );
+
+ for my $char (map { pack('C', hex($_)) } ($encodedPIN =~ /(..)/g)) {
+ my $decode = chop($key);
+ $decodedPIN .= chr(ord($char)^ord($decode));
+ $key = $decode.$key;
+ }
+
+ return $decodedPIN;
+}
+
+
+
+
+1;
+
+=pod
+
+=item device
+=item summary Integrates Android devices into FHEM and displays several settings.
+=item summary_DE Integriert Android-Geräte in FHEM und zeigt verschiedene Einstellungen an.
+
+=begin html
+
+
+AMADDevice
+
+ AMAD - Automagic Android Device
+
+ This module integrates Android devices into FHEM and displays several settings using the Android app "Automagic".
+ Automagic is comparable to the "Tasker" app for automating tasks and configuration settings. But Automagic is more user-friendly. The "Automagic Premium" app currently costs EUR 2.90.
+
+ Any information retrievable by Automagic can be displayed in FHEM by this module. Just define your own Automagic-"flow" and send the data to the AMADCommBridge. One even can control several actions on Android devices.
+
+ To be able to make use of all these functions the Automagic app and additional flows need to be installed on the Android device. The flows can be retrieved from the FHEM directory, the app can be bought in Google Play Store.
+
+ How to use AMADDevice?
+
+ - first, make sure that the AMADCommBridge in FHEM was defined
+ - install the "Automagic Premium" app from the PlayStore
+ - install the flowset 74_AMADDeviceautomagicFlowset$VERSION.xml file from the $INSTALLFHEM/FHEM/lib/ directory on the Android device
+ - activate the "installation assistant" Flow in Automagic. If one now sends Automagic into the background, e.g. Homebutton, the assistant starts and creates automatically a FHEM device for the android device
+
+
+ Define a AMADDevice device by hand.
+
+
+ Define
+
+ 10.6.9.10 1496497380000 IODev=AMADBridge
+ define <name> AMADDevice <IP-ADRESSE> <AMAD_ID> IODev=<IODEVICE>
+
+ Example:
+
+ define WandTabletWohnzimmer AMADDevice 192.168.0.23 123456 IODev=NAME_des_AMADCommBridge_Devices
+
+
+ In this case, an AMADDevice is created by hand. The AMAD_ID, here 123456, must also be entered exactly as a global variable in Automagic.
+
+
+
+ Readings
+
+ - airplanemode - on/off, state of the aeroplane mode
+ - androidVersion - currently installed version of Android
+ - automagicState - state of the Automagic App (prerequisite Android >4.3). In case you have Android >4.3 and the reading says "not supported", you need to enable Automagic inside Android / Settings / Sound & notification / Notification access
+ - batteryHealth - the health of the battery (1=unknown, 2=good, 3=overheat, 4=dead, 5=over voltage, 6=unspecified failure, 7=cold)
+ - batterytemperature - the temperature of the battery
+ - bluetooth - on/off, bluetooth state
+ - checkActiveTask - state of an app (needs to be defined beforehand). 0=not active or not active in foreground, 1=active in foreground, see note below
+ - connectedBTdevices - list of all devices connected via bluetooth
+ - connectedBTdevicesMAC - list of MAC addresses of all devices connected via bluetooth
+ - currentMusicAlbum - currently playing album of mediaplayer
+ - currentMusicApp - currently playing player app (Amazon Music, Google Play Music, Google Play Video, Spotify, YouTube, TuneIn Player, Aldi Life Music)
+ - currentMusicArtist - currently playing artist of mediaplayer
+ - currentMusicIcon - cover of currently play albumNoch nicht fertig implementiert
+ - currentMusicState - state of currently/last used mediaplayer
+ - currentMusicTrack - currently playing song title of mediaplayer
+ - daydream - on/off, daydream currently active
+ - deviceState - state of Android devices. unknown, online, offline.
+ - doNotDisturb - state of do not Disturb Mode
+ - dockingState - undocked/docked, Android device in docking station
+ - flow_SetCommands - active/inactive, state of SetCommands flow
+ - flow_informations - active/inactive, state of Informations flow
+ - flowsetVersionAtDevice - currently installed version of the flowsets on the Android device
+ - incomingCallerName - Callername from last Call
+ - incomingCallerNumber - Callernumber from last Call
+ - incommingWhatsAppMessageFrom - last WhatsApp message
+ - incommingWhatsTelegramMessageFrom - last telegram message
+ - intentRadioName - name of the most-recent streamed intent radio
+ - intentRadioState - state of intent radio player
+ - keyguardSet - 0/1 keyguard set, 0=no 1=yes, does not indicate whether it is currently active
+ - lastSetCommandError - last error message of a set command
+ - lastSetCommandState - last state of a set command, command send successful/command send unsuccessful
+ - lastStatusRequestError - last error message of a statusRequest command
+ - lastStatusRequestState - ast state of a statusRequest command, command send successful/command send unsuccessful
+ - nextAlarmDay - currently set day of alarm
+ - nextAlarmState - alert/done, current state of "Clock" stock-app
+ - nextAlarmTime - currently set time of alarm
+ - powerLevel - state of battery in %
+ - powerPlugged - 0=no/1,2=yes, power supply connected
+ - screen - on locked,unlocked/off locked,unlocked, state of display
+ - screenBrightness - 0-255, level of screen-brightness
+ - screenFullscreen - on/off, full screen mode
+ - screenOrientation - Landscape/Portrait, screen orientation (horizontal,vertical)
+ - screenOrientationMode - auto/manual, mode for screen orientation
+ - state - current state of AMAD device
+ - userFlowState - current state of a Flow, established under setUserFlowState Attribut
+ - volume - media volume setting
+ - volumeNotification - notification volume setting
+
+ Prerequisite for using the reading checkActivTask the package name of the application to be checked needs to be defined in the attribute checkActiveTask. Example: attr Nexus10Wohnzimmer
+ checkActiveTask com.android.chrome für den Chrome Browser.
+
+
+
+
+ Set
+
+ - activateVoiceInput - start voice input on Android device
+ - bluetooth - on/off, switch bluetooth on/off
+ - clearNotificationBar - All/Automagic, deletes all or only Automagic notifications in status bar
+ - closeCall - hang up a running call
+ - currentFlowsetUpdate - start flowset update on Android device
+ - installFlowSource - install a Automagic flow on device, XML file must be stored in /tmp/ with extension xml. Example: set TabletWohnzimmer installFlowSource WlanUebwerwachen.xml
+ - doNotDisturb - sets the do not Disturb Mode, always Disturb, never Disturb, alarmClockOnly alarm Clock only, onlyImportant only important Disturbs
+ - mediaAmazonMusic - play/stop/next/back , controlling the amazon music media player
+ - mediaGoogleMusic - play/stop/next/back , controlling the google play music media player
+ - mediaSpotifyMusic - play/stop/next/back , controlling the spotify media player
+ - mediaTuneinRadio - play/stop/next/back , controlling the TuneinRadio media player
+ - mediaAldiMusic - play/stop/next/back , controlling the Aldi music media player
+ - mediaAudible - play/stop/next/back , controlling the Audible media player
+ - mediaYouTube - play/stop/next/back , controlling the YouTube media player
+ - mediaVlcPlayer - play/stop/next/back , controlling the VLC media player
+ - nextAlarmTime - sets the alarm time. Only valid for the next 24 hours.
+ - notifySndFile - plays a media-file which by default needs to be stored in the folder "/storage/emulated/0/Notifications/" of the Android device. You may use the attribute setNotifySndFilePath for defining a different folder.
+ - openCall - initial a call and hang up after optional time / set DEVICE openCall 0176354 10 call this number and hang up after 10s
+ - screenBrightness - 0-255, set screen brighness
+ - screenMsg - display message on screen of Android device
+ - sendintent - send intent string Example: set $AMADDEVICE sendIntent org.smblott.intentradio.PLAY url http://stream.klassikradio.de/live/mp3-192/stream.klassikradio.de/play.m3u name Klassikradio, first parameter contains the action, second parameter contains the extra. At most two extras can be used.
+ - sendSMS - Sends an SMS to a specific phone number. Bsp.: sendSMS Dies ist ein Test|555487263
+ - startDaydream - start Daydream
+ - statusRequest - Get a new status report of Android device. Not all readings can be updated using a statusRequest as some readings are only updated if the value of the reading changes.
+ - timer - set a countdown timer in the "Clock" stock app. Only seconds are allowed as parameter.
+ - ttsMsg - send a message which will be played as voice message
+ - userFlowState - set Flow/s active or inactive,set Nexus7Wohnzimmer Badezimmer:inactive vorheizen or set Nexus7Wohnzimmer Badezimmer vorheizen,Nachtlicht Steven:inactive
+ - vibrate - vibrate Android device
+ - volume - set media volume. Works on internal speaker or, if connected, bluetooth speaker or speaker connected via stereo jack
+ - volumeNotification - set notifications volume
+
+
+ Set (depending on attribute values)
+
+ - changetoBtDevice - switch to another bluetooth device. Attribute setBluetoothDevice needs to be set. See note below!
+ - openApp - start an app. attribute setOpenApp
+ - openURL - opens a URLS in the standard browser as long as no other browser is set by the attribute setOpenUrlBrowser.Example: attr Tablet setOpenUrlBrowser de.ozerov.fully|de.ozerov.fully.MainActivity, first parameter: package name, second parameter: Class Name
+ - screen - on/off/lock/unlock, switch screen on/off or lock/unlock screen. In Automagic "Preferences" the "Device admin functions" need to be enabled, otherwise "Screen off" does not work. attribute setScreenOnForTimer changes the time the display remains switched on!
+ - screenFullscreen - on/off, activates/deactivates full screen mode. attribute setFullscreen
+ - screenLock - Locks screen with request for PIN. attribute setScreenlockPIN - enter PIN here. Only use numbers, 4-16 numbers required.
+ - screenOrientation - Auto,Landscape,Portait, set screen orientation (automatic, horizontal, vertical). attribute setScreenOrientation
+ - system - issue system command (only with rooted Android devices). reboot,shutdown,airplanemodeON (can only be switched ON) attribute root, in Automagic "Preferences" "Root functions" need to be enabled.
+ - setAPSSID - set WLAN AccesPoint SSID to prevent WLAN sleeps
+ - setNotifySndFilePath - set systempath to notifyfile (default /storage/emulated/0/Notifications/
+ - setTtsMsgSpeed - set speaking speed for TTS (Value between 0.5 - 4.0, 0.5 Step) default is 1.0
+ - setTtsMsgLang - set speaking language for TTS, de or en (default is de)
+
+ To be able to use "openApp" the corresponding attribute "setOpenApp" needs to contain the app package name.
+
+ To be able to switch between bluetooth devices the attribute "setBluetoothDevice" needs to contain (a list of) bluetooth devices defined as follows: attr <DEVICE> BTdeviceName1|MAC,BTDeviceName2|MAC No spaces are allowed in any BTdeviceName. Defining MAC please make sure to use the character : (colon) after each second digit/character.
+ Example: attr Nexus10Wohnzimmer setBluetoothDevice Logitech_BT_Adapter|AB:12:CD:34:EF:32,Anker_A3565|GH:56:IJ:78:KL:76
+
+
+
+ state
+
+ - initialized - shown after initial define.
+ - active - device is active.
+ - disabled - device is disabled by the attribute "disable".
+
+
+ Further examples and reading:
+
+
+
+
+=end html
+=begin html_DE
+
+
+AMADDevice
+
+ AMADDevice - Automagic Android Device
+
+ Dieses Modul liefert, in Verbindung mit der Android APP Automagic, diverse Informationen von Android Geräten.
+ Die AndroidAPP Automagic (welche nicht von mir stammt und 2.90 Euro kostet) funktioniert wie Tasker, ist aber bei weitem User freundlicher.
+
+ Mit etwas Einarbeitung können jegliche Informationen welche Automagic bereit stellt in FHEM angezeigt werden. Hierzu bedarf es lediglich eines eigenen Flows welcher seine Daten an die AMADDeviceCommBridge sendet. Das Modul gibt auch die Möglichkeit Androidgeräte zu steuern.
+
+ Für all diese Aktionen und Informationen wird auf dem Androidgerät "Automagic" und ein so genannter Flow benötigt. Die App ist über den Google PlayStore zu beziehen. Das benötigte Flowset bekommt man aus dem FHEM Verzeichnis.
+
+ Wie genau verwendet man nun AMADDevice?
+
+ - stelle sicher das als aller erstes die AMADCommBridge in FHEM definiert wurde
+ - installiere die App "Automagic Premium" aus dem PlayStore.
+ - installiere das Flowset 74_AMADDeviceautomagicFlowset$VERSION.xml aus dem Ordner $INSTALLFHEM/FHEM/lib/ auf dem Androidgerät
+ - aktiviere den Installationsassistanten Flow in Automagic. Wenn man nun Automagic in den Hintergrund schickt, z.B. Hometaste drücken, startet der Assistant und legt automatisch ein Device für das Androidgerät an.
+
+
+ Ein AMADDevice Gerät von Hand anlegen.
+
+
+ Define
+
+ 10.6.9.10 1496497380000 IODev=AMADBridge
+ define <name> AMADDevice <IP-ADRESSE> <AMAD_ID> IODev=<IODEVICE>
+
+ Beispiel:
+
+ define WandTabletWohnzimmer AMADDevice 192.168.0.23 123456 IODev=NAME_des_AMADCommBridge_Devices
+
+
+ In diesem Fall wird ein AMADDevice von Hand angelegt. Die AMAD_ID, hier 123456, muß auch exakt so als globale Variable in Automagic eingetragen sein.
+
+
+
+ Readings
+
+ - airplanemode - Status des Flugmodus
+ - androidVersion - aktuell installierte Androidversion
+ - automagicState - Statusmeldungen von der AutomagicApp (Voraussetzung Android >4.3). Ist Android größer 4.3 vorhanden und im Reading steht "wird nicht unterstützt", muß in den Androideinstellungen unter Ton und Benachrichtigungen -> Benachrichtigungszugriff ein Haken für Automagic gesetzt werden
+ - batteryHealth - Zustand der Battery (1=unbekannt, 2=gut, 3=Überhitzt, 4=tot, 5=Überspannung, 6=unbekannter Fehler, 7=kalt)
+ - batterytemperature - Temperatur der Batterie
+ - bluetooth - on/off, Bluetooth Status an oder aus
+ - checkActiveTask - Zustand einer zuvor definierten APP. 0=nicht aktiv oder nicht aktiv im Vordergrund, 1=aktiv im Vordergrund, siehe Hinweis unten
+ - connectedBTdevices - eine Liste der verbundenen Gerät
+ - connectedBTdevicesMAC - eine Liste der MAC Adressen aller verbundender BT Geräte
+ - currentMusicAlbum - aktuell abgespieltes Musikalbum des verwendeten Mediaplayers
+ - currentMusicApp - aktuell verwendeter Mediaplayer (Amazon Music, Google Play Music, Google Play Video, Spotify, YouTube, TuneIn Player, Aldi Life Music)
+ - currentMusicArtist - aktuell abgespielter Musikinterpret des verwendeten Mediaplayers
+ - currentMusicIcon - Cover vom aktuell abgespielten Album Noch nicht fertig implementiert
+ - currentMusicState - Status des aktuellen/zuletzt verwendeten Mediaplayers
+ - currentMusicTrack - aktuell abgespielter Musiktitel des verwendeten Mediaplayers
+ - daydream - on/off, Daydream gestartet oder nicht
+ - deviceState - Status des Androidgerätes. unknown, online, offline.
+ - doNotDisturb - aktueller Status des nicht stören Modus
+ - dockingState - undocked/docked Status ob sich das Gerät in einer Dockinstation befindet.
+ - flow_SetCommands - active/inactive, Status des SetCommands Flow
+ - flow_informations - active/inactive, Status des Informations Flow
+ - flowsetVersionAtDevice - aktuell installierte Flowsetversion auf dem Device
+ - incomingCallerName - Anrufername des eingehenden Anrufes
+ - incomingCallerNumber - Anrufernummer des eingehenden Anrufes
+ - incommingWhatsAppMessageFrom - letzte WhatsApp Nachricht
+ - incommingWhatsTelegramMessageFrom - letzte Telegram Nachricht
+ - intentRadioName - zuletzt gesrreamter Intent Radio Name
+ - intentRadioState - Status des IntentRadio Players
+ - keyguardSet - 0/1 Displaysperre gesetzt 0=nein 1=ja, bedeutet nicht das sie gerade aktiv ist
+ - lastSetCommandError - letzte Fehlermeldung vom set Befehl
+ - lastSetCommandState - letzter Status vom set Befehl, Befehl erfolgreich/nicht erfolgreich gesendet
+ - lastStatusRequestError - letzte Fehlermeldung vom statusRequest Befehl
+ - lastStatusRequestState - letzter Status vom statusRequest Befehl, Befehl erfolgreich/nicht erfolgreich gesendet
+ - nextAlarmDay - aktiver Alarmtag
+ - nextAlarmState - aktueller Status des "Androidinternen" Weckers
+ - nextAlarmTime - aktive Alarmzeit
+ - powerLevel - Status der Batterie in %
+ - powerPlugged - Netzteil angeschlossen? 0=NEIN, 1|2=JA
+ - screen - on locked/unlocked, off locked/unlocked gibt an ob der Bildschirm an oder aus ist und gleichzeitig gesperrt oder nicht gesperrt
+ - screenBrightness - Bildschirmhelligkeit von 0-255
+ - screenFullscreen - on/off, Vollbildmodus (An,Aus)
+ - screenOrientation - Landscape,Portrait, Bildschirmausrichtung (Horizontal,Vertikal)
+ - screenOrientationMode - auto/manual, Modus für die Ausrichtung (Automatisch, Manuell)
+ - state - aktueller Status
+ - userFlowState - aktueller Status eines Flows, festgelegt unter dem setUserFlowState Attribut
+ - volume - Media Lautstärkewert
+ - volumeNotification - Benachrichtigungs Lautstärke
+
+ Beim Reading checkActivTask muß zuvor der Packagename der zu prüfenden App als Attribut checkActiveTask angegeben werden. Beispiel: attr Nexus10Wohnzimmer
+ checkActiveTask com.android.chrome für den Chrome Browser.
+
+
+
+
+ Set
+
+ - activateVoiceInput - aktiviert die Spracheingabe
+ - bluetooth - on/off, aktiviert/deaktiviert Bluetooth
+ - clearNotificationBar - All,Automagic, löscht alle Meldungen oder nur die Automagic Meldungen in der Statusleiste
+ - closeCall - beendet einen laufenden Anruf
+ - currentFlowsetUpdate - fürt ein Flowsetupdate auf dem Device durch
+ - doNotDisturb - schaltet den nicht stören Modus, always immer stören, never niemals stören, alarmClockOnly nur Wecker darf stören, onlyImportant nur wichtige Störungen
+ - installFlowSource - installiert einen Flow auf dem Device, das XML File muss unter /tmp/ liegen und die Endung xml haben. Bsp: set TabletWohnzimmer installFlowSource WlanUebwerwachen.xml
+ - mediaAmazonMusic - play, stop, next, back ,steuert den Amazon Musik Mediaplayer
+ - mediaGoogleMusic - play, stop, next, back ,steuert den Google Play Musik Mediaplayer
+ - mediaSpotifyMusic - play, stop, next, back ,steuert den Spotify Mediaplayer
+ - mediaTuneinRadio - play, stop, next, back ,steuert den TuneIn Radio Mediaplayer
+ - mediaAldiMusic - play, stop, next, back ,steuert den Aldi Musik Mediaplayer
+ - mediaAudible - play, stop, next, back ,steuert den Audible Mediaplayer
+ - mediaYouTube - play, stop, next, back ,steuert den YouTube Mediaplayer
+ - mediaVlcPlayer - play, stop, next, back ,steuert den VLC Mediaplayer
+ - nextAlarmTime - setzt die Alarmzeit. gilt aber nur innerhalb der nächsten 24Std.
+ - openCall - ruft eine Nummer an und legt optional nach X Sekunden auf / set DEVICE openCall 01736458 10 / ruft die Nummer an und beendet den Anruf nach 10s
+ - screenBrightness - setzt die Bildschirmhelligkeit, von 0-255.
+ - screenMsg - versendet eine Bildschirmnachricht
+ - sendintent - sendet einen Intentstring Bsp: set $AMADDeviceDEVICE sendIntent org.smblott.intentradio.PLAY url http://stream.klassikradio.de/live/mp3-192/stream.klassikradio.de/play.m3u name Klassikradio, der erste Befehl ist die Aktion und der zweite das Extra. Es können immer zwei Extras mitgegeben werden.
+ - sendSMS - sendet eine SMS an eine bestimmte Telefonnummer. Bsp.: sendSMS Dies ist ein Test|555487263
+ - startDaydream - startet den Daydream
+ - statusRequest - Fordert einen neuen Statusreport beim Device an. Es können nicht von allen Readings per statusRequest die Daten geholt werden. Einige wenige geben nur bei Statusänderung ihren Status wieder.
+ - timer - setzt einen Timer innerhalb der als Standard definierten ClockAPP auf dem Device. Es können nur Sekunden angegeben werden.
+ - ttsMsg - versendet eine Nachricht welche als Sprachnachricht ausgegeben wird
+ - userFlowState - aktiviert oder deaktiviert einen oder mehrere Flows,set Nexus7Wohnzimmer Badezimmer vorheizen:inactive oder set Nexus7Wohnzimmer Badezimmer vorheizen,Nachtlicht Steven:inactive
+ - vibrate - lässt das Androidgerät vibrieren
+ - volume - setzt die Medialautstärke. Entweder die internen Lautsprecher oder sofern angeschlossen die Bluetoothlautsprecher und per Klinkenstecker angeschlossene Lautsprecher, + oder - vor dem Wert reduziert die aktuelle Lautstärke um den Wert. Der maximale Sliderwert kann über das Attribut setVolMax geregelt werden.
+ - volumeUp - erhöh;t die Lautstärke um den angegeben Wert im entsprechenden Attribut. Ist kein Attribut angegeben wird per default 2 genommen.
+ - volumeDown - reduziert die Lautstärke um den angegeben Wert im entsprechenden Attribut. Ist kein Attribut angegeben wird per default 2 genommen.
+ - volumeNotification - setzt die Benachrichtigungslautstärke.
+
+
+ Set abhängig von gesetzten Attributen
+
+ - changetoBtDevice - wechselt zu einem anderen Bluetooth Gerät. Attribut setBluetoothDevice muß gesetzt sein. Siehe Hinweis unten!
+ - notifySndFile - spielt die angegebene Mediadatei auf dem Androidgerät ab. Die aufzurufende Mediadatei sollte sich im Ordner /storage/emulated/0/Notifications/ befinden. Ist dies nicht der Fall kann man über das Attribut setNotifySndFilePath einen Pfad vorgeben.
+ - openApp - öffnet eine ausgewählte App. Attribut setOpenApp
+ - openURL - öffnet eine URL im Standardbrowser, sofern kein anderer Browser über das Attribut setOpenUrlBrowser ausgewählt wurde. Bsp: attr Tablet setOpenUrlBrowser de.ozerov.fully|de.ozerov.fully.MainActivity, das erste ist der Package Name und das zweite der Class Name
+ - setAPSSID - setzt die AccessPoint SSID um ein WLAN sleep zu verhindern
+ - screen - on/off/lock/unlock schaltet den Bildschirm ein/aus oder sperrt/entsperrt ihn, in den Automagic Einstellungen muss "Admin Funktion" gesetzt werden sonst funktioniert "Screen off" nicht. Attribut setScreenOnForTimer ändert die Zeit wie lange das Display an bleiben soll!
+ - screenFullscreen - on/off, (aktiviert/deaktiviert) den Vollbildmodus. Attribut setFullscreen
+ - screenLock - Sperrt den Bildschirm mit Pinabfrage. Attribut setScreenlockPIN - hier die Pin dafür eingeben. Erlaubt sind nur Zahlen. Es müßen mindestens 4, bis max 16 Zeichen verwendet werden.
+ - screenOrientation - Auto,Landscape,Portait, aktiviert die Bildschirmausrichtung (Automatisch,Horizontal,Vertikal). Attribut setScreenOrientation
+ - system - setzt Systembefehle ab (nur bei gerootetet Geräen). reboot,shutdown,airplanemodeON (kann nur aktiviert werden) Attribut root, in den Automagic Einstellungen muss "Root Funktion" gesetzt werden
+ - setNotifySndFilePath - setzt den korrekten Systempfad zur Notifydatei (default ist /storage/emulated/0/Notifications/
+ - setTtsMsgSpeed - setzt die Sprachgeschwindigkeit bei der Sprachausgabe(Werte zwischen 0.5 bis 4.0 in 0.5er Schritten) default ist 1.0
+ - setTtsMsgSpeed - setzt die Sprache bei der Sprachausgabe, de oder en (default ist de)
+ - setVolUpDownStep - setzt den Step für volumeUp und volumeDown
+ - setVolMax - setzt die maximale Volume Gr&uoml;e für den Slider
+ - setNotifyVolMax - setzt den maximalen Lautstärkewert für Benachrichtigungslautstärke für den Slider
+ - setRingSoundVolMax - setzt den maximalen Lautstärkewert für Klingellautstärke für den Slider
+
+ Um openApp verwenden zu können, muss als Attribut der Package Name der App angegeben werden.
+
+ Um zwischen Bluetoothgeräten wechseln zu können, muß das Attribut setBluetoothDevice mit folgender Syntax gesetzt werden. attr <DEVICE> BTdeviceName1|MAC,BTDeviceName2|MAC Es muss
+ zwingend darauf geachtet werden das beim BTdeviceName kein Leerzeichen vorhanden ist. Am besten zusammen oder mit Unterstrich. Achtet bei der MAC darauf das Ihr wirklich nach jeder zweiten Zahl auch
+ einen : drin habt
+ Beispiel: attr Nexus10Wohnzimmer setBluetoothDevice Logitech_BT_Adapter|AB:12:CD:34:EF:32,Anker_A3565|GH:56:IJ:78:KL:76
+
+
+
+ state
+
+ - initialized - Ist der Status kurz nach einem define.
+ - active - die Geräteinstanz ist im aktiven Status.
+ - disabled - die Geräteinstanz wurde über das Attribut disable deaktiviert
+
+
+ Anwendungsbeispiele:
+
+
+
+
+=end html_DE
+=cut
diff --git a/74_AMADautomagicFlowset_2.6.12.xml b/74_AMADautomagicFlowset_4.0.0.xml
similarity index 53%
rename from 74_AMADautomagicFlowset_2.6.12.xml
rename to 74_AMADautomagicFlowset_4.0.0.xml
index ddf86ed..92f5f81 100644
--- a/74_AMADautomagicFlowset_2.6.12.xml
+++ b/74_AMADautomagicFlowset_4.0.0.xml
@@ -1,24 +1,32 @@
-
+
true
Akku Ladestand: grösser als 0%
- true
+ false
0
HIGHER_THAN
- false
+ true
true
false
App Task Beendet
- true
+ false
+ CLASSIC
*
+
+ true
+ App Task Beendet: ch.gridvision.ppam.androidautomagic
+ false
+ CLASSIC
+ ch.gridvision.ppam.androidautomagic
+
true
Benachrichtigung in Statusbar angezeigt: ch.gridvision.ppam.androidautomagic
- true
+ false
ch.gridvision.ppam.androidautomagic
TEXT
CONTAINS_TEXT
@@ -29,7 +37,7 @@
true
Benachrichtigung in Statusbar angezeigt: com.whatsapp
- true
+ false
com.whatsapp
TEXT
CONTAINS_TEXT
@@ -40,7 +48,7 @@
true
Benachrichtigung in Statusbar angezeigt: org.telegram.messenger
- true
+ false
org.telegram.messenger
TEXT
CONTAINS_TEXT
@@ -51,7 +59,7 @@
true
Benachrichtigung in Statusbar entfernt: ch.gridvision.ppam.androidautomagic
- true
+ false
ch.gridvision.ppam.androidautomagic
TEXT
CONTAINS_TEXT
@@ -59,10 +67,26 @@
false
false
+
+ true
+ Bluetooth Gerät getrennt: Alle Geräte
+ false
+ true
+
+
+
+
+ true
+ Bluetooth Gerät verbunden: Alle Geräte
+ false
+ true
+
+
+
true
Bluetooth Status: Schaltet aus, Aus
- true
+ false
false
false
true
@@ -71,7 +95,7 @@
true
Bluetooth Status: Schaltet ein, Ein
- true
+ false
true
true
false
@@ -80,55 +104,55 @@
true
Daydream Status: Gestartet
- true
+ false
true
true
Daydream Status: Gestoppt
- true
+ false
false
true
Display Orientierung: Landscape
- true
+ false
false
true
Display Orientierung: Portrait
- true
+ false
true
true
Display Status: Aus
- true
+ false
false
true
Display Status: Ein
- true
+ false
true
true
Dock Event: Docked
- true
+ false
true
true
Dock Event: Undocked
- true
+ false
false
true
Eingehender Anruf. Status: Klingelt, Nummern: Alle
- true
+ false
true
true
@@ -140,13 +164,13 @@
true
Flugmodus: Aus
- true
+ false
false
true
Genereller Broadcast: wenn com.android.deskclock.ALARM_ALERT
- true
+ false
com.android.deskclock.ALARM_ALERT
@@ -161,7 +185,7 @@
true
Genereller Broadcast: wenn com.android.deskclock.ALARM_DISMISS
- true
+ false
com.android.deskclock.ALARM_DISMISS
@@ -176,7 +200,7 @@
true
Genereller Broadcast: wenn com.android.deskclock.ALARM_DONE
- true
+ false
com.android.deskclock.ALARM_DONE
@@ -191,7 +215,7 @@
true
Genereller Broadcast: wenn com.android.deskclock.ALARM_SNOOZE
- true
+ false
com.android.deskclock.ALARM_SNOOZE
@@ -206,7 +230,7 @@
true
Genereller Broadcast: wenn org.smblott.intentradio.STATE
- true
+ false
org.smblott.intentradio.STATE
@@ -230,7 +254,7 @@ irname=getString("name")
false
HTTP Request: /fhem-amad/deviceInfo/
- true
+ false
/fhem-amad/deviceInfo/
8090
true
@@ -238,7 +262,7 @@ irname=getString("name")
false
HTTP Request: /fhem-amad/setCommands/*
- true
+ false
/fhem-amad/setCommands/*
8090
true
@@ -246,14 +270,14 @@ irname=getString("name")
false
Medien Session verändert
- true
- com.amazon.mp3,com.amazon.avod.thirdpartyclient,com.audible.application,com.rhapsody.alditalk,com.spotify.music,com.google.android.videos,com.google.android.music,org.smblott.intentradioio,de.maxdome.app.android,tunein.player,org.videolan.vlc,com.google.android.youtube
+ false
+ com.amazon.mp3,com.amazon.avod.thirdpartyclient,com.audible.application,com.rhapsody.alditalk,com.spotify.music,com.google.android.videos,com.google.android.music,org.smblott.intentradioio,de.maxdome.app.android,tunein.player,org.videolan.vlc,com.google.android.youtube,com.sec.android.app.music
false
- Periodischer Timer: alle 30s
- true
- 30000
+ Periodischer Timer: alle 120s
+ false
+ 120000
true
false
false
@@ -274,12 +298,12 @@ irname=getString("name")
true
Sprachbefehl angefordert
- true
+ false
true
Stromversorgung: Angeschlossen
- true
+ false
true
true
true
@@ -288,7 +312,7 @@ irname=getString("name")
true
Stromversorgung: Entfernt
- true
+ false
false
true
true
@@ -297,7 +321,7 @@ irname=getString("name")
false
Systemeinstellung verändert: System next_alarm
- true
+ false
SYSTEM
next_alarm_formatted
setting
@@ -305,7 +329,7 @@ irname=getString("name")
true
Systemeinstellung verändert: System screen_brightness
- true
+ false
SYSTEM
screen_brightness
screenBrightness
@@ -313,7 +337,7 @@ irname=getString("name")
true
Systemeinstellung verändert: System volume_music_bt_a2dp
- true
+ false
SYSTEM
volume_music_bt_a2dp
volume
@@ -321,7 +345,7 @@ irname=getString("name")
true
Systemeinstellung verändert: System volume_music_headphone
- true
+ false
SYSTEM
volume_music_headphone
volume
@@ -329,7 +353,7 @@ irname=getString("name")
false
Systemeinstellung verändert: System volume_music_headset
- true
+ false
SYSTEM
volume_music_headset
volume
@@ -337,7 +361,7 @@ irname=getString("name")
true
Systemeinstellung verändert: System volume_music_speaker
- true
+ false
SYSTEM
volume_music_speaker
volume
@@ -345,7 +369,7 @@ irname=getString("name")
true
Systemeinstellung verändert: System volume_ring
- true
+ false
SYSTEM
volume_ring
volumeRingSound
@@ -353,7 +377,7 @@ irname=getString("name")
true
Systemeinstellung verändert: System volume_ring_speaker
- true
+ false
SYSTEM
volume_ring_speaker
volumeNotification
@@ -361,36 +385,52 @@ irname=getString("name")
true
Unterbrechnungen-Modus: Alle / Immer unterbrechen
- true
+ false
OFF
true
Unterbrechnungen-Modus: Keine / Nicht unterbrechen
- true
+ false
NO_INTERRUPTIONS
true
Unterbrechnungen-Modus: Nur Wecker (Android 6+)
- true
+ false
ALARMS_ONLY
true
Unterbrechnungen-Modus: Wichtig / Nur wichtige Unterbrechnungen zulassen
- true
+ false
IMPORTANT_INTERRUPTIONS
+
+ false
+ WLAN Getrennt: toGo
+ true
+ false
+ {global_apssid}
+
+
+ false
+ WLAN Verbunden: toGo
+ true
+ false
+ {global_apssid}
+
false
App Task läuft: App (neuster)
+ CLASSIC
{param_app}
true
true
App Task läuft: {global_activetask} (neuster)
+ CLASSIC
{global_activetask}
true
@@ -488,6 +528,11 @@ irname=getString("name")
Expression: All
param_app == "All"
+
+ true
+ Expression: amadcmd == "firstrun"
+ amadcmd == "firstrun"
+
false
Expression: Automagic
@@ -558,6 +603,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
@@ -728,6 +778,16 @@ irname=getString("name")
Expression: Reboot
param_syscmd == "reboot"
+
+ true
+ Expression: respreadingsval != "kaputt" and respreadingsval != "none"
+ respreadingsval != "kaputt" and respreadingsval != "none"
+
+
+ true
+ Expression: respreadingsval == "online"
+ respreadingsval == "online"
+
true
Expression: scrcount < 5
@@ -823,6 +883,11 @@ irname=getString("name")
Expression: Shutdown
param_syscmd == "shutdown"
+
+ true
+ Expression: sprachassi == "ja"
+ sprachassi == "ja"
+
false
Expression: startDaydream"
@@ -833,6 +898,11 @@ irname=getString("name")
Expression: System Command"
request_path == "/fhem-amad/setCommands/systemcommand"
+
+ true
+ Expression: togocount < 6
+ togocount < 6
+
true
Expression: trigger == "Akku Ladestand: grösser als 0%"
@@ -862,8 +932,10 @@ irname=getString("name")
true
- Expression: trigger == "Bluetooth Status: Schaltet aus, Aus" or trigger == "Bluetooth Status: Schaltet ein, Ein" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
+ Expression: trigger == "Bluetooth Status: Schaltet aus, Aus" or trigger == "Bluetooth Gerät verbunden: Alle Geräte" or trigger == "Bluetooth Gerät getrennt: Alle Geräte" or trigger == "Bluetooth Status: Schaltet ein, Ein" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
trigger == "Bluetooth Status: Schaltet aus, Aus"
+ or trigger == "Bluetooth Gerät verbunden: Alle Geräte"
+ or trigger == "Bluetooth Gerät getrennt: Alle Geräte"
or trigger == "Bluetooth Status: Schaltet ein, Ein"
or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
@@ -945,13 +1017,13 @@ or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
true
- Expression: trigger == "Periodischer Timer: alle 30s"
- trigger == "Periodischer Timer: alle 30s"
+ Expression: trigger == "Periodischer Timer: alle 120s"
+ trigger == "Periodischer Timer: alle 120s"
true
- Expression: trigger == "Periodischer Timer: alle 30s" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
- trigger == "Periodischer Timer: alle 30s" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
+ Expression: trigger == "Periodischer Timer: alle 120s" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
+ trigger == "Periodischer Timer: alle 120s" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
true
@@ -996,6 +1068,16 @@ or trigger == "Unterbrechnungen-Modus: Nur Wecker (Android 6+)"
or trigger == "Unterbrechnungen-Modus: Wichtig / Nur wichtige Unterbrechnungen zulassen"
or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
+
+ true
+ Expression: trigger == "WLAN Getrennt: toGo"
+ trigger == "WLAN Getrennt: toGo"
+
+
+ true
+ Expression: trigger == "WLAN Verbunden: toGo"
+ trigger == "WLAN Verbunden: toGo"
+
false
Expression: ttsMsg"
@@ -1017,11 +1099,31 @@ or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
Expression: value != ""
value != ""
+
+ true
+ Expression: value == "ja"
+ value == "ja"
+
+
+ true
+ Expression: value == "nein"
+ value == "nein"
+
+
+ true
+ Flow Aktiv: First Run Assistant
+ First Run Assistant
+
true
Flow Aktiv: Informations
Informations
+
+ true
+ Flow Aktiv: Send Data to AMADCommBridge
+ Send Data to AMADCommBridge
+
true
Flow Aktiv: SetCommands
@@ -1108,6 +1210,31 @@ or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
WLAN verfügbar: {global_apssid}
{global_apssid}
+
+ false
+ Abfrage
+ Send Data to AMADCommBridge
+
+ false
+ true
+ true
+
+
+ false
+ AMAD First Run Assistent Begrüßung
+ MUSIC
+ Hallo und herzlich willkommen beim Einrichtungs Assistenten von Fhem Amaad. Wenn Du fortfahren möchtest antworte einfach mit ja. Wenn nicht mit nein.
+ de_DE
+ true
+ 1.0
+ true
+ 1.0
+ false
+ true
+ false
+ true
+ TRANSIENT
+
false
AMAD Voice Control
@@ -1203,22 +1330,6 @@ or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
0
0
-
- true
- Benachrichtigung auf Bildschirm: {response} (lange)
- true
- {response}
-
- 200
- 250
- false
- 1.00
- true
- false
- TOP_LEFT
- 0
- 0
-
true
Benachrichtigung auf Bildschirm: {value} (lange)
@@ -1439,6 +1550,81 @@ putString("{param_exkey2}", "{param_exval2}");
/storage/sdcard0/Download
true
+
+ true
+ Eingabedialog: AMADCommBridge Port Einzeiliger Text Bitte gebe den Port der AMADCommBridge vom FHEM Server an.
+ AMADCommBridge Port
+ SINGLE_LINE_TEXT
+ Bitte gebe den Port der AMADCommBridge vom FHEM Server an.
+
+ 8090
+ false
+ 60000
+
+ false
+ false
+ false
+
+
+ true
+ Eingabedialog: Android Device IP Adresse Einzeiliger Text Bitte gebe die IP Adresse Deines Androidgerätes an. NUR IP kein FQDN!!!
+ Android Device IP Adresse
+ SINGLE_LINE_TEXT
+ Bitte gebe die IP Adresse Deines Androidgerätes an. NUR IP kein FQDN!!!
+
+ 192.168.x.x
+ false
+ 60000
+
+ false
+ false
+ false
+
+
+ true
+ Eingabedialog: FHEM Devicename Einzeiliger Text Wie soll das Device in FHEM heißen?
+ FHEM Devicename
+ SINGLE_LINE_TEXT
+ Wie soll das Device in FHEM heißen?
+
+ TabletWohnzimmer
+ false
+ 60000
+
+ false
+ false
+ false
+
+
+ true
+ Eingabedialog: FHEM Server IP Einzeiliger Text Bitte gebe die IP Adresse oder den FQDN Deines FHEM Servers an.
+ FHEM Server IP
+ SINGLE_LINE_TEXT
+ Bitte gebe die IP Adresse oder den FQDN Deines FHEM Servers an.
+
+ 192.168.x.x
+ false
+ 60000
+
+ false
+ false
+ false
+
+
+ true
+ Eingabedialog: Wünschst Du einen sprachgestützten oder dialoggestützten Installationsassistanten? Einfachauswahl Menü Sprache,Dialog (15s)
+ Wünschst Du einen sprachgestützten oder dialoggestützten Installationsassistanten?
+ SINGLE_CHOICE_MENU
+
+ Sprache,Dialog
+ Sprache
+ true
+ 15000
+
+ false
+ false
+ false
+
true
Flows ausführen: Send Data to AMADCommBridge
@@ -1471,10 +1657,16 @@ putString("{param_exkey2}", "{param_exval2}");
Flows ausführen: VoiceControl
VoiceControl
- true
+ false
false
false
+
+ true
+ Flows löschen: First Run Assistant
+ First Run Assistant
+ true
+
true
Flows löschen: MultimediaControl
@@ -1585,67 +1777,89 @@ androidVersion = "4.0 - 4.0.2 Ice Cream Sandwich"
false
- HTTP Request: send READINGS data to AMADCommBridge
+ HTTP Request: send FIRSTRUN data to AMADCommBridge JSON
http://{global_fhemip}:{global_bridgeport}
false
false
+ false
+
POST
GENERAL_TEXT
- text/plain
+ text/json
+ {firstrundata}
+ @@@@readingsNameXYZ@@readingsValueABC
+ 15000
+ true
+ Connection: close
+ true
+ respfirstrun
+ /storage/emulated/0/Download/file.bin
+ false
+
+
+ false
+ HTTP Request: send READINGS data to AMADCommBridge JSON
+ http://{global_fhemip}:{global_bridgeport}
+ false
+ false
+
+ false
+
+ POST
+ GENERAL_TEXT
+ text/json
{fhemdata}
@@@@readingsNameXYZ@@readingsValueABC
- 60000
+ 15000
true
- FHEMDEVICE: {global_fhemdevice}
-FHEMCMD: setreading
-Connection: close
+ Connection: close
true
- response
+ respsetreading
/storage/emulated/0/Download/file.bin
false
false
- HTTP Request: send READINGSVAL data to AMADCommBridge
+ HTTP Request: send READINGSVAL data to AMADCommBridge JSON
http://{global_fhemip}:{global_bridgeport}
false
false
+ false
+
POST
GENERAL_TEXT
- text/plain
+ text/json
{readingsvalcmd}
@@@@readingsNameXYZ@@readingsValueABC
- 60000
+ 15000
true
- FHEMDEVICE: {global_fhemdevice}
-FHEMCMD: readingsval
-Connection: close
+ Connection: close
true
- response
+ respreadingsval
/storage/emulated/0/Download/file.bin
false
false
- HTTP Request: send SET data to AMADCommBridge
+ HTTP Request: send SET data to AMADCommBridge JSON
http://{global_fhemip}:{global_bridgeport}
false
false
+ false
+
POST
GENERAL_TEXT
- text/plain
+ text/json
{setcmd}
@@@@readingsNameXYZ@@readingsValueABC
- 60000
+ 15000
true
- FHEMDEVICE: {global_fhemdevice}
-FHEMCMD: set
-Connection: close
+ Connection: close
true
- response
+ respset
/storage/emulated/0/Download/file.bin
false
@@ -1656,21 +1870,37 @@ Connection: close
false
false
+ false
+
POST
GENERAL_TEXT
- text/plain
+ text/json
{voiceinputdata}
@@@@readingsNameXYZ@@readingsValueABC
- 60000
+ 15000
true
FHEMDEVICE: {global_fhemdevice}
FHEMCMD: voiceinputvalue
Connection: close
true
- response
+ respvoiceinputvalue
/storage/emulated/0/Download/file.bin
true
+
+ true
+ In Datei Schreiben: Aktiviere Flows in /storage/emulated/0/file.txt (anhängen)
+ /storage/emulated/0/file.txt
+ Aktiviere Flows
+ true
+
+
+ true
+ In Datei Schreiben: Deaktiviere Flows in /storage/emulated/0/file.txt (anhängen)
+ /storage/emulated/0/file.txt
+ Deaktiviere Flows
+ true
+
false
Initialisiere Variable Nächster Alarm: next_alarm
@@ -1711,6 +1941,15 @@ Connection: close
volume_ring
volumeRingSound
+
+ true
+ Lautstärke einstellen: Medien auf Level 8
+ MUSIC
+ ADJUST_SET_ABSOLUTE
+ 8
+ false
+ false
+
false
Lautstärken setzen param_notifivolume
@@ -1777,6 +2016,86 @@ Connection: close
false
global_interruptions_mode
+
+ false
+ Medianlautstärken Speichern
+ false
+ global_volume_alarm
+ false
+ global_volume_dtmf
+ true
+ global_volume_music
+ false
+ global_volume_notification
+ false
+ global_volume_ring
+ false
+ global_volume_system
+ false
+ global_volume_voice_call
+ false
+ global_ringer_mode
+ false
+ global_interruptions_mode
+
+
+ false
+ Medienlautstärke Wiederherstellen
+ false
+ global_volume_alarm
+ false
+ global_volume_dtmf
+ true
+ global_volume_music
+ false
+ global_volume_notification
+ false
+ global_volume_ring
+ false
+ global_volume_system
+ false
+ global_volume_voice_call
+ false
+ global_ringer_mode
+ false
+ global_interruptions_mode
+
+
+ true
+ Meldungsdialog: Alle Informationen wurden nun erfasst und zur Amaad Comm Bridge gesendet. Ich werde gleich einmal prüfen ob die Einrichtung des Devices in Fhem gelungen ist. Gib mir bitte bis zu einer Minute Zeit für die Prüfung.
+
+ Alle Informationen wurden nun erfasst und zur Amaad Comm Bridge gesendet. Ich werde gleich einmal prüfen ob die Einrichtung des Devices in Fhem gelungen ist. Gib mir bitte bis zu einer Minute Zeit für die Prüfung.
+ Weiter
+ false
+ 60000
+
+
+ true
+ Meldungsdialog: Die Einrichtung ist nun abgeschlossen und das Amaad Device wurde angelegt. Es scheint aber noch keine Verbindung zwischen Fhem und Deinem Amaad Device zu bestehen. Mache am besten einmal ein Status Request in Fhem für das Amaad Device. Ist der Status in Fhem weiterhin offline schaue bitte ob alle Am
+
+ Die Einrichtung ist nun abgeschlossen und das Amaad Device wurde angelegt. Es scheint aber noch keine Verbindung zwischen Fhem und Deinem Amaad Device zu bestehen. Mache am besten einmal ein Status Request in Fhem für das Amaad Device. Ist der Status in Fhem weiterhin offline schaue bitte ob alle Amaad, Flows aktiv sind.
+ Weiter
+ false
+ 60000
+
+
+ true
+ Meldungsdialog: Leider scheint es ein Problem beim Einrichten des FHEM Devices gegeben zu haben. Hast Du die AMADCommBridge definiert, und ist sie auch aktiv? Sollte es weiterhin Probleme geben, wende Dich bitte an CoolTux alias Leon, im FHEM Forum.
+
+ Leider scheint es ein Problem beim Einrichten des FHEM Devices gegeben zu haben. Hast Du die AMADCommBridge definiert, und ist sie auch aktiv? Sollte es weiterhin Probleme geben, wende Dich bitte an CoolTux alias Leon, im FHEM Forum.
+ Weiter
+ false
+ 60000
+
+
+ true
+ Meldungsdialog: Wunderbar. Bitte nimm Dir Zeit und lese Dir die Hilfe Dialoge genau durch. Wenn Du Dir unsicher bist, kannst Du die Standardeinstellung, sofern vorhanden, belassen. Lass uns nun mit der Einrichtung beginnen.
+
+ Wunderbar. Bitte nimm Dir Zeit und lese Dir die Hilfe Dialoge genau durch. Wenn Du Dir unsicher bist, kannst Du die Standardeinstellung, sofern vorhanden, belassen. Lass uns nun mit der Einrichtung beginnen.
+ Weiter
+ false
+ 60000
+
true
Neustart
@@ -1838,9 +2157,17 @@ Connection: close
true
Nummer anrufen: {param_callnumber}
+
{param_callnumber}
true
+
+ true
+ Pause: 1s (Gerät wach halten)
+ 1s
+ true
+ false
+
true
Pause: 2s (Gerät wach halten)
@@ -1870,12 +2197,15 @@ Connection: close
false
- Prüfe und setze globale Variablen
+ Prüfe und setze globale Variable
@@ -1937,8 +2270,18 @@ fhemcmd = "setreading";
true
- Script: androidVersion = "androidVersion@@" + {androidVersion}; fhemcmd = "setreading";
-
+
+
+ true
+ Script: amaddevice_ip = {value}
+
+
+
+ true
+ Script: androidVersion = "\"androidVersion\":" + " \"" + {androidVersion} + "\""; fhemcmd = "setreading";
+
@@ -1948,14 +2291,14 @@ fhemcmd = "setreading";
true
- Script: automagicState = "automagicState@@" + {notification_text}; fhemcmd = "setreading";
-
true
- Script: bluetooth = "bluetooth@@" + {bluetooth_state}; fhemcmd = "setreading";
-
@@ -1970,15 +2313,15 @@ fhemcmd = "setreading";
true
- Script: btdeviceinfo = "connectedBTdevices@@" + {connected_devices_names} + "@@@@connectedBTdevicesMAC@@" + {connected_devices_addresses}; fhemcmd = "setreading";
-
true
- Script: checkActiveTask = "checkActiveTask@@" + {runTask}; fhemcmd = "setreading";
-
@@ -1989,19 +2332,19 @@ connected_devices_addresses = "none"
true
- Script: currentMusic = "currentMusicTrack@@" + {title} + "@@@@currentMusicAlbum@@" + {description} + "@@@@currentMusicArtist@@" + {subtitle} + "@@@@currentMusicApp@@" + {musicapp} + "@@@@currentMusicIcon@@" + {icon} + "@@@@currentMusicState@@" + {playback_state}; fhemcmd = "setreading";
-
true
- Script: daydream = "daydream@@" + {daydream_state}; fhemcmd = "setreading";
-
@@ -2016,8 +2359,8 @@ fhemcmd = "setreading";
true
- Script: deviceState = "deviceState@@online"; fhemcmd = "setreading";
-
@@ -2052,32 +2395,32 @@ fhemcmd = "setreading";
true
- Script: dockingState = "dockingState@@" + {dock_state}; fhemcmd = "setreading";
-
true
- Script: doNotDisturb = "doNotDisturb@@" + {dndValue}; fhemcmd = "setreading";
-
true
- Script: flow_informations = "flow_informations@@" + {informationFlow_state}; fhemcmd = "setreading";
-
true
- Script: flow_informations = "userFlowState@@" + {flowState}; fhemcmd = "setreading";
-
true
- Script: flow_SetCommands = "flow_SetCommands@@" + {setCommandFlow_state}; fhemcmd = "setreading";
-
@@ -2092,7 +2435,46 @@ fhemcmd = "setreading";
true
- Script: if(package_name == "com.google.android.music") { musicapp = "Google Musik" } if(package_name == "com.amazon.mp3") { musicapp = "Amazon Musik" } if(package_name == "com.google.android.videos") { musicapp = "Google Video" } if(package_name == "com.spotify.music") { musicapp = "Spotify Musik" } if(package_name == "com.google.android.youtube") { musicapp = "YouTube" } if(package_name == "tunein.player") { musicapp = "TuneIn Player" } if(package_name == "com.rhapsody.alditalk") { musicapp = "Aldi Life Musik" } if(package_name == "org.videolan.vlc") { musicapp = "VLC Player" }
+ Script: global_activetask = "none"; global_apssid = "none"; global_userflowstate = "none";
+
+
+
+ true
+ Script: global_amadid = getDate();
+
+
+
+ true
+ Script: global_bridgeport = {value}
+
+
+
+ true
+ Script: global_fhemdevice = {value}
+
+
+
+ true
+ Script: global_fhemip = {value}
+
+
+
+ true
+ Script: if(index == 0) { sprachassi = "ja"; } else { sprachassi = "nein"; }
+
+
+
+ true
+ Script: if(package_name == "com.google.android.music") { musicapp = "Google Musik" } if(package_name == "com.amazon.mp3") { musicapp = "Amazon Musik" } if(package_name == "com.google.android.videos") { musicapp = "Google Video" } if(package_name == "com.spotify.music") { musicapp = "Spotify Musik" } if(package_name == "com.google.android.youtube") { musicapp = "YouTube" } if(package_name == "tunein.player") { musicapp = "TuneIn Player" } if(package_name == "com.rhapsody.alditalk") { musicapp = "Aldi Life Musik" } if(package_name == "org.videolan.vlc") { musicapp = "VLC Player" } if(package_name == "com.sec.android.app.music") { musicapp = "Samsung Music Player" }
@@ -2174,6 +2560,18 @@ playback_state = "springt zum nächsten"
if(playback_state == 11) {
playback_state = "springt zu Position in Wiedergabeliste"
+}
+
+
+ true
+ Script: if(togocount > 0) { togocount = togocount + 1; } else { togocount = 0; togocount = togocount + 1; }
+
@@ -2197,21 +2595,21 @@ nextalarmstate = "snooze"
true
- Script: incomingCaller = "incomingCallerName@@" + {contact_name} + "@@@@incomingCallerNumber@@" + {incoming_number}; fhemcmd = "setreading";
-
true
- Script: incommingTelegramMessage = "incommingTelegramMessageFrom@@" + {notification_text}; fhemcmd = "setreading";
-
true
- Script: incommingWhatsAppMessage = "incommingWhatsAppMessageFrom@@" + {notification_text}; fhemcmd = "setreading";
-
@@ -2226,9 +2624,9 @@ fhemcmd = "setreading";
true
- Script: intentRadioState = "intentRadioState@@" + {irstate} + "@@@@intentRadioName@@" + {irname}; fhemcmd = "setreading";
-
@@ -2253,8 +2651,8 @@ fhemcmd = "setreading";
true
- Script: keyguardSet = "keyguardSet@@" + {keyguardSet}; fhemcmd = "setreading";
-
@@ -2274,15 +2672,15 @@ fhemcmd = "setreading";
true
- Script: nextAlarm = "nextAlarmTime@@" + {next_alarmtime} + "@@@@nextAlarmDay@@" + {next_alarmday}; fhemcmd = "setreading";
-
true
- Script: nextAlarmState = "nextAlarmState@@" + {nextalarmstate}; fhemcmd = "setreading";
-
@@ -2312,12 +2710,19 @@ fhemcmd = "setreading";
true
- Script: powerinfo = "powerLevel@@" + "{battery_percentage,numberformat,0}" + "@@@@powerPlugged@@" + {battery_plugged} + "@@@@batteryTemperature@@" + "{battery_temperature/10.0,numberformat.0.0}" + "@@@@batteryHealth@@" + {battery_health}; fhemcmd = "setreading";
-
+
+
+ true
+ Script: readingsvalcmd = "{global_fhemdevice} deviceState kaputt"; fhemcmd = "readingsval"; respfirstrun = "none";
+
true
@@ -2351,8 +2756,8 @@ fhemcmd = "setreading";
true
- Script: screen = "screen@@" + {screen_state}; fhemcmd = "setreading";
-
@@ -2397,101 +2802,133 @@ fhemcmd = "setreading";
true
- Script: screenBrightness = "screenBrightness@@" + {screenBrightness}; fhemcmd = "setreading";
-
true
- Script: screenOrientation = "screenOrientation@@" + {screen_orientation} + "@@@@screenOrientationMode@@" + {screen_orientation_mode}; fhemcmd = "setreading";
-
false
- Script: Set FHEMDATA
-
+ fhemdata = fhemdata + "{flow_informations}" + "," }
+
+
+
+
+fhemdata = substring(fhemdata, 0, length(fhemdata) - 1);
+
+
+fhemdata = "\{\"amad\": \{\"amad_id\": \"" + {global_amadid} + "\",\"fhemcmd\": \"setreading\"\},\"payload\": \{ " + {fhemdata} + "\}\}"
+
+
+ false
+ Script: Set FHEMDATA JSON First Run Assistant
+
+
+
+ false
+ Script: Set FHEMREADINGSVALCMD JSON
+
+
+
+ false
+ Script: Set FHEMSETCMD JSON
+
+
+
+ false
+ Script: Set FHEMVOICEINPUTDATA JSON
+
true
@@ -2541,20 +2978,20 @@ fhemcmd = "voiceinputvalue";
true
- Script: volumeNotification = "volumeNotification@@" + {volumeNotification}; fhemcmd = "setreading";
-
true
- Script: volumeRingSound = "volumeRingSound@@" + {volumeRingSound}; fhemcmd = "setreading";
-
true
- Script: volumevalue = "volume@@" + {volume}; fhemcmd = "setreading";
-
@@ -2606,6 +3043,12 @@ if(param_mplayer == "mediaAudible")
{
pname = "com.audible.application";
kname = "com.audible.application.AudibleMediaButtonProcessingReceiver";
+}
+
+if(param_mplayer == "mediaSamsungMusic")
+{
+ pname = "com.sec.android.app.music";
+ kname = "com.samsung.android.app.music.service.receiver.MediaButtonReceiver";
}
@@ -2653,6 +3096,20 @@ if(param_mplayer == "mediaAudible")
Informations
+
+ true
+ Setze Flow Status: Aktivieren Informations,SetCommands
+ true
+ Informations,SetCommands
+
+
+
+ true
+ Setze Flow Status: Aktivieren Send Data to AMADCommBridge
+ true
+ Send Data to AMADCommBridge
+
+
true
Setze Flow Status: Aktivieren SetCommands
@@ -2660,6 +3117,13 @@ if(param_mplayer == "mediaAudible")
SetCommands
+
+ true
+ Setze Flow Status: Aktivieren SetCommands,Update AMAD Flowset,VoiceControl
+ true
+ SetCommands,Update AMAD Flowset,VoiceControl
+
+
true
Setze Flow Status: Aktivieren {imported_flow_names,listformat,comma}
@@ -2674,6 +3138,20 @@ if(param_mplayer == "mediaAudible")
{param_flowname}
+
+ true
+ Setze Flow Status: Deaktivieren First Run Assistant
+ false
+ First Run Assistant
+
+
+
+ true
+ Setze Flow Status: Deaktivieren Informations,SetCommands
+ false
+ Informations,SetCommands
+
+
true
Setze Flow Status: Deaktivieren {param_flowname}
@@ -2748,6 +3226,7 @@ if(param_mplayer == "mediaAudible")
true
SMS senden an: an {param_smsnumber} '{param_smsmessage}' (10 in 12h)
+
{param_smsnumber}
{param_smsmessage}
true
@@ -2766,11 +3245,28 @@ if(param_mplayer == "mediaAudible")
Lautlos
{param_notifypath}{param_notifyfile}
NOTIFICATION
+
false
true
true
TRANSIENT
+
+ true
+ Sprachausgabe: Alle Informationen wurden nun erfasst und zur Amaad Comm Bridge gesendet. Ich werde gleich einmal prüfen ob die Einrichtung des Devices in Fhem gelungen ist. Gib mir bitte bis zu einer Minute Zeit für die Prüfung.
+ MUSIC
+ Alle Informationen wurden nun erfasst und zur Amaad Comm Bridge gesendet. Ich werde gleich einmal prüfen ob die Einrichtung des Devices in Fhem gelungen ist. Gib mir bitte bis zu einer Minute Zeit für die Prüfung.
+ de_DE
+ true
+ 1.0
+ true
+ 1.0
+ false
+ true
+ false
+ true
+ TRANSIENT
+
false
Sprachausgabe: Deutsch
@@ -2787,6 +3283,60 @@ if(param_mplayer == "mediaAudible")
true
TRANSIENT
+
+ true
+ Sprachausgabe: Die Einrichtung ist nun abgeschlossen und das Amaad Device online.
+Soll der Assistent gelöscht werden?
+ MUSIC
+ Die Einrichtung ist nun abgeschlossen und das Amaad Device online.
+Soll der Assistent gelöscht werden?
+ de_DE
+ true
+ 1.0
+ true
+ 1.0
+ false
+ true
+ false
+ true
+ TRANSIENT
+
+
+ true
+ Sprachausgabe: Die Einrichtung ist nun abgeschlossen und das Amaad Device wurde angelegt. Es scheint aber noch keine Verbindung zwischen Fhem und Deinem Amaad Device zu bestehen. Mache am besten einmal ein Status Request in Fhem für das Amaad Device. Ist der Status in Fhem weiterhin offline schaue bitte ob alle Amaad, Flows aktiv sind.
+Soll der Assistent gelöscht werden?
+ MUSIC
+ Die Einrichtung ist nun abgeschlossen und das Amaad Device wurde angelegt. Es scheint aber noch keine Verbindung zwischen Fhem und Deinem Amaad Device zu bestehen. Mache am besten einmal ein Status Request in Fhem für das Amaad Device. Ist der Status in Fhem weiterhin offline schaue bitte ob alle Amaad, Flows aktiv sind.
+Soll der Assistent gelöscht werden?
+ de_DE
+ true
+ 1.0
+ true
+ 1.0
+ false
+ true
+ false
+ true
+ TRANSIENT
+
+
+ true
+ Sprachausgabe: Du möchtest also nicht fortfahren. Das ist schade. Bitte bedenke das dieses Android Gerät somit nicht als Amaad Device in Fhem angelegt ist. Du kannst jeder Zeit den Assistenten Flow neu aktivieren und von vorn beginnen.
+Auf Wiedersehen.
+ MUSIC
+ Du möchtest also nicht fortfahren. Das ist schade. Bitte bedenke das dieses Android Gerät somit nicht als Amaad Device in Fhem angelegt ist. Du kannst jeder Zeit den Assistenten Flow neu aktivieren und von vorn beginnen.
+Auf Wiedersehen.
+ de_DE
+ true
+ 1.0
+ true
+ 1.0
+ false
+ true
+ false
+ true
+ TRANSIENT
+
false
Sprachausgabe: Englisch
@@ -2803,6 +3353,88 @@ if(param_mplayer == "mediaAudible")
true
TRANSIENT
+
+ true
+ Sprachausgabe: In Ordnung. Der Einrichtungs Assistent bleibt erhalten. Auf Wiedersehen.
+ MUSIC
+ In Ordnung. Der Einrichtungs Assistent bleibt erhalten. Auf Wiedersehen.
+ de_DE
+ true
+ 1.0
+ true
+ 1.0
+ false
+ true
+ false
+ true
+ TRANSIENT
+
+
+ true
+ Sprachausgabe: In Ordnung. Der Einrichtungs Assistent wird gelöscht. Auf Wiedersehen.
+ MUSIC
+ In Ordnung. Der Einrichtungs Assistent wird gelöscht. Auf Wiedersehen.
+ de_DE
+ true
+ 1.0
+ true
+ 1.0
+ false
+ true
+ false
+ true
+ TRANSIENT
+
+
+ true
+ Sprachausgabe: Leider scheint es ein Problem beim einrichten des Fhem Devices gegeben zu haben. Hast Du die Amaad Comm Bridge definiert? Und ist sie auch aktiv? Sollte es weiterhin Probleme geben, wende Dich bitte an Cooltux alias Leon, im Fhem Forum.
+Soll der Assistent gelöscht werden?
+ MUSIC
+ Leider scheint es ein Problem beim einrichten des Fhem Devices gegeben zu haben. Hast Du die Amaad Comm Bridge definiert? Und ist sie auch aktiv? Sollte es weiterhin Probleme geben, wende Dich bitte an Cooltux alias Leon, im Fhem Forum.
+Soll der Assistent gelöscht werden?
+ de_DE
+ true
+ 1.0
+ true
+ 1.0
+ false
+ true
+ false
+ true
+ TRANSIENT
+
+
+ true
+ Sprachausgabe: Oh das tut mir leid, da scheine ich Dich nicht verstanden zu haben. Bitte versuche es mit etwas Ruhe im Hintergrund noch einmal.
+ MUSIC
+ Oh das tut mir leid, da scheine ich Dich nicht verstanden zu haben. Bitte versuche es mit etwas Ruhe im Hintergrund noch einmal.
+ de_DE
+ true
+ 1.0
+ true
+ 1.0
+ false
+ true
+ false
+ true
+ TRANSIENT
+
+
+ true
+ Sprachausgabe: Wunderbar. Bitte nimm Dir Zeit und lese Dir die Hilfe Dialoge genau durch. Wenn Du Dir unsicher bist, kannst Du die Standardeinstellung, sofern vorhanden, belassen. Lass uns nun mit der Einrichtung beginnen.
+ MUSIC
+ Wunderbar. Bitte nimm Dir Zeit und lese Dir die Hilfe Dialoge genau durch. Wenn Du Dir unsicher bist, kannst Du die Standardeinstellung, sofern vorhanden, belassen. Lass uns nun mit der Einrichtung beginnen.
+ de_DE
+ true
+ 1.0
+ true
+ 1.0
+ false
+ true
+ false
+ true
+ TRANSIENT
+
false
Spracheingabe wurde nicht erkannt
@@ -2843,13 +3475,347 @@ if(param_mplayer == "mediaAudible")
true
WLAN Reassoziieren
+
+ First Run Assistant
+ AMADNG Info/Control Flowset v3.9.76
+ false
+ PARALLEL
+
+ App Task Beendet: ch.gridvision.ppam.androidautomagic
+
+ AMAD Voice Control
+ Flows löschen: First Run Assistant
+ AMAD Voice Control
+ AMAD Voice Control
+ Flows löschen: First Run Assistant
+ Sprachausgabe: In Ordnung. Der Einrichtungs Assistent bleibt erhalten. Auf Wiedersehen.
+ Abfrage
+ Script: amadcmd = "firstrun"
+ Script: amaddevice_ip = {value}
+ Eingabedialog: Android Device IP Adresse Einzeiliger Text Bitte gebe die IP Adresse Deines Androidgerätes an. NUR IP kein FQDN!!!
+ Script: global_fhemip = {value}
+ Eingabedialog: FHEM Server IP Einzeiliger Text Bitte gebe die IP Adresse oder den FQDN Deines FHEM Servers an.
+ Script: global_fhemdevice = {value}
+ Eingabedialog: FHEM Devicename Einzeiliger Text Wie soll das Device in FHEM heißen?
+ Script: global_bridgeport = {value}
+ Eingabedialog: AMADCommBridge Port Einzeiliger Text Bitte gebe den Port der AMADCommBridge vom FHEM Server an.
+ Sprachausgabe: Du möchtest also nicht fortfahren. Das ist schade. Bitte bedenke das dieses Android Gerät somit nicht als Amaad Device in Fhem angelegt ist. Du kannst jeder Zeit den Assistenten Flow neu aktivieren und von vorn beginnen.
+Auf Wiedersehen.
+ AMAD Voice Control
+ Medienlautstärke Wiederherstellen
+ Lautstärke einstellen: Medien auf Level 8
+ Medianlautstärken Speichern
+ Setze Flow Status: Aktivieren Informations
+ Setze Flow Status: Aktivieren SetCommands,Update AMAD Flowset,VoiceControl
+ Pause: 2s (Gerät wach halten)
+ Script: readingsvalcmd = "{global_fhemdevice} deviceState kaputt"; fhemcmd = "readingsval"; respfirstrun = "none";
+ Expression: value != ""
+ Sprachausgabe: Oh das tut mir leid, da scheine ich Dich nicht verstanden zu haben. Bitte versuche es mit etwas Ruhe im Hintergrund noch einmal.
+ Expression: value == "nein"
+ Expression: value == "ja"
+ Expression: value == "ja"
+ Sprachausgabe: In Ordnung. Der Einrichtungs Assistent wird gelöscht. Auf Wiedersehen.
+ Sprachausgabe: Oh das tut mir leid, da scheine ich Dich nicht verstanden zu haben. Bitte versuche es mit etwas Ruhe im Hintergrund noch einmal.
+ Expression: value != ""
+ Expression: value == "nein"
+ Expression: value != ""
+ Sprachausgabe: Oh das tut mir leid, da scheine ich Dich nicht verstanden zu haben. Bitte versuche es mit etwas Ruhe im Hintergrund noch einmal.
+ Expression: value == "nein"
+ Expression: value == "ja"
+ Flows löschen: First Run Assistant
+ Sprachausgabe: In Ordnung. Der Einrichtungs Assistent wird gelöscht. Auf Wiedersehen.
+ Sprachausgabe: In Ordnung. Der Einrichtungs Assistent bleibt erhalten. Auf Wiedersehen.
+ Expression: value != ""
+ Sprachausgabe: Oh das tut mir leid, da scheine ich Dich nicht verstanden zu haben. Bitte versuche es mit etwas Ruhe im Hintergrund noch einmal.
+ Sprachausgabe: In Ordnung. Der Einrichtungs Assistent wird gelöscht. Auf Wiedersehen.
+ Sprachausgabe: In Ordnung. Der Einrichtungs Assistent bleibt erhalten. Auf Wiedersehen.
+ Expression: value == "ja"
+ Expression: value == "nein"
+ Script: if(index == 0) { sprachassi = "ja"; } else { sprachassi = "nein"; }
+ AMAD First Run Assistent Begrüßung
+ Eingabedialog: Wünschst Du einen sprachgestützten oder dialoggestützten Installationsassistanten? Einfachauswahl Menü Sprache,Dialog (15s)
+ Script: global_amadid = getDate();
+ Setze Flow Status: Deaktivieren First Run Assistant
+ Setze Flow Status: Aktivieren Send Data to AMADCommBridge
+ Script: global_activetask = "none"; global_apssid = "none"; global_userflowstate = "none";
+ Sprachausgabe: Wunderbar. Bitte nimm Dir Zeit und lese Dir die Hilfe Dialoge genau durch. Wenn Du Dir unsicher bist, kannst Du die Standardeinstellung, sofern vorhanden, belassen. Lass uns nun mit der Einrichtung beginnen.
+ Meldungsdialog: Wunderbar. Bitte nimm Dir Zeit und lese Dir die Hilfe Dialoge genau durch. Wenn Du Dir unsicher bist, kannst Du die Standardeinstellung, sofern vorhanden, belassen. Lass uns nun mit der Einrichtung beginnen.
+ Expression: sprachassi == "ja"
+ Flows ausführen: Send Data to AMADCommBridge
+ Sprachausgabe: Alle Informationen wurden nun erfasst und zur Amaad Comm Bridge gesendet. Ich werde gleich einmal prüfen ob die Einrichtung des Devices in Fhem gelungen ist. Gib mir bitte bis zu einer Minute Zeit für die Prüfung.
+ Expression: sprachassi == "ja"
+ Meldungsdialog: Alle Informationen wurden nun erfasst und zur Amaad Comm Bridge gesendet. Ich werde gleich einmal prüfen ob die Einrichtung des Devices in Fhem gelungen ist. Gib mir bitte bis zu einer Minute Zeit für die Prüfung.
+ Expression: respreadingsval != "kaputt" and respreadingsval != "none"
+ Expression: sprachassi == "ja"
+ Sprachausgabe: Leider scheint es ein Problem beim einrichten des Fhem Devices gegeben zu haben. Hast Du die Amaad Comm Bridge definiert? Und ist sie auch aktiv? Sollte es weiterhin Probleme geben, wende Dich bitte an Cooltux alias Leon, im Fhem Forum.
+Soll der Assistent gelöscht werden?
+ Meldungsdialog: Leider scheint es ein Problem beim Einrichten des FHEM Devices gegeben zu haben. Hast Du die AMADCommBridge definiert, und ist sie auch aktiv? Sollte es weiterhin Probleme geben, wende Dich bitte an CoolTux alias Leon, im FHEM Forum.
+ Expression: sprachassi == "ja"
+ Sprachausgabe: Die Einrichtung ist nun abgeschlossen und das Amaad Device wurde angelegt. Es scheint aber noch keine Verbindung zwischen Fhem und Deinem Amaad Device zu bestehen. Mache am besten einmal ein Status Request in Fhem für das Amaad Device. Ist der Status in Fhem weiterhin offline schaue bitte ob alle Amaad, Flows aktiv sind.
+Soll der Assistent gelöscht werden?
+ Meldungsdialog: Die Einrichtung ist nun abgeschlossen und das Amaad Device wurde angelegt. Es scheint aber noch keine Verbindung zwischen Fhem und Deinem Amaad Device zu bestehen. Mache am besten einmal ein Status Request in Fhem für das Amaad Device. Ist der Status in Fhem weiterhin offline schaue bitte ob alle Am
+ Expression: respreadingsval == "online"
+ Sprachausgabe: Die Einrichtung ist nun abgeschlossen und das Amaad Device online.
+Soll der Assistent gelöscht werden?
+ Expression: sprachassi == "ja"
+ Meldungsdialog: Wunderbar. Bitte nimm Dir Zeit und lese Dir die Hilfe Dialoge genau durch. Wenn Du Dir unsicher bist, kannst Du die Standardeinstellung, sofern vorhanden, belassen. Lass uns nun mit der Einrichtung beginnen.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Informations
- AMAD2 Info/Control Flowset v2.6.12
- true
+ AMADNG Info/Control Flowset v3.9.76
+ false
QUEUE
900
-
+ Script: daydream_state = "on"
+ Script: daydream_state = "off"
+ Script: keyguard = "unlocked"
+ Display Orientierung: Portrait
+ Script: screen_orientation = "portrait"
+ Script: screen_orientation = "landscape"
+ Script: dock_state = "docked"
+ Script: dock_state = "undocked"
+ Script: keyguardSet = "0"
+ Script: screen_orientation_mode = "manual"
+ Script: scrcount = 0
+ Script: keyguard = "locked"
+ Expression: scrcount < 5
+ Script: scrcount = scrcount + 1
+ Pause: 2s (Gerät wach halten)
+ Dock Status: Docked
+ Display automatisch drehen eingeschaltet
+ Expression: trigger == "Daydream Status: Gestartet"
+ Bluetooth eingeschaltet
+ Expression: trigger == "App Task Beendet"
+ Keyguard gesperrt
+ Expression: keyguard == "locked"
+ Expression: getAndroidSDKVersion() >= "16"
+ Script: keyguardSet = "not supported from your device"
+ Display eingeschaltet
+ Display eingeschaltet
+ Expression: getAndroidSDKVersion() >= "16"
+ Unterbrechnungen-Modus: Nur Wecker (Android 6+)
+ Unterbrechnungen-Modus: Keine / Nicht unterbrechen
+ Unterbrechnungen-Modus: Wichtig / Nur wichtige Unterbrechnungen zulassen
+ Unterbrechnungen-Modus: Alle / Immer unterbrechen
+ Script: dndValue = "always"
+ Script: dndValue = "onlyImportant"
+ Script: dndValue = "never"
+ Script: dndValue = "alarmClockOnly"
+ Script: screen_state = "on"
+ Script: screen_state = "off"
+ Script: screen_state = "on {keyguard}"
+ Script: screen_state = "off {keyguard}"
+ Script: airplanemode = "off"
+ Script: bluetooth_state = "on"
+ Script: androidVersion = "not supported funktion"
+ App Task läuft: {global_activetask} (neuster)
+ Script: runTask = "1"
+ Script: runTask = "0"
+ Expression: getAndroidSDKVersion() >= "19"
+ Script: runTask = "not supported android version"
+ Script: runTask = "null"
+ Expression: trigger == "Periodischer Timer: alle 120s"
+ Expression: global_activetask != null
+ Expression: trigger == "Display Status: Aus" or trigger == "Display Status: Ein" or udef_trigger == "setLockPin" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
+ Expression: trigger == "Daydream Status: Gestartet" or trigger == "Daydream Status: Gestoppt"
+ Expression: trigger == "Display Orientierung: Landscape" or trigger == "Display Orientierung: Portrait" or trigger == "Display Status: Ein" or trigger == "Display Status: Aus" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
+ Expression: trigger == "Akku Ladestand: grösser als 0%"
+ Stromversorgung: Angeschlossen
+ Script: screen_orientation_mode = "auto"
+ Script: bluetooth_state = "off"
+ Script: if(trigger == "Genereller Broadcast: wenn com.android.deskclock.ALARM_ALERT") { nextalarmstate = "alert" } if(trigger == "Genereller Broadcast: wenn com.android.deskclock.ALARM_DISMISS") { nextalarmstate = "dismiss" } if(trigger == "Genereller Broadcast: wenn com.android.deskclock.ALARM_DONE") { nextalarmstate = "done" } if(trigger == "Genereller Broadcast: wenn com.android.deskclock.ALARM_SNOOZE") { nextalarmstate = "snooze" }
+ Keyguard mit Sicherheit
+ Script: keyguardSet = "1"
+ Expression: udef_trigger == "setLockPin" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
+ Expression: trigger == "Eingehender Anruf. Status: Klingelt, Nummern: Alle"
+ Expression: trigger == "Flugmodus: Aus" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
+ Expression: trigger == "Systemeinstellung verändert: System screen_brightness"
+ Bluetooth Gerät verbunden: Beliebiges Geräte (Advanced Audio Distribution)
+ Script: volume = {volumeBT}
+ Pause: 2s (Gerät wach halten)
+ Musik Aktiv
+ Benachrichtigung auf Bildschirm: [AMAD2] Nicht mehr benötigte AMAD Flows wurden entfernt! (lange)
+ Expression: trigger == "Systemeinstellung verändert: System volume_music_bt_a2dp" or trigger == "Systemeinstellung verändert: System volume_music_speaker" or trigger == "Systemeinstellung verändert: System volume_music_headphone" or trigger == "Systemeinstellung verändert: System volume_music_headset"
+ Initialisiere Variable Systemeinstellung: volumeMusikBluetooth.2
+ Script: volume = {volumeSP}
+ Initialisiere Variable Systemeinstellung: volumeMusikSpeaker.2
+ Expression: trigger == "Unterbrechnungen-Modus: Alle / Immer unterbrechen" or trigger == "Unterbrechnungen-Modus: Keine / Nicht unterbrechen" or trigger == "Unterbrechnungen-Modus: Nur Wecker (Android 6+)" or trigger == "Unterbrechnungen-Modus: Wichtig / Nur wichtige Unterbrechnungen zulassen" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
+ Expression: getAndroidSDKVersion() >= "21"
+ Script: airpcount = 0
+ Host erreichbar: {global_fhemip}:{global_bridgeport}
+ WLAN Reassoziieren
+ Expression: trigger == "Genereller Broadcast: wenn com.android.deskclock.ALARM_ALERT" or trigger == "Genereller Broadcast: wenn com.android.deskclock.ALARM_DISMISS" or trigger == "Genereller Broadcast: wenn com.android.deskclock.ALARM_DONE" or trigger == "Genereller Broadcast: wenn com.android.deskclock.ALARM_SNOOZE" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
+ Expression: trigger == "Systemeinstellung verändert: System next_alarm" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
+ Initialisiere Variable Nächster Alarm: next_alarm
+ Script: next_alarmday = "{next_alarm,dateformat,c}"
+ Script: next_alarmtime = "{next_alarm,dateformat,HH:mm}"
+ Expression: global_fhemip != null or global_bridgeport != null
+ Expression: getAndroidSDKVersion() >= "19"
+ Script: notification_text = "Aktiviere Automagic unter Einstellungen -> Benachrichtigungen -> Benachrichtigungszugriff"
+ Script: notification_text = "not supported from your device"
+ Expression: getAndroidSDKVersion() >= "19"
+ Script: notification_text = "Aktiviere Automagic unter Einstellungen -> Benachrichtigungen -> Benachrichtigungszugriff"
+ Expression: trigger == "Genereller Broadcast: wenn org.smblott.intentradio.STATE"
+ Expression: trigger == "Benachrichtigung in Statusbar angezeigt: com.whatsapp"
+ Benachrichtigung in Statusbar angezeigt: WhatsApp
+ Script: notification_text = "not supported from your device"
+ Expression: trigger == "Benachrichtigung in Statusbar angezeigt: org.telegram.messenger"
+ Initialisiere Variable Systemeinstellung: screenBrightness
+ Expression: trigger == "HTTP Request: /fhem-amad/deviceInfo/"
+ Expression: trigger == "Systemeinstellung verändert: System volume_ring_speaker"
+ Initialisiere Variable Systemeinstellung: volumeNotification
+ Expression: trigger == "Systemeinstellung verändert: System volume_ring"
+ Initialisiere Variable Systemeinstellung: volumeRingSound
+ Expression: trigger == "Medien Session verändert" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
+ Get Android Version
+ WLAN verfügbar: {global_apssid}
+ Script: volumeRingSound = "\"volumeRingSound\":" + " \"" + {volumeRingSound} + "\""; fhemcmd = "setreading";
+ Script: intentRadioState = "\"intentRadioState\":" + " \"" + {irstate} + "\"" + "," + "\"intentRadioName\":" + " \"" + {irname} + "\""; fhemcmd = "setreading";
+ Script: keyguardSet = "\"keyguardSet\":" + " \"" + {keyguardSet} + "\""; fhemcmd = "setreading";
+ Script: dockingState = "\"dockingState\":" + " \"" + {dock_state} + "\""; fhemcmd = "setreading";
+ Script: screenOrientation = "\"screenOrientation\":" + " \"" + {screen_orientation} + "\"" + "," + "\"screenOrientationMode\":" + " \"" + {screen_orientation_mode} + "\""; fhemcmd = "setreading";
+ Script: screenBrightness = "\"screenBrightness\":" + " \"" + {screenBrightness} + "\""; fhemcmd = "setreading";
+ Script: daydream = "\"daydream\":" + " \"" + {daydream_state} + "\""; fhemcmd = "setreading";
+ Script: nextAlarm = "\"nextAlarmTime\":" + " \"" + {next_alarmtime} + "\"" + "," + "\"nextAlarmDay\":" + " \"" + {next_alarmday} + "\""; fhemcmd = "setreading";
+ Script: volumevalue = "\"volume\":" + " \"" + {volume} + "\""; fhemcmd = "setreading";
+ Script: volumeNotification = "\"volumeNotification\":" + " \"" + {volumeNotification} + "\""; fhemcmd = "setreading";
+ Script: airplanemode = "\"airplanemode\":" + " \"" + {airplanemode} + "\""; fhemcmd = "setreading";
+ Script: screen = "\"screen\":" + " \"" + {screen_state} + "\""; fhemcmd = "setreading";
+ Script: nextAlarmState = "\"nextAlarmState\":" + " \"" + {nextalarmstate} + "\""; fhemcmd = "setreading";
+ Script: doNotDisturb = "\"doNotDisturb\":" + " \"" + {dndValue} + "\""; fhemcmd = "setreading";
+ Script: checkActiveTask = "\"checkActiveTask\":" + " \"" + {runTask} + "\""; fhemcmd = "setreading";
+ Expression: Leon == "Gaultier"
+ Flows löschen: MultimediaControl
+ Script: androidVersion = "\"androidVersion\":" + " \"" + {androidVersion} + "\""; fhemcmd = "setreading";
+ Script: powerinfo = "\"powerLevel\":" + " \"" + "{battery_percentage,numberformat,0}" + "\"" + "," + "\"powerPlugged\":" + " \"" + {battery_plugged} + "\"" + "," + "\"batteryTemperature\":" + " \"" + "{battery_temperature/10.0,numberformat.0.0}" + "\"" + "," + "\"batteryHealth\":" + " \"" + {battery_health} + "\""; fhemcmd = "setreading";
+ Expression: trigger == "Benachrichtigung in Statusbar angezeigt: ch.gridvision.ppam.androidautomagic" or trigger == "Benachrichtigung in Statusbar entfernt: ch.gridvision.ppam.androidautomagic" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
+ Expression: getAndroidSDKVersion() >= "19"
+ Script: notification_text = "Aktiviere Automagic unter Einstellungen -> Benachrichtigungen -> Benachrichtigungszugriff"
+ Benachrichtigung in Statusbar angezeigt: Automagic
+ Expression: package_name == {global_activetask}
+ Script: deviceState = "\"deviceState\": \"online\""; fhemcmd = "setreading";
+ Expression: trigger == "Dock Event: Docked" or trigger == "Dock Event: Undocked" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
+ Expression: trigger == "Periodischer Timer: alle 120s" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
+ Flows ausführen: Send Data to AMADCommBridge
+ Prüfe und setze globale Variable
+ Script: bluetooth = "\"bluetooth\":" + " \"" + {bluetooth_state} + "\""; fhemcmd = "setreading";
+ Script: connected_devices_names = "none"; connected_devices_addresses = "none"
+ Script: btdeviceinfo = "\"connectedBTdevices\":" + " \"" + {connected_devices_names} + "\"" + "," + "\"connectedBTdevicesMAC\":" + " \"" + {connected_devices_addresses} + "\""; fhemcmd = "setreading";
+ Bluetooth Gerät verbunden: Beliebiges Geräte
+ Expression: trigger == "Bluetooth Status: Schaltet aus, Aus" or trigger == "Bluetooth Gerät verbunden: Alle Geräte" or trigger == "Bluetooth Gerät getrennt: Alle Geräte" or trigger == "Bluetooth Status: Schaltet ein, Ein" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
+ Host erreichbar: {global_fhemip}:{global_bridgeport}
+ Script: flow_SetCommands = "\"flow_SetCommands\":" + " \"" + {setCommandFlow_state} + "\""; fhemcmd = "setreading";
+ Setze Flow Status: Aktivieren SetCommands
+ Script: setCommandFlow_state = "aktiv"
+ Script: setCommandFlow_state = "inaktiv"
+ Flow Aktiv: SetCommands
+ Expression: trigger == "Periodischer Timer: alle 120s"
+ Expression: global_userflowstate != "none"
+ Flow Aktiv: {global_userflowstate}
+ Script: flowState = "inactive"
+ Script: flowState = "active"
+ Script: flow_informations = "\"userFlowState\":" + " \"" + {flowState} + "\""; fhemcmd = "setreading";
+ Expression: trigger == "Periodischer Timer: alle 120s" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
+ Flow Aktiv: Send Data to AMADCommBridge
+ Setze Flow Status: Aktivieren Send Data to AMADCommBridge
+ Expression: trigger == "Periodischer Timer: alle 120s"
+ Script: incomingCaller = "\"incomingCallerName\":" + " \"" + {contact_name} + "\"" + "," + "\"incomingCallerNumber\":" + " \"" + {incoming_number} + "\""; fhemcmd = "setreading";
+ Script: incommingWhatsAppMessage = "\"incommingWhatsAppMessageFrom\":" + " \"" + replaceAll({notification_text}, "\\n", " ") + "\""; fhemcmd = "setreading";
+ Script: automagicState = "\"automagicState\":" + " \"" + replaceAll({notification_text}, "\\n", " ") + "\""; fhemcmd = "setreading";
+ Script: incommingTelegramMessage = "\"incommingTelegramMessageFrom\":" + " \"" + replaceAll({notification_text}, "\\n", " ") + "\""; fhemcmd = "setreading";
+ Benachrichtigung in Statusbar angezeigt: Telegram Messenger
+ Pause: 2s (Gerät wach halten)
+ Script: airpcount = airpcount + 1
+ Expression: airpcount < 11
+ Script: notification_text = "not supported from your device"
+
Genereller Broadcast: wenn com.android.deskclock.ALARM_DONE
Genereller Broadcast: wenn org.smblott.intentradio.STATE
Systemeinstellung verändert: System volume_music_headphone
@@ -2865,469 +3831,356 @@ if(param_mplayer == "mediaAudible")
Benachrichtigung in Statusbar angezeigt: com.whatsapp
Daydream Status: Gestoppt
Benachrichtigung in Statusbar angezeigt: ch.gridvision.ppam.androidautomagic
- Akku Ladestand: grösser als 0%
Eingehender Anruf. Status: Klingelt, Nummern: Alle
Display Status: Ein
Systemeinstellung verändert: System volume_music_speaker
Systemeinstellung verändert: System screen_brightness
Daydream Status: Gestartet
+ Bluetooth Gerät verbunden: Alle Geräte
+ Bluetooth Gerät getrennt: Alle Geräte
Dock Event: Docked
+ Periodischer Timer: alle 120s
Systemeinstellung verändert: System volume_music_bt_a2dp
+ Akku Ladestand: grösser als 0%
Unterbrechnungen-Modus: Alle / Immer unterbrechen
+ App Task Beendet
HTTP Request: /fhem-amad/deviceInfo/
- Periodischer Timer: alle 30s
Genereller Broadcast: wenn com.android.deskclock.ALARM_ALERT
Benachrichtigung in Statusbar angezeigt: org.telegram.messenger
Stromversorgung: Entfernt
Systemeinstellung verändert: System next_alarm
Benachrichtigung in Statusbar entfernt: ch.gridvision.ppam.androidautomagic
- App Task Beendet
Unterbrechnungen-Modus: Keine / Nicht unterbrechen
Dock Event: Undocked
Display Orientierung: Landscape
Unterbrechnungen-Modus: Nur Wecker (Android 6+)
+ Systemeinstellung verändert: System volume_ring
Flugmodus: Aus
Systemeinstellung verändert: System volume_ring_speaker
- Systemeinstellung verändert: System volume_ring
Medien Session verändert
- Script: daydream_state = "on"
- Script: daydream_state = "off"
- Expression: airpcount < 11
- Script: keyguard = "unlocked"
- Display Orientierung: Portrait
- Script: screen_orientation = "portrait"
- Script: screen_orientation = "landscape"
- Script: dock_state = "docked"
- Script: dock_state = "undocked"
- Script: keyguardSet = "0"
- Script: screen_orientation_mode = "manual"
- Script: scrcount = 0
- Script: keyguard = "locked"
- Expression: scrcount < 5
- Script: scrcount = scrcount + 1
- Pause: 2s (Gerät wach halten)
- Script: notification_text = "Aktiviere Automagic unter Einstellungen -> Benachrichtigungen -> Benachrichtigungszugriff"
- Benachrichtigung in Statusbar angezeigt: Automagic
- Script: airpcount = airpcount + 1
- Dock Status: Docked
- Script: notification_text = "not supported from your device"
- Display automatisch drehen eingeschaltet
- Expression: trigger == "Daydream Status: Gestartet"
- Bluetooth eingeschaltet
- Expression: trigger == "App Task Beendet"
- Keyguard gesperrt
- Expression: keyguard == "locked"
- Expression: getAndroidSDKVersion() >= "19"
- Expression: getAndroidSDKVersion() >= "16"
- Script: keyguardSet = "not supported from your device"
- Display eingeschaltet
- Display eingeschaltet
- Expression: getAndroidSDKVersion() >= "16"
- Unterbrechnungen-Modus: Nur Wecker (Android 6+)
- Unterbrechnungen-Modus: Keine / Nicht unterbrechen
- Unterbrechnungen-Modus: Wichtig / Nur wichtige Unterbrechnungen zulassen
- Unterbrechnungen-Modus: Alle / Immer unterbrechen
- Script: dndValue = "always"
- Script: dndValue = "onlyImportant"
- Script: dndValue = "never"
- Script: dndValue = "alarmClockOnly"
- Script: screen_state = "on"
- Script: screen_state = "off"
- Script: screen_state = "on {keyguard}"
- Script: screen_state = "off {keyguard}"
- Script: airplanemode = "off"
- Script: bluetooth_state = "on"
- Script: androidVersion = "not supported funktion"
- Expression: package_name == {global_activetask}
- App Task läuft: {global_activetask} (neuster)
- Script: runTask = "1"
- Script: runTask = "0"
- Expression: getAndroidSDKVersion() >= "19"
- Script: runTask = "not supported android version"
- Script: runTask = "null"
- Expression: trigger == "Periodischer Timer: alle 30s" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
- Expression: trigger == "Periodischer Timer: alle 30s"
- Expression: global_activetask != null
- Expression: trigger == "Display Status: Aus" or trigger == "Display Status: Ein" or udef_trigger == "setLockPin" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
- Expression: trigger == "Daydream Status: Gestartet" or trigger == "Daydream Status: Gestoppt"
- Expression: trigger == "Display Orientierung: Landscape" or trigger == "Display Orientierung: Portrait" or trigger == "Display Status: Ein" or trigger == "Display Status: Aus" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
- Expression: trigger == "Benachrichtigung in Statusbar angezeigt: ch.gridvision.ppam.androidautomagic" or trigger == "Benachrichtigung in Statusbar entfernt: ch.gridvision.ppam.androidautomagic" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
- Expression: trigger == "Dock Event: Docked" or trigger == "Dock Event: Undocked" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
- Expression: trigger == "Akku Ladestand: grösser als 0%"
- Stromversorgung: Angeschlossen
- Script: screen_orientation_mode = "auto"
- Script: screen = "screen@@" + {screen_state}; fhemcmd = "setreading";
- Script: bluetooth = "bluetooth@@" + {bluetooth_state}; fhemcmd = "setreading";
- Script: daydream = "daydream@@" + {daydream_state}; fhemcmd = "setreading";
- Script: automagicState = "automagicState@@" + {notification_text}; fhemcmd = "setreading";
- Script: dockingState = "dockingState@@" + {dock_state}; fhemcmd = "setreading";
- Script: incomingCaller = "incomingCallerName@@" + {contact_name} + "@@@@incomingCallerNumber@@" + {incoming_number}; fhemcmd = "setreading";
- Script: androidVersion = "androidVersion@@" + {androidVersion}; fhemcmd = "setreading";
- Script: checkActiveTask = "checkActiveTask@@" + {runTask}; fhemcmd = "setreading";
- Script: deviceState = "deviceState@@online"; fhemcmd = "setreading";
- Script: bluetooth_state = "off"
- Script: if(trigger == "Genereller Broadcast: wenn com.android.deskclock.ALARM_ALERT") { nextalarmstate = "alert" } if(trigger == "Genereller Broadcast: wenn com.android.deskclock.ALARM_DISMISS") { nextalarmstate = "dismiss" } if(trigger == "Genereller Broadcast: wenn com.android.deskclock.ALARM_DONE") { nextalarmstate = "done" } if(trigger == "Genereller Broadcast: wenn com.android.deskclock.ALARM_SNOOZE") { nextalarmstate = "snooze" }
- Bluetooth Gerät verbunden: Beliebiges Geräte
- Script: btdeviceinfo = "connectedBTdevices@@" + {connected_devices_names} + "@@@@connectedBTdevicesMAC@@" + {connected_devices_addresses}; fhemcmd = "setreading";
- Script: connected_devices_names = "none"; connected_devices_addresses = "none"
- Expression: trigger == "Bluetooth Status: Schaltet aus, Aus" or trigger == "Bluetooth Status: Schaltet ein, Ein" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
- Keyguard mit Sicherheit
- Script: keyguardSet = "1"
- Script: keyguardSet = "keyguardSet@@" + {keyguardSet}; fhemcmd = "setreading";
- Expression: udef_trigger == "setLockPin" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
- Expression: trigger == "Eingehender Anruf. Status: Klingelt, Nummern: Alle"
- Expression: trigger == "Flugmodus: Aus" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
- Script: screenBrightness = "screenBrightness@@" + {screenBrightness}; fhemcmd = "setreading";
- Expression: trigger == "Systemeinstellung verändert: System screen_brightness"
- Bluetooth Gerät verbunden: Beliebiges Geräte (Advanced Audio Distribution)
- Script: volumevalue = "volume@@" + {volume}; fhemcmd = "setreading";
- Script: volume = {volumeBT}
- Script: screenOrientation = "screenOrientation@@" + {screen_orientation} + "@@@@screenOrientationMode@@" + {screen_orientation_mode}; fhemcmd = "setreading";
- Script: powerinfo = "powerLevel@@" + "{battery_percentage,numberformat,0}" + "@@@@powerPlugged@@" + {battery_plugged} + "@@@@batteryTemperature@@" + "{battery_temperature/10.0,numberformat.0.0}" + "@@@@batteryHealth@@" + {battery_health}; fhemcmd = "setreading";
- Pause: 2s (Gerät wach halten)
- Musik Aktiv
- Script: currentMusic = "currentMusicTrack@@" + {title} + "@@@@currentMusicAlbum@@" + {description} + "@@@@currentMusicArtist@@" + {subtitle} + "@@@@currentMusicApp@@" + {musicapp} + "@@@@currentMusicIcon@@" + {icon} + "@@@@currentMusicState@@" + {playback_state}; fhemcmd = "setreading";
- Script: airplanemode = "airplanemode@@" + {airplanemode}; fhemcmd = "setreading";
- Benachrichtigung auf Bildschirm: [AMAD2] Nicht mehr benötigte AMAD Flows wurden entfernt! (lange)
- Expression: trigger == "Systemeinstellung verändert: System volume_music_bt_a2dp" or trigger == "Systemeinstellung verändert: System volume_music_speaker" or trigger == "Systemeinstellung verändert: System volume_music_headphone" or trigger == "Systemeinstellung verändert: System volume_music_headset"
- Initialisiere Variable Systemeinstellung: volumeMusikBluetooth.2
- Script: volume = {volumeSP}
- Initialisiere Variable Systemeinstellung: volumeMusikSpeaker.2
- Expression: trigger == "Unterbrechnungen-Modus: Alle / Immer unterbrechen" or trigger == "Unterbrechnungen-Modus: Keine / Nicht unterbrechen" or trigger == "Unterbrechnungen-Modus: Nur Wecker (Android 6+)" or trigger == "Unterbrechnungen-Modus: Wichtig / Nur wichtige Unterbrechnungen zulassen" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
- Expression: getAndroidSDKVersion() >= "21"
- Flow Aktiv: SetCommands
- Script: setCommandFlow_state = "aktiv"
- Script: setCommandFlow_state = "inaktiv"
- Setze Flow Status: Aktivieren SetCommands
- Script: flow_SetCommands = "flow_SetCommands@@" + {setCommandFlow_state}; fhemcmd = "setreading";
- Script: flowState = "active"
- Script: flow_informations = "userFlowState@@" + {flowState}; fhemcmd = "setreading";
- Expression: global_userflowstate != "none"
- Flow Aktiv: {global_userflowstate}
- Expression: trigger == "Periodischer Timer: alle 30s" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
- Expression: trigger == "Periodischer Timer: alle 30s"
- Script: flowState = "inactive"
- Expression: Leon == "Gaultier"
- Flows löschen: MultimediaControl
- Script: airpcount = 0
- Host erreichbar: {global_fhemip}:{global_bridgeport}
- Pause: 2s (Gerät wach halten)
- WLAN verfügbar: {global_apssid}
- WLAN Reassoziieren
- Expression: trigger == "Genereller Broadcast: wenn com.android.deskclock.ALARM_ALERT" or trigger == "Genereller Broadcast: wenn com.android.deskclock.ALARM_DISMISS" or trigger == "Genereller Broadcast: wenn com.android.deskclock.ALARM_DONE" or trigger == "Genereller Broadcast: wenn com.android.deskclock.ALARM_SNOOZE" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
- Expression: trigger == "Systemeinstellung verändert: System next_alarm" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
- Initialisiere Variable Nächster Alarm: next_alarm
- Script: next_alarmday = "{next_alarm,dateformat,c}"
- Script: next_alarmtime = "{next_alarm,dateformat,HH:mm}"
- Script: nextAlarm = "nextAlarmTime@@" + {next_alarmtime} + "@@@@nextAlarmDay@@" + {next_alarmday}; fhemcmd = "setreading";
- Prüfe und setze globale Variablen
- Expression: global_fhemip != null or global_bridgeport != null
- Flows ausführen: Send Data to AMADCommBridge
- Script: nextAlarmState = "nextAlarmState@@" + {nextalarmstate}; fhemcmd = "setreading";
- Script: doNotDisturb = "doNotDisturb@@" + {dndValue}; fhemcmd = "setreading";
- Expression: getAndroidSDKVersion() >= "19"
- Script: notification_text = "Aktiviere Automagic unter Einstellungen -> Benachrichtigungen -> Benachrichtigungszugriff"
- Script: notification_text = "not supported from your device"
- Script: incommingWhatsAppMessage = "incommingWhatsAppMessageFrom@@" + {notification_text}; fhemcmd = "setreading";
- Expression: getAndroidSDKVersion() >= "19"
- Script: notification_text = "Aktiviere Automagic unter Einstellungen -> Benachrichtigungen -> Benachrichtigungszugriff"
- Script: intentRadioState = "intentRadioState@@" + {irstate} + "@@@@intentRadioName@@" + {irname}; fhemcmd = "setreading";
- Expression: trigger == "Genereller Broadcast: wenn org.smblott.intentradio.STATE"
- Expression: trigger == "Benachrichtigung in Statusbar angezeigt: com.whatsapp"
- Benachrichtigung in Statusbar angezeigt: WhatsApp
- Script: notification_text = "not supported from your device"
- Benachrichtigung in Statusbar angezeigt: Telegram Messenger
- Script: incommingTelegramMessage = "incommingTelegramMessageFrom@@" + {notification_text}; fhemcmd = "setreading";
- Script: volumeNotification = "volumeNotification@@" + {volumeNotification}; fhemcmd = "setreading";
- Host erreichbar: {global_fhemip}:{global_bridgeport}
- Expression: trigger == "Benachrichtigung in Statusbar angezeigt: org.telegram.messenger"
- Initialisiere Variable Systemeinstellung: screenBrightness
- Expression: trigger == "HTTP Request: /fhem-amad/deviceInfo/"
- Expression: trigger == "Systemeinstellung verändert: System volume_ring_speaker"
- Initialisiere Variable Systemeinstellung: volumeNotification
- Expression: trigger == "Systemeinstellung verändert: System volume_ring"
- Script: volumeRingSound = "volumeRingSound@@" + {volumeRingSound}; fhemcmd = "setreading";
- Initialisiere Variable Systemeinstellung: volumeRingSound
- Script: subtitle = "no player active"; title = "no player active"; description = "no player active"; musicapp = "no player active"; icon = "no player active"
- Script: if(playback_state == 0) { playback_state = "keiner" } if(playback_state == 1) { playback_state = "gestoppt" } if(playback_state == 2) { playback_state = "pausiert" } if(playback_state == 3) { playback_state = "spielt ab" } if(playback_state == 4) { playback_state = "spult vorwärts" } if(playback_state == 5) { playback_state = "spült rückwärts" } if(playback_state == 6) { playback_state = "buffert" } if(playback_state == 7) { playback_state = "Fehler" } if(playback_state == 8) { playback_state = "verbindet" } if(playback_state == 9) { playback_state = "springt zum vorherigen" } if(playback_state == 10) { playback_state = "springt zum nächsten" } if(playback_state == 11) { playback_state = "springt zu Position in Wiedergabeliste" }
- Expression: trigger == "Medien Session verändert" or trigger == "HTTP Request: /fhem-amad/deviceInfo/"
- Script: if(package_name == "com.google.android.music") { musicapp = "Google Musik" } if(package_name == "com.amazon.mp3") { musicapp = "Amazon Musik" } if(package_name == "com.google.android.videos") { musicapp = "Google Video" } if(package_name == "com.spotify.music") { musicapp = "Spotify Musik" } if(package_name == "com.google.android.youtube") { musicapp = "YouTube" } if(package_name == "tunein.player") { musicapp = "TuneIn Player" } if(package_name == "com.rhapsody.alditalk") { musicapp = "Aldi Life Musik" } if(package_name == "org.videolan.vlc") { musicapp = "VLC Player" }
- Get Android Version
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ Script: subtitle = "no player active"; title = "no player active"; description = "no player active"; musicapp = "no player active"; icon = "no player active"
+ Script: if(playback_state == 0) { playback_state = "keiner" } if(playback_state == 1) { playback_state = "gestoppt" } if(playback_state == 2) { playback_state = "pausiert" } if(playback_state == 3) { playback_state = "spielt ab" } if(playback_state == 4) { playback_state = "spult vorwärts" } if(playback_state == 5) { playback_state = "spült rückwärts" } if(playback_state == 6) { playback_state = "buffert" } if(playback_state == 7) { playback_state = "Fehler" } if(playback_state == 8) { playback_state = "verbindet" } if(playback_state == 9) { playback_state = "springt zum vorherigen" } if(playback_state == 10) { playback_state = "springt zum nächsten" } if(playback_state == 11) { playback_state = "springt zu Position in Wiedergabeliste" }
+ Script: currentMusic = "\"currentMusicTrack\":" + " \"" + {title} + "\"" + "," + "\"currentMusicAlbum\":" + " \"" + {description} + "\"" + "," + "\"currentMusicArtist\":" + " \"" + {subtitle} + "\"" + "," + "\"currentMusicApp\":" + " \"" + {musicapp} + "\"" + "," + "\"currentMusicIcon\":" + " \"" + {icon} + "\"" + "," + "\"currentMusicState\":" + " \"" + {playback_state} + "\""; fhemcmd = "setreading";
+ Script: if(package_name == "com.google.android.music") { musicapp = "Google Musik" } if(package_name == "com.amazon.mp3") { musicapp = "Amazon Musik" } if(package_name == "com.google.android.videos") { musicapp = "Google Video" } if(package_name == "com.spotify.music") { musicapp = "Spotify Musik" } if(package_name == "com.google.android.youtube") { musicapp = "YouTube" } if(package_name == "tunein.player") { musicapp = "TuneIn Player" } if(package_name == "com.rhapsody.alditalk") { musicapp = "Aldi Life Musik" } if(package_name == "org.videolan.vlc") { musicapp = "VLC Player" } if(package_name == "com.sec.android.app.music") { musicapp = "Samsung Music Player" }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Send Data to AMADCommBridge
- AMAD2 Info/Control Flowset v2.6.12
+ AMADNG Info/Control Flowset v3.9.76
true
PARALLEL
900
-
- HTTP Request: send VOICEINPUTVALUE data to AMADCommBridge
- HTTP Request: send SET data to AMADCommBridge
- Benachrichtigung auf Bildschirm: {response} (lange)
- HTTP Request: send READINGS data to AMADCommBridge
- Expression: fhemcmd == "set"
- Expression: fhemcmd == "voiceinputvalue"
- Host erreichbar: {global_fhemip}:{global_bridgeport}
+
+ WLAN Getrennt: toGo
+ WLAN Verbunden: toGo
+
+ Expression: fhemcmd == "set"
+ Expression: fhemcmd == "voiceinputvalue"
+ Expression: amadcmd == "firstrun"
+ Expression: fhemcmd == "readingsval"
+ Script: Set FHEMSETCMD JSON
+ Script: Set FHEMVOICEINPUTDATA JSON
+ Script: Set FHEMREADINGSVALCMD JSON
Expression: fhemcmd == "setreading"
- Expression: fhemcmd == "readingsval"
- HTTP Request: send READINGSVAL data to AMADCommBridge
- Script: Set FHEMDATA
-
-
-
-
-
-
-
-
-
-
+ Script: Set FHEMDATA JSON First Run Assistant
+ Host erreichbar: {global_fhemip}:{global_bridgeport}
+ In Datei Schreiben: Deaktiviere Flows in /storage/emulated/0/file.txt (anhängen)
+ Setze Flow Status: Deaktivieren Informations,SetCommands
+ Flow Aktiv: Informations
+ Flow Aktiv: SetCommands
+ Expression: trigger == "WLAN Getrennt: toGo"
+ Expression: togocount < 6
+ Pause: 1s (Gerät wach halten)
+ Setze Flow Status: Aktivieren Informations,SetCommands
+ Flow Aktiv: Informations
+ Flow Aktiv: SetCommands
+ Expression: trigger == "WLAN Verbunden: toGo"
+ In Datei Schreiben: Aktiviere Flows in /storage/emulated/0/file.txt (anhängen)
+ HTTP Request: send FIRSTRUN data to AMADCommBridge JSON
+ HTTP Request: send READINGS data to AMADCommBridge JSON
+ HTTP Request: send SET data to AMADCommBridge JSON
+ HTTP Request: send READINGSVAL data to AMADCommBridge JSON
+ HTTP Request: send VOICEINPUTVALUE data to AMADCommBridge
+ Script: if(togocount > 0) { togocount = togocount + 1; } else { togocount = 0; togocount = togocount + 1; }
+ Script: Set FHEMDATA JSON
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
SetCommands
- AMAD2 Info/Control Flowset v2.6.12
- true
+ AMADNG Info/Control Flowset v3.9.76
+ false
QUEUE
900
- Periodischer Timer: alle 30s
HTTP Request: /fhem-amad/deviceInfo/
Sprachbefehl angefordert
HTTP Request: /fhem-amad/setCommands/*
+ Periodischer Timer: alle 120s
Expression: setBrightness"
Expression: setScreenFullscreen"
@@ -3364,135 +4217,137 @@ if(param_mplayer == "mediaAudible")
Setze Display Helligkeit: {param_brightness}
Expression: setScreenlock"
Expression: sendIntent"
- Setze Flow Status: Aktivieren Informations
- Expression: param_lockmod == "lock"
- Setze Lock PIN/Passwort: PIN/Passwort zurücksetzen
- Setze Lock PIN/Passwort: Setze PIN von Variable param_lockpin
- Expression: trigger == "Sprachbefehl angefordert"
- Expression: setAlarm"
- Setze Timer
- Expression: screenMsg"
- Benachrichtigung auf Bildschirm: {param_message} (lange)
- Script: udef_trigger = "setLockPin"
- Flows ausführen: udef_trigger setLockPin
- Display eingeschaltet
- Gerät sperren
- Schalte Display ein
- Gerät sperren
- Expression: setTimer"
- Expression: param_option
- Pause: {param_hanguptime}s (Gerät wach halten)
- Anruf beenden
- Broadcast senden: {param_action}
- URL in Browser öffnen: {param_url} (mit {param_browserapp}/{param_browserappclass})
- Setze Unterbrechnungen-Modus: Alle / Immer unterbrechen
- Setze Unterbrechnungen-Modus: Wichtig / Nur wichtige Unterbrechnungen zulassen
- Setze Unterbrechnungen-Modus: Keine / Nicht unterbrechen
- Setze Unterbrechnungen-Modus: Nur Wecker (Android 6+)
- Expression: openURL"
- Expression: param_fullscreen == "on"
- Expression: do not Disturb"
- Expression: param_disturbmod == "always"
- Expression: param_disturbmod == "onlyImportant"
- Expression: param_disturbmod == "never"
- Expression: param_disturbmod == "alarmClockOnly"
- Flows ausführen: VoiceControl
- Flows ausführen: Send Data to AMADCommBridge
- Expression: setBluetooth"
- Flow Aktiv: Informations
- Script: informationFlow_state = "aktiv"
- Script: informationFlow_state = "inaktiv"
- Script: flow_informations = "flow_informations@@" + {informationFlow_state}; fhemcmd = "setreading";
- Host erreichbar: {global_fhemip}:{global_bridgeport}
- Sprachausgabe: Deutsch
- Expression: ttsMsg"
- Expression: param_screen=="on"
- Expression: setScreenOnOff"
- Gerät sperren
- Expression: param_screen=="off"
- Expression: openApp"
- App Task läuft: App (neuster)
- Expression: setVolume"
- App Starten: App
- Dateien löschen: /storage/emulated/0/Download/installFlow_{param_flowname}
- Dateien löschen: /storage/sdcard0/Download/installFlow_{param_flowname}
- Dateien löschen: /storage/sdcard0/Download/installFlow_{param_flowname}
- Script: notification_text = "Flow install: path for download not exist"
- Script: automagicState = "automagicState@@" + {notification_text}; fhemcmd = "setreading";
- Flows/Widgets importieren: /storage/sdcard0/Download/installFlow_{param_flowname}
- Setze Flow Status: Aktivieren {imported_flow_names,listformat,comma}
- Download URL: http://{global_fhemip}:{global_bridgeport}/installFlow_{param_flowname} to /storage/sdcard0/Download
- Download URL: http://{global_fhemip}:{global_bridgeport}/installFlow_{param_flowname} to /storage/sdcard0/Download
- Download URL: http://{global_fhemip}:{global_bridgeport}/installFlow_{param_flowname} to /storage/emulated/0/Download
- Flows/Widgets importieren: /storage/emulated/0/Download/installFlow_{param_flowname}
- Flows/Widgets importieren: /storage/sdcard0/Download/installFlow_{param_flowname}
- Setze Flow Status: Aktivieren {imported_flow_names,listformat,comma}
- Gerätespeicherplatz: Freier Speicherplatz > 1kb (/storage/emulated/0)
- Gerätespeicherplatz: Freier Speicherplatz > 1kb (/storage/sdcard0)
- Gerätespeicherplatz: Freier Speicherplatz > 1kb (/sdcard)
- Expression: installFlow"
- Neustart
- Expression: Reboot
- Expression: System Command"
- Expression: Shutdown
- Expression: Airplanemode
- Script: airplanemode = "airplanemode@@on"; fhemcmd = "setreading";
- Flows ausführen: Send Data to AMADCommBridge mit warten
- Flugmodus ein-/ausschalten: Ein
- Herunterfahren
- Notification Lautstärke Wiederherstellen
- Expression: param_notifyfile == "RedAlert.mp3"
- Sound: {param_notifypath}{param_notifyfile} als Benachrichtigung
- Benachrichtigung aus Statusbar entfernen: Alle
- Benachrichtigung aus Statusbar entfernen: Alle (Automagic)
- Expression: Automagic
- Expression: All
- Expression: notifysnd"
- NotificationLautstärke auf Level 7
- Notification Lautstärke Speichern
- Expression: param_notifyfile == "RedAlert.mp3"
- Setze Flow Status: Aktivieren {imported_flow_names,listformat,comma}
- Expression: Clear Automagic Meldungen"
- Expression: setVibrate"
- Vibrieren: Pattern 2 (-- --)
- Audio Player steuern: Medienknopf Zurück ({pname}/{kname})
- Expression: param_button == "stop"
- Expression: param_button == "next"
- Expression: param_button == "back"
- Schalte Display ein: Hell für {param_screenontime}s
- Sprachausgabe: Englisch
- Expression: ttsMsgLang"
- Expression: global_fhemip != null or global_bridgeport != null
- Setze Alarm: um {param_hour}:{param_minute}
- Audio Player steuern: Medienknopf Weiter ({pname}/{kname})
- Expression: openCall"
- Nummer anrufen: {param_callnumber}
- Expression: sendSms"
- Expression: param_flowstate == "active" or param_flowstate == "inactive"
- Expression: param_flowstate == "active"
- SMS senden an: an {param_smsnumber} '{param_smsmessage}' (10 in 12h)
- Setze Flow Status: Deaktivieren {param_flowname}
- Setze Flow Status: Aktivieren {param_flowname}
- Script: notification_text = "Flow '{param_flowname}' has been set {param_flowstate}"
- Script: automagicState = "automagicState@@" + {notification_text}; fhemcmd = "setreading";
- Expression: flowState"
- Expression: closeCall"
- Audio Player steuern: Medienknopf Stopp ({pname}/{kname})
- Expression: multimediaControl"
- Starte Daydream
- Expression: startDaydream"
- Lautstärken setzen param_volume
- Expression: setNotifiVolume"
- Lautstärken setzen param_notifivolume
- Expression: trigger == "HTTP Request: /fhem-amad/setCommands/*"
- Expression: setRingSoundVolume"
- Lautstärken setzen param_ringsoundvolume
- Expression: param_button == "play/pause"
- Audio Player steuern: Medienknopf Play/Pause (/{kname})
- Script: Zuordnung Mediaplayer
-
+ Expression: param_lockmod == "lock"
+ Setze Lock PIN/Passwort: PIN/Passwort zurücksetzen
+ Setze Lock PIN/Passwort: Setze PIN von Variable param_lockpin
+ Expression: trigger == "Sprachbefehl angefordert"
+ Expression: setAlarm"
+ Setze Timer
+ Expression: screenMsg"
+ Benachrichtigung auf Bildschirm: {param_message} (lange)
+ Script: udef_trigger = "setLockPin"
+ Display eingeschaltet
+ Gerät sperren
+ Schalte Display ein
+ Gerät sperren
+ Expression: setTimer"
+ Expression: param_option
+ Pause: {param_hanguptime}s (Gerät wach halten)
+ Anruf beenden
+ Broadcast senden: {param_action}
+ URL in Browser öffnen: {param_url} (mit {param_browserapp}/{param_browserappclass})
+ Setze Unterbrechnungen-Modus: Alle / Immer unterbrechen
+ Setze Unterbrechnungen-Modus: Wichtig / Nur wichtige Unterbrechnungen zulassen
+ Setze Unterbrechnungen-Modus: Keine / Nicht unterbrechen
+ Setze Unterbrechnungen-Modus: Nur Wecker (Android 6+)
+ Expression: openURL"
+ Expression: param_fullscreen == "on"
+ Expression: do not Disturb"
+ Expression: param_disturbmod == "always"
+ Expression: param_disturbmod == "onlyImportant"
+ Expression: param_disturbmod == "never"
+ Expression: param_disturbmod == "alarmClockOnly"
+ Expression: setBluetooth"
+ Expression: ttsMsg"
+ Expression: param_screen=="on"
+ Expression: setScreenOnOff"
+ Gerät sperren
+ Expression: param_screen=="off"
+ Expression: openApp"
+ App Task läuft: App (neuster)
+ Expression: setVolume"
+ App Starten: App
+ Dateien löschen: /storage/emulated/0/Download/installFlow_{param_flowname}
+ Dateien löschen: /storage/sdcard0/Download/installFlow_{param_flowname}
+ Dateien löschen: /storage/sdcard0/Download/installFlow_{param_flowname}
+ Script: notification_text = "Flow install: path for download not exist"
+ Flows/Widgets importieren: /storage/sdcard0/Download/installFlow_{param_flowname}
+ Setze Flow Status: Aktivieren {imported_flow_names,listformat,comma}
+ Download URL: http://{global_fhemip}:{global_bridgeport}/installFlow_{param_flowname} to /storage/sdcard0/Download
+ Download URL: http://{global_fhemip}:{global_bridgeport}/installFlow_{param_flowname} to /storage/sdcard0/Download
+ Flows/Widgets importieren: /storage/emulated/0/Download/installFlow_{param_flowname}
+ Flows/Widgets importieren: /storage/sdcard0/Download/installFlow_{param_flowname}
+ Setze Flow Status: Aktivieren {imported_flow_names,listformat,comma}
+ Gerätespeicherplatz: Freier Speicherplatz > 1kb (/storage/sdcard0)
+ Gerätespeicherplatz: Freier Speicherplatz > 1kb (/sdcard)
+ Expression: installFlow"
+ Neustart
+ Expression: Reboot
+ Expression: System Command"
+ Expression: Shutdown
+ Expression: Airplanemode
+ Script: airplanemode = "airplanemode@@on"; fhemcmd = "setreading";
+ Flows ausführen: Send Data to AMADCommBridge mit warten
+ Flugmodus ein-/ausschalten: Ein
+ Herunterfahren
+ Notification Lautstärke Wiederherstellen
+ Expression: param_notifyfile == "RedAlert.mp3"
+ Benachrichtigung aus Statusbar entfernen: Alle
+ Benachrichtigung aus Statusbar entfernen: Alle (Automagic)
+ Expression: Automagic
+ Expression: All
+ Expression: notifysnd"
+ NotificationLautstärke auf Level 7
+ Notification Lautstärke Speichern
+ Expression: param_notifyfile == "RedAlert.mp3"
+ Setze Flow Status: Aktivieren {imported_flow_names,listformat,comma}
+ Expression: Clear Automagic Meldungen"
+ Expression: setVibrate"
+ Vibrieren: Pattern 2 (-- --)
+ Audio Player steuern: Medienknopf Zurück ({pname}/{kname})
+ Expression: param_button == "stop"
+ Expression: param_button == "next"
+ Expression: param_button == "back"
+ Schalte Display ein: Hell für {param_screenontime}s
+ Expression: ttsMsgLang"
+ Expression: global_fhemip != null or global_bridgeport != null
+ Setze Alarm: um {param_hour}:{param_minute}
+ Audio Player steuern: Medienknopf Weiter ({pname}/{kname})
+ Expression: openCall"
+ Nummer anrufen: {param_callnumber}
+ Expression: sendSms"
+ Expression: param_flowstate == "active" or param_flowstate == "inactive"
+ Expression: param_flowstate == "active"
+ SMS senden an: an {param_smsnumber} '{param_smsmessage}' (10 in 12h)
+ Setze Flow Status: Deaktivieren {param_flowname}
+ Script: notification_text = "Flow '{param_flowname}' has been set {param_flowstate}"
+ Expression: flowState"
+ Expression: closeCall"
+ Expression: multimediaControl"
+ Starte Daydream
+ Expression: startDaydream"
+ Lautstärken setzen param_volume
+ Expression: setNotifiVolume"
+ Lautstärken setzen param_notifivolume
+ Expression: trigger == "HTTP Request: /fhem-amad/setCommands/*"
+ Expression: setRingSoundVolume"
+ Lautstärken setzen param_ringsoundvolume
+ Expression: param_button == "play/pause"
+ Audio Player steuern: Medienknopf Play/Pause (/{kname})
+ Sound: {param_notifypath}{param_notifyfile} als Benachrichtigung
+ Gerätespeicherplatz: Freier Speicherplatz > 1kb (/storage/emulated/0)
+ Download URL: http://{global_fhemip}:{global_bridgeport}/installFlow_{param_flowname} to /storage/emulated/0/Download
+ Script: flow_informations = "\"flow_informations\":" + " \"" + {informationFlow_state} + "\""; fhemcmd = "setreading";
+ Script: automagicState = "\"automagicState\":" + " \"" + replaceAll({notification_text}, "\\n", " ") + "\""; fhemcmd = "setreading";
+ Script: automagicState = "\"automagicState\":" + " \"" + replaceAll({notification_text}, "\\n", " ") + "\""; fhemcmd = "setreading";
+ Flows ausführen: Send Data to AMADCommBridge
+ Sprachausgabe: Englisch
+ Sprachausgabe: Deutsch
+ Flows ausführen: VoiceControl
+ Flows ausführen: udef_trigger setLockPin
+ Setze Flow Status: Aktivieren {param_flowname}
+ Flow Aktiv: Informations
+ Script: informationFlow_state = "aktiv"
+ Script: informationFlow_state = "inaktiv"
+ Setze Flow Status: Aktivieren Informations
+ Host erreichbar: {global_fhemip}:{global_bridgeport}
+ Flow Aktiv: Send Data to AMADCommBridge
+ Setze Flow Status: Aktivieren Send Data to AMADCommBridge
+ Audio Player steuern: Medienknopf Stopp ({pname}/{kname})
+ Script: Zuordnung Mediaplayer
+
-
+
@@ -3519,227 +4374,245 @@ if(param_mplayer == "mediaAudible")
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
Update AMAD Flowset
- AMAD2 Info/Control Flowset v2.6.12
+ AMADNG Info/Control Flowset v3.9.76
true
QUEUE
HTTP Request: /fhem-amad/currentFlowsetUpdate
- Flows/Widgets importieren: /storage/emulated/0/Download/currentFlowsetUpdate.xml
- Setze Flow Status: Aktivieren {imported_flow_names,listformat,comma}
- Dateien löschen: /storage/emulated/0/Download/currentFlowsetUpdate.xml
- Setze Flow Status: Aktivieren {imported_flow_names,listformat,comma}
- Dateien löschen: /storage/sdcard0/Download/currentFlowsetUpdate.xml
- Flows/Widgets importieren: /storage/sdcard0/Download/currentFlowsetUpdate.xml
- Download URL: http://{global_fhemip}:{global_bridgeport}/currentFlowsetUpdate.xml to /storage/sdcard0/Download
- Download URL: http://{global_fhemip}:{global_bridgeport}/currentFlowsetUpdate.xml to /sdcard/Download
- Flows/Widgets importieren: /sdcard/Download/currentFlowsetUpdate.xml
- Setze Flow Status: Aktivieren {imported_flow_names,listformat,comma}
- Dateien löschen: /sdcard/Download/currentFlowsetUpdate.xml
- Script: notification_text = "Flowset Update: path for download not exist"
- Gerätespeicherplatz: Freier Speicherplatz > 1kb (/storage/emulated/0)
- Gerätespeicherplatz: Freier Speicherplatz > 1kb (/storage/sdcard0)
- Gerätespeicherplatz: Freier Speicherplatz > 1kb (/sdcard)
- Prüfe und setze Bridgeport Variable
- Download URL: http://{global_fhemip}:{global_bridgeport}/currentFlowsetUpdate.xml to /storage/emulated/0/Download
- Script: automagicState = "automagicState@@" + {notification_text}; fhemcmd = "setreading";
+ Setze Flow Status: Aktivieren {imported_flow_names,listformat,comma}
+ Setze Flow Status: Aktivieren {imported_flow_names,listformat,comma}
+ Flows/Widgets importieren: /storage/sdcard0/Download/currentFlowsetUpdate.xml
+ Download URL: http://{global_fhemip}:{global_bridgeport}/currentFlowsetUpdate.xml to /storage/sdcard0/Download
+ Download URL: http://{global_fhemip}:{global_bridgeport}/currentFlowsetUpdate.xml to /sdcard/Download
+ Flows/Widgets importieren: /sdcard/Download/currentFlowsetUpdate.xml
+ Setze Flow Status: Aktivieren {imported_flow_names,listformat,comma}
+ Script: notification_text = "Flowset Update: path for download not exist"
+ Gerätespeicherplatz: Freier Speicherplatz > 1kb (/storage/sdcard0)
+ Gerätespeicherplatz: Freier Speicherplatz > 1kb (/sdcard)
+ Gerätespeicherplatz: Freier Speicherplatz > 1kb (/storage/emulated/0)
+ Script: automagicState = "\"automagicState\":" + " \"" + replaceAll({notification_text}, "\\n", " ") + "\""; fhemcmd = "setreading";
+ Prüfe und setze Bridgeport Variable
+ Flows/Widgets importieren: /storage/emulated/0/Download/currentFlowsetUpdate.xml
+ Download URL: http://{global_fhemip}:{global_bridgeport}/currentFlowsetUpdate.xml to /storage/emulated/0/Download
+ Dateien löschen: /storage/emulated/0/Download/currentFlowsetUpdate.xml
+ Dateien löschen: /storage/sdcard0/Download/currentFlowsetUpdate.xml
+ Dateien löschen: /sdcard/Download/currentFlowsetUpdate.xml
Flows ausführen: Send Data to AMADCommBridge
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ Flow Aktiv: First Run Assistant
+ Setze Flow Status: Deaktivieren First Run Assistant
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
VoiceControl
- AMAD2 Info/Control Flowset v2.6.12
+ AMADNG Info/Control Flowset v3.9.76
true
QUEUE
- Expression: value != ""
- Flows ausführen: Send Data to AMADCommBridge
- Benachrichtigung auf Bildschirm: {value} (lange)
- Spracheingabe wurde nicht erkannt
- Flows ausführen: Send Data to AMADCommBridge
- Setze voice Variablen
- Script: voiceinputdata = value; fhemcmd = "voiceinputvalue";
- Script: voiceinputdata = {left(value, (indexOf(value, " und ")))}; fhemcmd = "voiceinputvalue";
- Expression: contains(value, " und ")
- AMAD Voice Control
-
-
-
-
+ AMAD Voice Control
+ Expression: value != ""
+ Expression: contains(value, " und ")
+ Script: voiceinputdata = {left(value, (indexOf(value, " und ")))}; fhemcmd = "voiceinputvalue";
+ Flows ausführen: Send Data to AMADCommBridge
+ Setze voice Variablen
+ Spracheingabe wurde nicht erkannt
+ Script: voiceinputdata = value; fhemcmd = "voiceinputvalue";
+ Flows ausführen: Send Data to AMADCommBridge
+ Benachrichtigung auf Bildschirm: {value} (lange)
+ Expression: global_fhemctlmode != "thirdPartControl"
+ Script: voiceinputdata = value; fhemcmd = "voiceinputvalue";
+ Flows ausführen: Send Data to AMADCommBridge
+ Benachrichtigung auf Bildschirm: {value} (lange)
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/README.md b/README.md
deleted file mode 100644
index 8d8be1e..0000000
--- a/README.md
+++ /dev/null
@@ -1,151 +0,0 @@
-AMAD
-
- AMAD - Automagic Android Device
-
- Dieses Modul liefert, in Verbindung mit der Android APP Automagic, diverse Informationen von Android Geräten.
- Die AndroidAPP Automagic (welche nicht von mir stammt und 2.90 Euro kostet) funktioniert wie Tasker, ist aber bei weitem User freundlicher.
-
- Mit etwas Einarbeitung können jegliche Informationen welche Automagic bereit stellt in FHEM angezeigt werden. Hierzu bedarf es lediglich eines eigenen Flows welcher seine Daten an die AMADCommBridge sendet. Das Modul gibt auch die Möglichkeit Androidgeräte zu steuern.
-
- Für all diese Aktionen und Informationen wird auf dem Androidgerät "Automagic" und ein so genannter Flow benötigt. Die App ist über den Google PlayStore zu beziehen. Das benötigte Flowset bekommt man aus dem FHEM Verzeichnis.
-
- Wie genau verwendet man nun AMAD?
-
- - man installiert die App "Automagic Premium" aus dem PlayStore oder die Testversion von hier
- - dann installiert man das Flowset 74_AMADautomagicFlowset$VERSION.xml aus dem Ordner $INSTALLFHEM/FHEM/lib/ auf dem Androidgerät und aktiviert die Flows.
-
-
- Es muß noch ein Device in FHEM anlegt werden.
-
-
- Define
-
- define <name> AMAD <IP-ADRESSE> <WLANAP-SSID('s)>
-
- Beispiel:
-
- define WandTabletWohnzimmer AMAD 192.168.0.23 TuxNetAP,Opa@@Zu@@Hause
-
-
- Diese Anweisung erstellt zwei neues AMAD-Device im Raum AMAD.Der Parameter <IP-ADRESSE> legt die IP Adresse des Android Gerätes fest und der Parameter WLANAP-SSID die SSID Deines WLAN's. Es können mehrere SSID's mit angegeben werden, welche dann durch Komma getrennt sein müssen. Haben die SSID's Leerzeichen im Namen werde die Leerzeichen durch 2 @ aufgefüllt. Gibt es Androidgeräte welche nicht über WLAN sondern USB-Ethernet angeschlossen sind, ist die WLANAP-SSID mit "usb-ethernet" zu benennen
- Das zweite Device ist die AMADCommBridge welche als Kommunikationsbrücke vom Androidgerät zu FHEM diehnt. !!!Comming Soon!!! Wer den Port ändern möchte, kann dies über das Attribut "port" tun. Ihr solltet aber wissen was Ihr tut, da dieser Port im HTTP Request Trigger der beiden Flows eingestellt ist. Demzufolge muß der Port dort auch geändert werden. Der Port für die Bridge kann ohne Probleme im Bridge Device mittels dem Attribut "port" verändert werden.
-
- Der Port für die Bridge kann ohne Probleme im Bridge Device mittels dem Attribut "port" verändert werden.
-
-
- AMAD Communication Bridge
-
- Beim ersten anlegen einer AMAD Deviceinstanz wird automatisch ein Gerät Namens AMADCommBridge im Raum AMAD mit angelegt. Dieses Gerät diehnt zur Kommunikation vom Androidgerät zu FHEM ohne das zuvor eine Anfrage von FHEM aus ging. Damit das Androidgerät die IP von FHEM kennt, muss diese sofort nach dem anlegen der Bridge über den set Befehl in ein entsprechendes Reading in die Bridge geschrieben werden. DAS IST SUPER WICHTIG UND FÜR DIE FUNKTION DER BRIDGE NOTWENDIG.
- Hierfür muß folgender Befehl ausgeführt werden. set AMADCommBridge fhemServerIP <FHEM-IP>.
- Als zweites Reading kann expertMode gesetzen werden. Mit diesem Reading wird eine unmittelbare Komminikation mit FHEM erreicht ohne die Einschränkung über ein
- Notify gehen zu müssen und nur reine set Befehle ausführen zu können.
-
- NUN bitte die Flows AKTIVIEREN!!!
-
- Fertig! Nach anlegen der Geräteinstanz und dem eintragen der fhemServerIP in der CommBridge sollten nach spätestens 15 Sekunden bereits die ersten Readings reinkommen. Nun wird alle 15 Sekunden probiert einen Status Request erfolgreich ab zu schließen. Wenn der Status sich über einen längeren Zeitraum nicht auf "active" ändert, sollte man im Log nach eventuellen Fehlern suchen.
-
-
- Readings
-
- - airplanemode - Status des Flugmodus
- - androidVersion - aktuell installierte Androidversion
- - automagicState - Statusmeldungen von der AutomagicApp (Voraussetzung Android >4.3). Ist Android größer 4.3 vorhanden und im Reading steht "wird nicht unterstützt", muß in den Androideinstellungen unter Ton und Benachrichtigungen -> Benachrichtigungszugriff ein Haken für Automagic gesetzt werden
- - bluetooth - on/off, Bluetooth Status an oder aus
- - checkActiveTask - Zustand einer zuvor definierten APP. 0=nicht aktiv oder nicht aktiv im Vordergrund, 1=aktiv im Vordergrund, siehe Hinweis unten
- - connectedBTdevices - eine Liste der verbundenen Gerät
- - connectedBTdevicesMAC - eine Liste der MAC Adressen aller verbundender BT Geräte
- - currentMusicAlbum - aktuell abgespieltes Musikalbum des verwendeten Mediaplayers
- - currentMusicApp - aktuell verwendeter Mediaplayers
- - currentMusicArtist - aktuell abgespielter Musikinterpret des verwendeten Mediaplayers
- - currentMusicTrack - aktuell abgespielter Musiktitel des verwendeten Mediaplayers
- - daydream - on/off, Daydream gestartet oder nicht
- - deviceState - Status des Androidgerätes. unknown, online, offline.
- - dockingState - undocked/docked Status ob sich das Gerät in einer Dockinstation befindet.
- - flow_SetCommands - active/inactive, Status des SetCommands Flow
- - flow_informations - active/inactive, Status des Informations Flow
- - flowsetVersionAtDevice - aktuell installierte Flowsetversion auf dem Device
- - intentRadioName - zuletzt gesrreamter Intent Radio Name
- - intentRadioState - Status des IntentRadio Players
- - keyguardSet - 0/1 Displaysperre gesetzt 0=nein 1=ja, bedeutet nicht das sie gerade aktiv ist
- - lastSetCommandError - letzte Fehlermeldung vom set Befehl
- - lastSetCommandState - letzter Status vom set Befehl, Befehl erfolgreich/nicht erfolgreich gesendet
- - lastStatusRequestError - letzte Fehlermeldung vom statusRequest Befehl
- - lastStatusRequestState - letzter Status vom statusRequest Befehl, Befehl erfolgreich/nicht erfolgreich gesendet
- - nextAlarmDay - aktiver Alarmtag
- - nextAlarmState - aktueller Status des "Androidinternen" Weckers
- - nextAlarmTime - aktive Alarmzeit
- - powerLevel - Status der Batterie in %
- - powerPlugged - Netzteil angeschlossen? 0=NEIN, 1|2=JA
- - screen - on locked/unlocked, off locked/unlocked gibt an ob der Bildschirm an oder aus ist und gleichzeitig gesperrt oder nicht gesperrt
- - screenBrightness - Bildschirmhelligkeit von 0-255
- - screenFullscreen - on/off, Vollbildmodus (An,Aus)
- - screenOrientation - Landscape,Portrait, Bildschirmausrichtung (Horizontal,Vertikal)
- - screenOrientationMode - auto/manual, Modus für die Ausrichtung (Automatisch, Manuell)
- - state - aktueller Status
- - volume - Media Lautstärkewert
- - volumeNotification - Benachrichtigungs Lautstärke
-
- Beim Reading checkActivTask muß zuvor der Packagename der zu prüfenden App als Attribut checkActiveTask angegeben werden. Beispiel: attr Nexus10Wohnzimmer
- checkActiveTask com.android.chrome für den Chrome Browser.
-
-
-
-
- Set
-
- - activateVoiceInput - aktiviert die Spracheingabe
- - amazonMusic - play, stop, next, back ,steuert den Amazon Musik Mediaplayer
- - bluetooth - on/off, aktiviert/deaktiviert Bluetooth
- - clearNotificationBar - All,Automagic, löscht alle Meldungen oder nur die Automagic Meldungen in der Statusleiste
- - currentFlowsetUpdate - fürt ein Flowsetupdate auf dem Device durch
- - googleMusic - play, stop, next, back ,steuert den Google Play Musik Mediaplayer
- - installFlowSource - installiert einen Flow auf dem Device, das XML File muss unter /tmp/ liegen und die Endung xml haben. Bsp: set TabletWohnzimmer installFlowSource WlanUebwerwachen.xml
- - nextAlarmTime - setzt die Alarmzeit. gilt aber nur innerhalb der nächsten 24Std.
- - screenBrightness - setzt die Bildschirmhelligkeit, von 0-255.
- - screenMsg - versendet eine Bildschirmnachricht
- - sendintent - sendet einen Intentstring Bsp: set $AMADDEVICE sendIntent org.smblott.intentradio.PLAY url http://stream.klassikradio.de/live/mp3-192/stream.klassikradio.de/play.m3u name Klassikradio, der erste Befehl ist die Aktion und der zweite das Extra. Es können immer zwei Extras mitgegeben werden.
- - spotifyMusic - play, stop, next, back ,steuert den Spotify Mediaplayer
- - statusRequest - Fordert einen neuen Statusreport beim Device an. Es können nicht von allen Readings per statusRequest die Daten geholt werden. Einige wenige geben nur bei Statusänderung ihren Status wieder.
- - timer - setzt einen Timer innerhalb der als Standard definierten ClockAPP auf dem Device. Es können nur Sekunden angegeben werden.
- - ttsMsg - versendet eine Nachricht welche als Sprachnachricht ausgegeben wird
- - vibrate - lässt das Androidgerät vibrieren
- - volume - setzt die Medialautstärke. Entweder die internen Lautsprecher oder sofern angeschlossen die Bluetoothlautsprecher und per Klinkenstecker angeschlossene Lautsprecher
- - volumeNotification - setzt die Benachrichtigungslautstärke.
-
-
- Set abhängig von gesetzten Attributen
-
- - changetoBtDevice - wechselt zu einem anderen Bluetooth Gerät. Attribut setBluetoothDevice muß gesetzt sein. Siehe Hinweis unten!
- - notifySndFile - spielt die angegebene Mediadatei auf dem Androidgerät ab. Die aufzurufende Mediadatei sollte sich im Ordner /storage/emulated/0/Notifications/ befinden. Ist dies nicht der Fall kann man über das Attribut setNotifySndFilePath einen Pfad vorgeben.
- - openApp - öffnet eine ausgewählte App. Attribut setOpenApp
- - openURL - öffnet eine URL im Standardbrowser, sofern kein anderer Browser über das Attribut setOpenUrlBrowser ausgewählt wurde. Bsp: attr Tablet setOpenUrlBrowser de.ozerov.fully|de.ozerov.fully.MainActivity, das erste ist der Package Name und das zweite der Class Name
- - screen - on/off/lock/unlock schaltet den Bildschirm ein/aus oder sperrt/entsperrt ihn, in den Automagic Einstellungen muss "Admin Funktion" gesetzt werden sonst funktioniert "Screen off" nicht. Attribut setScreenOnForTimer ändert die Zeit wie lange das Display an bleiben soll!
- - screenFullscreen - on/off, (aktiviert/deaktiviert) den Vollbildmodus. Attribut setFullscreen
- - screenLock - Sperrt den Bildschirm mit Pinabfrage. Attribut setScreenlockPIN - hier die Pin dafür eingeben. Erlaubt sind nur Zahlen. Es müßen mindestens 4, bis max 16 Zeichen verwendet werden.
- - screenOrientation - Auto,Landscape,Portait, aktiviert die Bildschirmausrichtung (Automatisch,Horizontal,Vertikal). Attribut setScreenOrientation
- - system - setzt Systembefehle ab (nur bei gerootetet Geräen). reboot,shutdown,airplanemodeON (kann nur aktiviert werden) Attribut root, in den Automagic Einstellungen muss "Root Funktion" gesetzt werden
- - setNotifySndFilePath - setzt den korrekten Systempfad zur Notifydatei (default ist /storage/emulated/0/Notifications/
- - setTtsMsgSpeed - setzt die Sprachgeschwindigkeit bei der Sprachausgabe(Werte zwischen 0.5 bis 4.0 in 0.5er Schritten) default ist 1.0
-
- Um openApp verwenden zu können, muss als Attribut der Package Name der App angegeben werden.
-
- Um zwischen Bluetoothgeräten wechseln zu können, muß das Attribut setBluetoothDevice mit folgender Syntax gesetzt werden. attr <DEVICE> BTdeviceName1|MAC,BTDeviceName2|MAC Es muss
- zwingend darauf geachtet werden das beim BTdeviceName kein Leerzeichen vorhanden ist. Am besten zusammen oder mit Unterstrich. Achtet bei der MAC darauf das Ihr wirklich nach jeder zweiten Zahl auch
- einen : drin habt
- Beispiel: attr Nexus10Wohnzimmer setBluetoothDevice Logitech_BT_Adapter|AB:12:CD:34:EF:32,Anker_A3565|GH:56:IJ:78:KL:76
-
-
-
- state
-
- - initialized - Ist der Status kurz nach einem define.
- - active - die Geräteinstanz ist im aktiven Status.
- - disabled - die Geräteinstanz wurde über das Attribut disable deaktiviert
-
-
- Anwendungsbeispiele:
-
-
-