74_AMAD change: set of STATE has been replaced by Readingsupdate - feature: commandref english translation, default $ line

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@9252 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
markooldenburg 2015-09-15 06:44:46 +00:00
parent 3c7cb19159
commit df7d529383
2 changed files with 231 additions and 52 deletions

View File

@ -1,14 +1,17 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it. # Do not insert empty lines here, update check depends on it.
- change: 74_AMAD: change set of STATE has been replaced by Readingsupdate
'state'
- feature: 74_AMAD: commandref english translation, default $Id$ line
- feature: SYSMON: telnet login with no user/pass required - feature: SYSMON: telnet login with no user/pass required
- bugfix: 95_Dashboard: the sort order in columns is now correctly read - bugfix: 95_Dashboard: the sort order in columns is now correctly read
from the sorting attribute. from the sorting attribute.
- bugfix: 00_MAXLAN: set time on cube if it has none (by Tom_S) - bugfix: 00_MAXLAN: set time on cube if it has none (by Tom_S)
- bugfix: 14_CUL_MAX: work together with a-culfw - bugfix: 14_CUL_MAX: work together with a-culfw
- bugfix: 70_PushNotifier: bugfix regex deviceID - bugfix: 70_PushNotifier: bugfix regex deviceID
- feature: new Module 74_AMAD to request Information and control Android - feature: new Module 74_AMAD to request Information and control Android Devices
Devices in cooperation with AutomagicApp on the Device (Forum in cooperation with AutomagicApp on the Device (Forum #39773)
#39773) (by M. Oldenburg) (by M. Oldenburg)
- bugfix: 70_PushNotifier.pm: regex error handling - bugfix: 70_PushNotifier.pm: regex error handling
- bugfix: 31_MilightDevice.pm: fixed bug that lead to crash on lost bridge - bugfix: 31_MilightDevice.pm: fixed bug that lead to crash on lost bridge
connection, added module name prefix to round function connection, added module name prefix to round function

View File

@ -1,4 +1,4 @@
################################################################ ###############################################################################
# #
# Developed with Kate # Developed with Kate
# #
@ -20,9 +20,10 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
################################################################ #
# $Id$
#
###############################################################################
package main; package main;
@ -33,7 +34,7 @@ use Time::HiRes qw(gettimeofday);
use HttpUtils; use HttpUtils;
my $version = "0.6.0"; my $version = "0.6.1";
@ -90,8 +91,9 @@ my ( $hash, $def ) = @_;
InternalTimer( gettimeofday()+$hash->{INTERVAL}, "AMAD_GetUpdateTimer", $hash, 0 ); InternalTimer( gettimeofday()+$hash->{INTERVAL}, "AMAD_GetUpdateTimer", $hash, 0 );
$hash->{STATE} = "initialized"; # $hash->{STATE} = "initialized"; # direktes setzen von STATE ist absolete
readingsSingleUpdate ( $hash, "deviceState", "online", 0 ); readingsSingleUpdate ( $hash, "state", "initialized", 1 );
readingsSingleUpdate ( $hash, "deviceState", "online", 1 );
return undef; return undef;
} }
@ -114,19 +116,22 @@ my ( $cmd, $name, $attrName, $attrVal ) = @_;
if( $cmd eq "set" ) { if( $cmd eq "set" ) {
if( $attrVal eq "0" ) { if( $attrVal eq "0" ) {
RemoveInternalTimer( $hash ); RemoveInternalTimer( $hash );
InternalTimer( gettimeofday()+2, "AMAD_GetUpdateTimer", $hash, 0 ) if( $hash->{STATE} eq "disabled" ); InternalTimer( gettimeofday()+2, "AMAD_GetUpdateTimer", $hash, 0 ) if( ReadingsVal( $hash->{NAME}, "state", 0 ) eq "disabled" );
$hash->{STATE}='active'; # $hash->{STATE}='active'; # direktes STATE setzen ist absolete
readingsSingleUpdate ( $hash, "state", "active", 1 );
Log3 $name, 3, "AMAD ($name) - enabled"; Log3 $name, 3, "AMAD ($name) - enabled";
} else { } else {
$hash->{STATE} = 'disabled'; # $hash->{STATE} = 'disabled';
readingsSingleUpdate ( $hash, "state", "disabled", 1 );
RemoveInternalTimer( $hash ); RemoveInternalTimer( $hash );
Log3 $name, 3, "AMAD ($name) - disabled"; Log3 $name, 3, "AMAD ($name) - disabled";
} }
} }
elsif( $cmd eq "del" ) { elsif( $cmd eq "del" ) {
RemoveInternalTimer( $hash ); RemoveInternalTimer( $hash );
InternalTimer( gettimeofday()+2, "AMAD_GetUpdateTimer", $hash, 0 ) if( $hash->{STATE} eq "disabled" ); InternalTimer( gettimeofday()+2, "AMAD_GetUpdateTimer", $hash, 0 ) if( ReadingsVal( $hash->{NAME}, "state", 0 ) eq "disabled" );
$hash->{STATE}='active'; # $hash->{STATE}='active';
readingsSingleUpdate ( $hash, "state", "active", 1 );
Log3 $name, 3, "AMAD ($name) - enabled"; Log3 $name, 3, "AMAD ($name) - enabled";
} else { } else {
@ -190,7 +195,7 @@ sub AMAD_GetUpdateLocal($) {
my ( $hash ) = @_; my ( $hash ) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
AMAD_RetrieveAutomagicInfo( $hash ) if( ReadingsVal( $name, "deviceState", "online" ) eq "online" && $hash->{STATE} ne "initialized" && AttrVal( $name, "disable", 0 ) ne "1" ); ### deviceState muß von Hand online/offline gesetzt werden z.B. über RESIDENZ Modul AMAD_RetrieveAutomagicInfo( $hash ) if( ReadingsVal( $name, "deviceState", "online" ) eq "online" && ReadingsVal( $hash->{NAME}, "state", 0 ) ne "initialized" && AttrVal( $name, "disable", 0 ) ne "1" ); ### deviceState muß von Hand online/offline gesetzt werden z.B. ueber RESIDENZ Modul
return 1; return 1;
} }
@ -200,7 +205,7 @@ sub AMAD_GetUpdateTimer($) {
my ( $hash ) = @_; my ( $hash ) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
AMAD_RetrieveAutomagicInfo( $hash ) if( ReadingsVal( $name, "deviceState", "online" ) eq "online" && AttrVal( $name, "disable", 0 ) ne "1" ); ### deviceState muß von Hand online/offline gesetzt werden z.B. über RESIDENZ Modul AMAD_RetrieveAutomagicInfo( $hash ) if( ReadingsVal( $name, "deviceState", "online" ) eq "online" && AttrVal( $name, "disable", 0 ) ne "1" ); ### deviceState muß von Hand online/offline gesetzt werden z.B. ueber RESIDENZ Modul
InternalTimer( gettimeofday()+$hash->{INTERVAL}, "AMAD_GetUpdateTimer", $hash, 1 ); InternalTimer( gettimeofday()+$hash->{INTERVAL}, "AMAD_GetUpdateTimer", $hash, 1 );
Log3 $name, 4, "AMAD ($name) - Call AMAD_GetUpdateTimer"; Log3 $name, 4, "AMAD ($name) - Call AMAD_GetUpdateTimer";
@ -248,7 +253,7 @@ sub AMAD_Set($$@) {
Log3 $name, 5, "AMAD ($name) - set $name $cmd ".join(" ", @val); Log3 $name, 5, "AMAD ($name) - set $name $cmd ".join(" ", @val);
return "set command only works if STATE not equal initialized, please wait for next interval run" if( $hash->{STATE} eq "initialized"); return "set command only works if state not equal initialized, please wait for next interval run" 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 disabled" if( AttrVal( $name, "disable", "0" ) eq "1" );
return AMAD_SelectSetCmd( $hash, $cmd, @val ) if( @val ) && ( ReadingsVal( $name, "deviceState", "online" ) eq "offline" ) && ( lc $cmd eq 'devicestate' ); return AMAD_SelectSetCmd( $hash, $cmd, @val ) if( @val ) && ( ReadingsVal( $name, "deviceState", "online" ) eq "offline" ) && ( lc $cmd eq 'devicestate' );
@ -308,7 +313,8 @@ sub AMAD_RetrieveAutomagicInfoFinished($$$) {
Log3 $name, 5, "AMAD ($name) - CHECK THE LAST ERROR READINGS FOR MORE INFO, DEVICE IS SET OFFLINE"; Log3 $name, 5, "AMAD ($name) - CHECK THE LAST ERROR READINGS FOR MORE INFO, DEVICE IS SET OFFLINE";
readingsBulkUpdate( $hash, "deviceState", "offline" ); readingsBulkUpdate( $hash, "deviceState", "offline" );
$hash->{STATE} = "AMAD Flows inactive, device set offline"; # $hash->{STATE} = "AMAD Flows inactive, device set offline"; # STATE direkt setzen ist absolete
readingsBulkUpdate ( $hash, "state", "AMAD Flows inactive, device set offline");
} }
elsif( $hash->{helper}{infoErrorCounter} > 9 && $hash->{helper}{setCmdErrorCounter} > 4 ) { elsif( $hash->{helper}{infoErrorCounter} > 9 && $hash->{helper}{setCmdErrorCounter} > 4 ) {
readingsBulkUpdate( $hash, "lastStatusRequestError", "unknown error, please contact the developer" ); readingsBulkUpdate( $hash, "lastStatusRequestError", "unknown error, please contact the developer" );
@ -316,7 +322,9 @@ sub AMAD_RetrieveAutomagicInfoFinished($$$) {
Log3 $name, 4, "AMAD ($name) - UNKNOWN ERROR, PLEASE CONTACT THE DEVELOPER, DEVICE DISABLED"; Log3 $name, 4, "AMAD ($name) - UNKNOWN ERROR, PLEASE CONTACT THE DEVELOPER, DEVICE DISABLED";
$attr{$name}{disable} = 1; $attr{$name}{disable} = 1;
$hash->{STATE} = "Unknown Error, device disabled"; # $hash->{STATE} = "Unknown Error, device disabled";
readingsBulkUpdate ( $hash, "state", "Unknown Error, device disabled");
$hash->{helper}{infoErrorCounter} = 0; $hash->{helper}{infoErrorCounter} = 0;
$hash->{helper}{setCmdErrorCounter} = 0; $hash->{helper}{setCmdErrorCounter} = 0;
@ -338,7 +346,8 @@ sub AMAD_RetrieveAutomagicInfoFinished($$$) {
Log3 $name, 4, "AMAD ($name) - To many Errors please check your Network or Device Configuration, DEVICE IS SET OFFLINE"; Log3 $name, 4, "AMAD ($name) - To many Errors please check your Network or Device Configuration, DEVICE IS SET OFFLINE";
readingsBulkUpdate( $hash, "deviceState", "offline" ); readingsBulkUpdate( $hash, "deviceState", "offline" );
$hash->{STATE} = "To many Errors, device set offline"; # $hash->{STATE} = "To many Errors, device set offline"; # STATE direkt setzen ist absolete
readingsBulkUpdate ( $hash, "state", "To many Errors, device set offline");
$hash->{helper}{infoErrorCounter} = 0; $hash->{helper}{infoErrorCounter} = 0;
} }
readingsEndUpdate( $hash, 1 ); readingsEndUpdate( $hash, 1 );
@ -346,10 +355,11 @@ sub AMAD_RetrieveAutomagicInfoFinished($$$) {
if( defined( $err ) ) { if( defined( $err ) ) {
if( $err ne "" ) { if( $err ne "" ) {
$hash->{STATE} = $err if( $hash->{STATE} ne "initialized" ); readingsBeginUpdate( $hash );
# $hash->{STATE} = $err if( $hash->{STATE} ne "initialized" );
readingsBulkUpdate ( $hash, "state", "$err") if( ReadingsVal( $name, "state", 1 ) ne "initialized" );
$hash->{helper}{infoErrorCounter} = ( $hash->{helper}{infoErrorCounter} + 1 ); $hash->{helper}{infoErrorCounter} = ( $hash->{helper}{infoErrorCounter} + 1 );
readingsBeginUpdate( $hash );
readingsBulkUpdate( $hash, "lastStatusRequestState", "statusRequest_error" ); readingsBulkUpdate( $hash, "lastStatusRequestState", "statusRequest_error" );
if( $err =~ /timed out/ ) { if( $err =~ /timed out/ ) {
@ -358,7 +368,7 @@ sub AMAD_RetrieveAutomagicInfoFinished($$$) {
elsif( ( $err =~ /Keine Route zum Zielrechner/ ) && $hash->{helper}{infoErrorCounter} > 1 ) { elsif( ( $err =~ /Keine Route zum Zielrechner/ ) && $hash->{helper}{infoErrorCounter} > 1 ) {
readingsBulkUpdate( $hash,"lastStatusRequestError", "no route to target. bad network configuration or network is down "); readingsBulkUpdate( $hash,"lastStatusRequestError", "no route to target. bad network configuration or network is down ");
} else { } else {
readingsBulkUpdate($hash, "lastStatusRequestError", "$err" ); readingsBulkUpdate($hash, "lastStatusRequestError", $err );
} }
readingsEndUpdate( $hash, 1 ); readingsEndUpdate( $hash, 1 );
@ -369,10 +379,11 @@ sub AMAD_RetrieveAutomagicInfoFinished($$$) {
} }
if( $data eq "" and exists( $param->{code} ) ) { if( $data eq "" and exists( $param->{code} ) ) {
$hash->{STATE} = $param->{code} if( $hash->{STATE} ne "initialized" ); readingsBeginUpdate( $hash );
# $hash->{STATE} = $param->{code} if( $hash->{STATE} ne "initialized" ); # direktes setzen von STATE ist absolete
readingsBulkUpdate ( $hash, "state", $param->{code} ) if( ReadingsVal( $name, "state", 1 ) ne "initialized" );
$hash->{helper}{infoErrorCounter} = ( $hash->{helper}{infoErrorCounter} + 1 ); $hash->{helper}{infoErrorCounter} = ( $hash->{helper}{infoErrorCounter} + 1 );
readingsBeginUpdate( $hash );
readingsBulkUpdate( $hash, "lastStatusRequestState", "statusRequest_error" ); readingsBulkUpdate( $hash, "lastStatusRequestState", "statusRequest_error" );
if( $param->{code} ne 200 ) { if( $param->{code} ne 200 ) {
@ -388,10 +399,11 @@ sub AMAD_RetrieveAutomagicInfoFinished($$$) {
} }
if( ( $data =~ /Error/i ) and exists( $param->{code} ) ) { if( ( $data =~ /Error/i ) and exists( $param->{code} ) ) {
$hash->{STATE} = $param->{code} if( $hash->{STATE} ne "initialized" ); #$hash->{STATE} = $param->{code} if( $hash->{STATE} ne "initialized" ); ## STATE direkt ist absolete
readingsBeginUpdate( $hash );
readingsBulkUpdate( $hash, "state", $param->{code} ) if( ReadingsVal( $name, "state" ,0) ne "initialized" );
$hash->{helper}{infoErrorCounter} = ( $hash->{helper}{infoErrorCounter} + 1 ); $hash->{helper}{infoErrorCounter} = ( $hash->{helper}{infoErrorCounter} + 1 );
readingsBeginUpdate( $hash );
readingsBulkUpdate( $hash, "lastStatusRequestState", "statusRequest_error" ); readingsBulkUpdate( $hash, "lastStatusRequestState", "statusRequest_error" );
if( $param->{code} eq 404 && ReadingsVal( $name, "flow_Informations", "inactive" ) eq "inactive" ) { if( $param->{code} eq 404 && ReadingsVal( $name, "flow_Informations", "inactive" ) eq "inactive" ) {
@ -415,7 +427,8 @@ sub AMAD_RetrieveAutomagicInfoFinished($$$) {
$hash->{helper}{infoErrorCounter} = 0; $hash->{helper}{infoErrorCounter} = 0;
### Begin Response Processing ### Begin Response Processing
$hash->{STATE} = "active" if( $hash->{STATE} eq "initialized" || $hash->{STATE} ne "active" ); # $hash->{STATE} = "active" if( $hash->{STATE} eq "initialized" || $hash->{STATE} ne "active" ); ## STATE direkt setzen ist absolete
readingsSingleUpdate( $hash, "state", "active", 1) if( ReadingsVal( $name, "state", 0 ) ne "initialized" or ReadingsVal( $name, "state", 0 ) ne "active" );
my @valuestring = split( '@@@@', $data ); my @valuestring = split( '@@@@', $data );
my %buffer; my %buffer;
@ -436,12 +449,14 @@ sub AMAD_RetrieveAutomagicInfoFinished($$$) {
readingsBulkUpdate( $hash, "lastStatusRequestState", "statusRequest_done" ); readingsBulkUpdate( $hash, "lastStatusRequestState", "statusRequest_done" );
readingsEndUpdate( $hash, 1 );
$hash->{helper}{infoErrorCounter} = 0; $hash->{helper}{infoErrorCounter} = 0;
### End Response Processing ### End Response Processing
$hash->{STATE} = "active" if( $hash->{STATE} eq "initialized" ); #$hash->{STATE} = "active" if( $hash->{STATE} eq "initialized" ); ## STATE direkt setzen ist absolete
readingsBulkUpdate( $hash, "state", "active" ) if( ReadingsVal( $name, "state", 0 ) eq "initialized" );
readingsEndUpdate( $hash, 1 );
return undef; return undef;
} }
@ -451,9 +466,11 @@ sub AMAD_HTTP_POST($$) {
my ( $hash, $url ) = @_; my ( $hash, $url ) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $state = $hash->{STATE}; #my $state = $hash->{STATE};
my $state = ReadingsVal( $name, "state", 0 );
$hash->{STATE} = "Send HTTP POST"; #$hash->{STATE} = "Send HTTP POST";
readingsSingleUpdate( $hash, "state", "Send HTTP POST", 1 );
HttpUtils_NonblockingGet( HttpUtils_NonblockingGet(
{ {
@ -467,7 +484,8 @@ sub AMAD_HTTP_POST($$) {
); );
Log3 $name, 4, "AMAD ($name) - Send HTTP POST with URL $url"; Log3 $name, 4, "AMAD ($name) - Send HTTP POST with URL $url";
$hash->{STATE} = $state; #$hash->{STATE} = $state;
readingsSingleUpdate( $hash, "state", $state, 1 );
return undef; return undef;
} }
@ -489,7 +507,8 @@ sub AMAD_HTTP_POSTerrorHandling($$$) {
Log3 $name, 5, "AMAD ($name) - CHECK THE LAST ERROR READINGS FOR MORE INFO, DEVICE IS SET OFFLINE"; Log3 $name, 5, "AMAD ($name) - CHECK THE LAST ERROR READINGS FOR MORE INFO, DEVICE IS SET OFFLINE";
readingsBulkUpdate( $hash, "deviceState", "offline" ); readingsBulkUpdate( $hash, "deviceState", "offline" );
$hash->{STATE} = "AMAD Flows inactive, device set offline"; #$hash->{STATE} = "AMAD Flows inactive, device set offline"; # STATE direkt setzen ist absolete
readingsBulkUpdate( $hash, "state", "AMAD Flows inactive, device set offline" );
} }
elsif( $hash->{helper}{infoErrorCounter} > 9 && $hash->{helper}{setCmdErrorCounter} > 4 ) { elsif( $hash->{helper}{infoErrorCounter} > 9 && $hash->{helper}{setCmdErrorCounter} > 4 ) {
readingsBulkUpdate($hash, "lastSetCommandError", "unknown error, please contact the developer" ); readingsBulkUpdate($hash, "lastSetCommandError", "unknown error, please contact the developer" );
@ -497,7 +516,8 @@ sub AMAD_HTTP_POSTerrorHandling($$$) {
Log3 $name, 4, "AMAD ($name) - UNKNOWN ERROR, PLEASE CONTACT THE DEVELOPER, DEVICE DISABLED"; Log3 $name, 4, "AMAD ($name) - UNKNOWN ERROR, PLEASE CONTACT THE DEVELOPER, DEVICE DISABLED";
$attr{$name}{disable} = 1; $attr{$name}{disable} = 1;
$hash->{STATE} = "Unknown Error, device disabled"; #$hash->{STATE} = "Unknown Error, device disabled";
readingsBulkUpdate( $hash, "state", "Unknown Error, device disabled" );
$hash->{helper}{infoErrorCounter} = 0; $hash->{helper}{infoErrorCounter} = 0;
$hash->{helper}{setCmdErrorCounter} = 0; $hash->{helper}{setCmdErrorCounter} = 0;
@ -519,7 +539,8 @@ sub AMAD_HTTP_POSTerrorHandling($$$) {
Log3 $name, 4, "AMAD ($name) - To many Errors please check your Network or Device Configuration, DEVICE IS SET OFFLINE"; Log3 $name, 4, "AMAD ($name) - To many Errors please check your Network or Device Configuration, DEVICE IS SET OFFLINE";
readingsBulkUpdate( $hash, "deviceState", "offline" ); readingsBulkUpdate( $hash, "deviceState", "offline" );
$hash->{STATE} = "To many Errors, device set offline"; #$hash->{STATE} = "To many Errors, device set offline"; ## STATE direkt setzen ist absolete
readingsBulkUpdate( $hash, "state", "To many Errors, device set offline" );
$hash->{helper}{setCmdErrorCounter} = 0; $hash->{helper}{setCmdErrorCounter} = 0;
} }
readingsEndUpdate( $hash, 1 ); readingsEndUpdate( $hash, 1 );
@ -527,10 +548,11 @@ sub AMAD_HTTP_POSTerrorHandling($$$) {
if( defined( $err ) ) { if( defined( $err ) ) {
if( $err ne "" ) { if( $err ne "" ) {
$hash->{STATE} = $err if( $hash->{STATE} ne "initialized" ); readingsBeginUpdate( $hash );
#$hash->{STATE} = $err if( $hash->{STATE} ne "initialized" ); ## STATE direkt setzen ist absolete
readingsBulkUpdate( $hash, "state", $err ) if( ReadingsVal( $name, "state", 0 ) ne "initialized" );
$hash->{helper}{setCmdErrorCounter} = ($hash->{helper}{setCmdErrorCounter} + 1); $hash->{helper}{setCmdErrorCounter} = ($hash->{helper}{setCmdErrorCounter} + 1);
readingsBeginUpdate( $hash );
readingsBulkUpdate( $hash, "lastSetCommandState", "cmd_error" ); readingsBulkUpdate( $hash, "lastSetCommandState", "cmd_error" );
if( $err =~ /timed out/ ) { if( $err =~ /timed out/ ) {
@ -550,10 +572,12 @@ sub AMAD_HTTP_POSTerrorHandling($$$) {
} }
if( $data eq "" and exists( $param->{code} ) && $param->{code} ne 200 ) { if( $data eq "" and exists( $param->{code} ) && $param->{code} ne 200 ) {
$hash->{STATE} = $param->{code} if( $hash->{STATE} ne "initialized" ); readingsBeginUpdate( $hash );
#$hash->{STATE} = $param->{code} if( $hash->{STATE} ne "initialized" ); ## STATE direkt setzen ist absolete
readingsBulkUpdate( $hash, "state", $param->{code} ) if( ReadingsVal( $hash, "state", 0 ) ne "initialized" );
$hash->{helper}{setCmdErrorCounter} = ( $hash->{helper}{setCmdErrorCounter} + 1 ); $hash->{helper}{setCmdErrorCounter} = ( $hash->{helper}{setCmdErrorCounter} + 1 );
readingsBeginUpdate( $hash );
readingsBulkUpdate($hash, "lastSetCommandState", "cmd_error" ); readingsBulkUpdate($hash, "lastSetCommandState", "cmd_error" );
readingsBulkUpdate($hash, "lastSetCommandError", "http Error ".$param->{code} ); readingsBulkUpdate($hash, "lastSetCommandError", "http Error ".$param->{code} );
readingsEndUpdate( $hash, 1 ); readingsEndUpdate( $hash, 1 );
@ -564,10 +588,12 @@ sub AMAD_HTTP_POSTerrorHandling($$$) {
} }
if( ( $data =~ /Error/i ) and exists( $param->{code} ) ) { if( ( $data =~ /Error/i ) and exists( $param->{code} ) ) {
$hash->{STATE} = $param->{code} if( $hash->{STATE} ne "initialized" ); readingsBeginUpdate( $hash );
#$hash->{STATE} = $param->{code} if( $hash->{STATE} ne "initialized" ); ## STATE direkt setzen ist absolete
readingsBulkUpdate( $hash, "state", $param->{code} ) if( ReadingsVal( $name, "state", 0 ) ne "initialized" );
$hash->{helper}{setCmdErrorCounter} = ( $hash->{helper}{setCmdErrorCounter} + 1 ); $hash->{helper}{setCmdErrorCounter} = ( $hash->{helper}{setCmdErrorCounter} + 1 );
readingsBeginUpdate( $hash );
readingsBulkUpdate( $hash, "lastSetCommandState", "cmd_error" ); readingsBulkUpdate( $hash, "lastSetCommandState", "cmd_error" );
if( $param->{code} eq 404 ) { if( $param->{code} eq 404 ) {
@ -743,8 +769,157 @@ sub AMAD_SelectSetCmd($$@) {
<a name="AMAD"></a> <a name="AMAD"></a>
<h3>AMAD</h3> <h3>AMAD</h3>
<ul> <ul>
<u><b>AMAD - Automagic Android Device</b></u> <u><b>AMAD - Auto Magic Android Device</b></u>
At the moment no english documentation is available <br>
This module provides, <b><u>in cooperation with the Android APP Auto Magic</u></b>, a variety of information from Android devices.
The AndroidAPP Auto Magic (this 3rd party app and costs 2.90Euro) works better than Tasker and is user-friendly.
The following states can be displayed:
<ul>
<li>State of Automagic on the device</li>
<li>Bluetooth On / Off</li>
<li>Bluetooth devices connected</li>
<li>Current music album played Media Player</li>
<li>Current music artist played Media Player</li>
<li>Current music title played Media Player</li>
<li>State of Android device - Online / Offline</li>
<li>Next alarm day</li>
<li>Next alarm time</li>
<li>Battery state %</li>
<li>Charging State - Charger connected / disconnected</li>
<li>Screen State On / Off</li>
<li>Screen Brightness</li>
<li>Full Screen Mode On / Off</li>
<li>Screen Orientation Auto / Landscape / Portrait</li>
<li>Default volume</li>
<li>Media volume device speaker</li>
<li>Media volume Bluetooth speaker</li>
</ul>
<br>
With some experience lots of information from the Android device can be shown in FHEM. This requires only small adjustments of the "Informations" flow
<br><br>
With this module it is possible to control an Android device as follows.
<ul>
<li>State of the device (Online, Offline)</li>
<li>Media Player control (play, stop, next track, previous track)</li>
<li>Set next alarm time</li>
<li>Open an app on the device</li>
<li>Open a URL in the browser on the device</li>
<li>Set Screen on/off</li>
<li>Adjust the screen brightness</li>
<li>Switch to fullscreen mode</li>
<li>Send a message which appears on the screen</li>
<li>Set screen orientation (Auto / Landscape / Portrait)</li>
<li>Request new status report of the device</li>
<li>Set system commands (Reboot)</li>
<li>Send a message which will be announced (TTS)</li>
<li>Default media volume</li>
</ul>
<br><br>
To perform actions and to obtain information you need the Android App Automagic and a matching Flow. The App you need to get from the app store (google play),
but the modul and the corresponding flow you get from me.
<br><br>
<b>How used AMAD?</b>
<ul>
<li>installed the app "Auto Magic Premium" from the App Store or the trial version from <a href="https://automagic4android.com/de/testversion">here</a></li>
<li>installed the Flowset 74_AMADautomagicFlows$VERSION.xml from the folder $INSTALLFHEM/FHEM/lib/ to your Android device and first activates only the "information" flow.</li>
</ul>
<br>
Now you must define a FHEM device.
<br><br>
<a name="AMADdefine"></a>
<b>Define</b>
<ul><br>
<code>define &lt;name&gt; AMAD &lt;IP-ADDRESS&gt;</code>
<br><br>
Example:
<ul><br>
<code>define TabletLivingRoom AMAD 192.168.0.23</code><br>
</ul>
<br>
This statement creates a new AMAD device. The parameter &lt;IP-ADRESSE&lt; specifies the ip-address of the Android device.
The default interval is 180 seconds and can be changed via the Interval attribute. If you want to change the port, you can do this via the port attribute.
<b>You should know what you're doing, because the TCP port is set into the 2 flows as HTTP Response trigger. Consequently, this must also be changed there.</b><br>
</ul>
<br><br>
<b><u>Done! After connecting the device instance should already come in the first Readings within 3 minutes.</u></b>
<br><br>
<a name="AMADreadings"></a>
<b>Readings</b>
<ul>
<li>automagic state - status messages from the AutomagicApp</li>
<li>bluetooth on / off - is on the device Bluetooth on or off</li>
<li>connectedBTdevices - a list of the connected devices</li>
<li>current Music Album - currently abgespieltes Music Album of the media player used</li>
<li>current music artist - currently played music artist of the media player used</li>
<li>current Music Track - currently played music title of the media player used</li>
<li>deviceState - State of Android device, must itself be set with setreading e.g. about the attendance check. When offline is set, the interval is set off for information retrieval.</li>
<li>flow_SetCommands active / inactive - indicates the status of SetCommands flow again</li>
<li>flow_informations active / inactive - indicates the status of the information flow again</li>
<li>lastSetCommandError - last error message from the set command successfully / not sent last status from the set command, command is successful - lastSetCommandState</li>
<li>lastSetCommandState cmd_done / cmd_error - state of last SetCommand command</li>
<li>lastStatusRequestError - last error message from the status request command successfully / not sent last status from the status request command, command is successful - load status RequestStateChange</li>
<li>lastStatusRequestState statusRequest_done / statusRequest_error - state of last statusRequest command</li>
<li>nextAlarmDay - active alarm day</li>
<li>next alarmTime - active alarm time</li>
<li>powerlevel - status of the battery in %</li>
<li>powerPlugged - connected power supply? 0=NO, 1|2=YES</li>
<li>screen - screen on/off</li>
<li>Screen Brightness - Screen Brightness from 0-255</li>
<li>Screen fullscreen - fullscreen mode (On, Off)</li>
<li>screenOrientation - screen orientation (Auto, Landscape, Portrait)</li>
<li>volume - volume value which was set on "Set volume".</li>
<li>volume Music Bluetooth - Media volume of the Bluetooth speakers</li>
<li>volume music speaker - Media volume of the internal speakers</li>
<br>
The Readings volume Music Bluetooth and music speaker volume reflect the respective media volume of the closed border is Bluetooth speakers or the internal speaker again.
Unless one the respective volumes relies exclusively on the Set command, one of the two will always agree with the "volume" Reading a.
</ul>
<br><br>
<a name="AMADset"></a>
<b>Set</b>
<ul>
<li>Device State - sets the Device Status Online / Offline. See Readings</li>
<li>Media Player - controls the default media player. Play, Stop, Back Route title, ahead of title.</li>
<li>NextAlarm time - sets the alarm time. only within the next 24hrs.</li>
<li>openURL - opens a URL in your default browser</li>
<li>screen - are sets the screen on / off with barrier in the car Magic settings must "Admin Function" set will not work "Screen off".</li>
<li>screenMsg - sends a message screen</li>
<li>Status Request - calls for a new Status Report in Device to</li>
<li>ttsMsg - sends a message which is output as a voice message</li>
<li>volume - sets the media volume. Either the internal speakers or when connected the Bluetooth speaker</li>
</ul>
<br>
<b>Set depending on set attributes</b>
<ul>
<li>mediaPlayer - controls the default media player. Play, Stop, Back Route title, ahead of title. <b>Attribute fhemServerIP</b></li>
<li>openapp - opens a selected app. <b>Attribute setOpenApp</b></li>
<li>screen Brightness - sets the screen brightness, 0-255 <b>Attribute setScreenBrightness</b></li>
If you want to use the "set screen brightness", a small adjustment in the flow SetCommands must be made. Opens the action (one of the squares very bottom) Set System Settings: System and makes a check "I have checked the settings, I know what I'm doing".
<li>screen fullscreen - Switches to full screen mode on / off. <b>Attribute SetFullscreen </b></li>
<li>screenOrientation - Switches the screen orientation Auto / Landscape / Portrait. <b>Attribute setScreenOrientation</b></li>
<li>system - set system commands from (only rooted devices). Reboot <b>Attribut root</b>, in the Auto Magic Settings "root function" must be set</li>
Must be separated as an attribute, or a comma, several app names are set in order to use openapp. The app name is arbitrary and only required for recognition. The same app name must flow in SetCommands on the left below the hash expression: "openapp" be in one of the 5 strands (one app per strand) entered in both diamonds. Thereafter, in the quadrangle selected the app which app through the attribute names should be started.
</ul>
<br><br>
<a name="AMADstate"></a>
<b>state</b>
<ul>
<li>initialized - If the status shortly after a define.</li>
<li>active - the device instance is in active status.</li>
<li>disabled - the device instance has been disabled via the disable attribute</li>
</ul>
<br><br><br>
<u><b>Application examples:</b></u>
<ul><br>
I have the chargers for my Android devices on wireless switch sockets. a DOIF switches less than 30% the power outlet and more than 90% again. In the morning I'll wake up with music from my tablet in the bedroom. This involves the use of the wakeuptimer the RESIDENTS Modules. I stop the music manually. After that the weather forecast will be told (through TTS).<br>
My 10 "Tablet in the living room is media player for the living room with Bluetooth speakers. The volume is automatically set down when the Fritzbox signals a incoming call on the living room handset.
</ul>
<br><br><br>
<b><u>And finally I would like to say thank you.</u><br>
The biggest thank goes to my mentor Andre (justme1968), he told me with useful hints that helped me to understandPerl code and made programming a real fun.<br>
I would also like to thank Jens (jensb) who has supported me when I made my first steps in Perl code.<br>
And lastbut not least a special thank to PAH (Prof. Dr. Peter Henning), without his statement "We had all times of 'I do not know', that's no excuse," I would not have started to get interested in module development :-)<br><br>
Thanks to J&uuml;rgen (ujaudio) for the english translation</b>
</ul> </ul>
=end html =end html
@ -754,6 +929,7 @@ sub AMAD_SelectSetCmd($$@) {
<h3>AMAD</h3> <h3>AMAD</h3>
<ul> <ul>
<u><b>AMAD - Automagic Android Device</b></u> <u><b>AMAD - Automagic Android Device</b></u>
<br>
Dieses Modul liefert, <b><u>in Verbindung mit der Android APP Automagic</u></b>, diverse Informationen von Android Ger&auml;ten. Dieses Modul liefert, <b><u>in Verbindung mit der Android APP Automagic</u></b>, diverse Informationen von Android Ger&auml;ten.
Die AndroidAPP Automagic (welche nicht von mir stammt und 2.90Euro kostet) funktioniert wie Tasker, ist aber bei weitem User freundlicher. Die AndroidAPP Automagic (welche nicht von mir stammt und 2.90Euro kostet) funktioniert wie Tasker, ist aber bei weitem User freundlicher.
Im Auslieferiungszustand werden folgende Zust&auml;nde dargestellt: Im Auslieferiungszustand werden folgende Zust&auml;nde dargestellt:
@ -769,7 +945,7 @@ sub AMAD_SelectSetCmd($$@) {
<li>n&auml;chste Alarmzeit</li> <li>n&auml;chste Alarmzeit</li>
<li>Batteriestatus in %</li> <li>Batteriestatus in %</li>
<li>Ladestatus - Netztei angeschlossen / nicht angeschlossen</li> <li>Ladestatus - Netztei angeschlossen / nicht angeschlossen</li>
<li>Bildschirnstatus An/Aus</li> <li>Bildschirmstatus An/Aus</li>
<li>Bildschirmhelligkeit</li> <li>Bildschirmhelligkeit</li>
<li>Vollbildmodus An/Aus</li> <li>Vollbildmodus An/Aus</li>
<li>Bildschirmausrichtung Auto/Landscape/Portrait</li> <li>Bildschirmausrichtung Auto/Landscape/Portrait</li>
@ -848,7 +1024,7 @@ sub AMAD_SelectSetCmd($$@) {
<li>nextAlarmDay - aktiver Alarmtag</li> <li>nextAlarmDay - aktiver Alarmtag</li>
<li>nextAlarmTime - aktive Alarmzeit</li> <li>nextAlarmTime - aktive Alarmzeit</li>
<li>powerLevel - Status der Batterie in %</li> <li>powerLevel - Status der Batterie in %</li>
<li>powerPlugged - Netzteil angeschlossen? 0=NEIN, 2=JA</li> <li>powerPlugged - Netzteil angeschlossen? 0=NEIN, 1|2=JA</li>
<li>screen - Bildschirm An oderAus</li> <li>screen - Bildschirm An oderAus</li>
<li>screenBrightness - Bildschirmhelligkeit von 0-255</li> <li>screenBrightness - Bildschirmhelligkeit von 0-255</li>
<li>screenFullscreen - Vollbildmodus (On,Off)</li> <li>screenFullscreen - Vollbildmodus (On,Off)</li>
@ -892,9 +1068,9 @@ sub AMAD_SelectSetCmd($$@) {
</ul> </ul>
<br><br> <br><br>
<a name="AMADstate"></a> <a name="AMADstate"></a>
<b>STATE</b> <b>state</b>
<ul> <ul>
<li>initialized - Ist der Status kurz nach einem define..</li> <li>initialized - Ist der Status kurz nach einem define.</li>
<li>active - die Ger&auml;teinstanz ist im aktiven Status.</li> <li>active - die Ger&auml;teinstanz ist im aktiven Status.</li>
<li>disabled - die Ger&auml;teinstanz wurde &uuml;ber das Attribut disable deaktiviert</li> <li>disabled - die Ger&auml;teinstanz wurde &uuml;ber das Attribut disable deaktiviert</li>
</ul> </ul>