Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
91110ea98b | |||
4df083cbf9 | |||
b9708a909d | |||
9727c85bde | |||
552efdf558 | |||
2ec50eaec3 | |||
73fcfb63d9 | |||
f2fe1ee8be | |||
bb9705ef8b | |||
2513af243b | |||
92d42b2e19 |
551
74_HOMBOT.pm
551
74_HOMBOT.pm
@ -35,7 +35,7 @@ use Time::HiRes qw(gettimeofday);
|
|||||||
use HttpUtils;
|
use HttpUtils;
|
||||||
use Blocking;
|
use Blocking;
|
||||||
|
|
||||||
my $version = "0.1.60";
|
my $version = "0.2.5";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -48,16 +48,17 @@ sub HOMBOT_Initialize($) {
|
|||||||
$hash->{DefFn} = "HOMBOT_Define";
|
$hash->{DefFn} = "HOMBOT_Define";
|
||||||
$hash->{UndefFn} = "HOMBOT_Undef";
|
$hash->{UndefFn} = "HOMBOT_Undef";
|
||||||
$hash->{AttrFn} = "HOMBOT_Attr";
|
$hash->{AttrFn} = "HOMBOT_Attr";
|
||||||
|
$hash->{FW_detailFn} = "HOMBOT_DetailFn";
|
||||||
|
|
||||||
$hash->{AttrList} = "interval ".
|
$hash->{AttrList} = "interval ".
|
||||||
"disable:1 ".
|
"disable:1 ".
|
||||||
$readingFnAttributes;
|
$readingFnAttributes;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach my $d(sort keys %{$modules{HOMBOT}{defptr}}) {
|
foreach my $d(sort keys %{$modules{HOMBOT}{defptr}}) {
|
||||||
my $hash = $modules{HOMBOT}{defptr}{$d};
|
my $hash = $modules{HOMBOT}{defptr}{$d};
|
||||||
$hash->{VERSION} = $version;
|
$hash->{VERSION} = $version;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +68,13 @@ sub HOMBOT_Define($$) {
|
|||||||
|
|
||||||
my @a = split( "[ \t][ \t]*", $def );
|
my @a = split( "[ \t][ \t]*", $def );
|
||||||
|
|
||||||
|
|
||||||
return "too few parameters: define <name> HOMBOT <HOST>" if( @a != 3 );
|
return "too few parameters: define <name> HOMBOT <HOST>" if( @a != 3 );
|
||||||
|
return "please check if ssh installed" unless( -X "/usr/bin/ssh" );
|
||||||
|
return "please check if $attr{global}{modpath}/.ssh/known_hosts or /root/.ssh/known_hosts exist" unless( -R "$attr{global}{modpath}/.ssh/known_hosts" or -R "/root/.ssh/known_hosts" );
|
||||||
|
return "please check if sshpass installed" unless( -X "/usr/bin/sshpass" or -X "/usr/local/bin/sshpass" );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
my $name = $a[0];
|
my $name = $a[0];
|
||||||
my $host = $a[2];
|
my $host = $a[2];
|
||||||
@ -80,6 +87,8 @@ sub HOMBOT_Define($$) {
|
|||||||
$hash->{VERSION} = $version;
|
$hash->{VERSION} = $version;
|
||||||
$hash->{helper}{requestErrorCounter} = 0;
|
$hash->{helper}{requestErrorCounter} = 0;
|
||||||
$hash->{helper}{setErrorCounter} = 0;
|
$hash->{helper}{setErrorCounter} = 0;
|
||||||
|
$hash->{helper}{sshpass} = "/usr/bin/sshpass";
|
||||||
|
$hash->{helper}{sshpass} = "/usr/local/bin/sshpass" unless( -X "/usr/bin/sshpass");
|
||||||
|
|
||||||
|
|
||||||
Log3 $name, 3, "HOMBOT ($name) - defined with host $hash->{HOST} on port $hash->{PORT} and interval $hash->{INTERVAL} (sec)";
|
Log3 $name, 3, "HOMBOT ($name) - defined with host $hash->{HOST} on port $hash->{PORT} and interval $hash->{INTERVAL} (sec)";
|
||||||
@ -117,56 +126,56 @@ sub HOMBOT_Attr(@) {
|
|||||||
my $hash = $defs{$name};
|
my $hash = $defs{$name};
|
||||||
|
|
||||||
if( $attrName eq "disable" ) {
|
if( $attrName eq "disable" ) {
|
||||||
if( $cmd eq "set" ) {
|
if( $cmd eq "set" ) {
|
||||||
if( $attrVal eq "0" ) {
|
if( $attrVal eq "0" ) {
|
||||||
RemoveInternalTimer( $hash );
|
RemoveInternalTimer( $hash );
|
||||||
InternalTimer( gettimeofday()+2, "HOMBOT_Get_stateRequest", $hash, 0 ) if( ReadingsVal( $hash->{NAME}, "state", 0 ) eq "disabled" );
|
InternalTimer( gettimeofday()+2, "HOMBOT_Get_stateRequest", $hash, 0 ) if( ReadingsVal( $hash->{NAME}, "state", 0 ) eq "disabled" );
|
||||||
readingsSingleUpdate ( $hash, "state", "active", 1 );
|
readingsSingleUpdate ( $hash, "state", "active", 1 );
|
||||||
Log3 $name, 3, "HOMBOT ($name) - enabled";
|
Log3 $name, 3, "HOMBOT ($name) - enabled";
|
||||||
} else {
|
} else {
|
||||||
readingsSingleUpdate ( $hash, "state", "disabled", 1 );
|
readingsSingleUpdate ( $hash, "state", "disabled", 1 );
|
||||||
RemoveInternalTimer( $hash );
|
RemoveInternalTimer( $hash );
|
||||||
Log3 $name, 3, "HOMBOT ($name) - disabled";
|
Log3 $name, 3, "HOMBOT ($name) - disabled";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif( $cmd eq "del" ) {
|
elsif( $cmd eq "del" ) {
|
||||||
RemoveInternalTimer( $hash );
|
RemoveInternalTimer( $hash );
|
||||||
InternalTimer( gettimeofday()+2, "HOMBOT_Get_stateRequest", $hash, 0 ) if( ReadingsVal( $hash->{NAME}, "state", 0 ) eq "disabled" );
|
InternalTimer( gettimeofday()+2, "HOMBOT_Get_stateRequest", $hash, 0 ) if( ReadingsVal( $hash->{NAME}, "state", 0 ) eq "disabled" );
|
||||||
readingsSingleUpdate ( $hash, "state", "active", 1 );
|
readingsSingleUpdate ( $hash, "state", "active", 1 );
|
||||||
Log3 $name, 3, "HOMBOT ($name) - enabled";
|
Log3 $name, 3, "HOMBOT ($name) - enabled";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if($cmd eq "set") {
|
if($cmd eq "set") {
|
||||||
$attr{$name}{$attrName} = $attrVal;
|
$attr{$name}{$attrName} = $attrVal;
|
||||||
Log3 $name, 3, "HOMBOT ($name) - $attrName : $attrVal";
|
Log3 $name, 3, "HOMBOT ($name) - $attrName : $attrVal";
|
||||||
}
|
}
|
||||||
elsif( $cmd eq "del" ) {
|
elsif( $cmd eq "del" ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( $attrName eq "interval" ) {
|
if( $attrName eq "interval" ) {
|
||||||
if( $cmd eq "set" ) {
|
if( $cmd eq "set" ) {
|
||||||
if( $attrVal < 60 ) {
|
if( $attrVal < 60 ) {
|
||||||
Log3 $name, 3, "HOMBOT ($name) - interval too small, please use something > 60 (sec), default is 180 (sec)";
|
Log3 $name, 3, "HOMBOT ($name) - interval too small, please use something > 60 (sec), default is 180 (sec)";
|
||||||
return "interval too small, please use something > 60 (sec), default is 180 (sec)";
|
return "interval too small, please use something > 60 (sec), default is 180 (sec)";
|
||||||
} else {
|
} else {
|
||||||
$hash->{INTERVAL} = $attrVal;
|
$hash->{INTERVAL} = $attrVal;
|
||||||
Log3 $name, 3, "HOMBOT ($name) - set interval to $attrVal";
|
Log3 $name, 3, "HOMBOT ($name) - set interval to $attrVal";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif( $cmd eq "del" ) {
|
elsif( $cmd eq "del" ) {
|
||||||
$hash->{INTERVAL} = 180;
|
$hash->{INTERVAL} = 180;
|
||||||
Log3 $name, 3, "HOMBOT ($name) - set interval to default";
|
Log3 $name, 3, "HOMBOT ($name) - set interval to default";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if( $cmd eq "set" ) {
|
if( $cmd eq "set" ) {
|
||||||
$attr{$name}{$attrName} = $attrVal;
|
$attr{$name}{$attrName} = $attrVal;
|
||||||
Log3 $name, 3, "HOMBOT ($name) - $attrName : $attrVal";
|
Log3 $name, 3, "HOMBOT ($name) - $attrName : $attrVal";
|
||||||
}
|
}
|
||||||
elsif( $cmd eq "del" ) {
|
elsif( $cmd eq "del" ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
@ -220,16 +229,16 @@ sub HOMBOT_getStatusTXT($) {
|
|||||||
|
|
||||||
|
|
||||||
HttpUtils_NonblockingGet(
|
HttpUtils_NonblockingGet(
|
||||||
{
|
{
|
||||||
url => $url,
|
url => $url,
|
||||||
timeout => 10,
|
timeout => 10,
|
||||||
hash => $hash,
|
hash => $hash,
|
||||||
method => "GET",
|
method => "GET",
|
||||||
doTrigger => 1,
|
doTrigger => 1,
|
||||||
callback => \&HOMBOT_RetrieveHomebotInfoFinished,
|
callback => \&HOMBOT_RetrieveHomebotInfoFinished,
|
||||||
id => "statustxt",
|
id => "statustxt",
|
||||||
}
|
});
|
||||||
);
|
|
||||||
Log3 $name, 4, "HOMBOT ($name) - NonblockingGet get URL";
|
Log3 $name, 4, "HOMBOT ($name) - NonblockingGet get URL";
|
||||||
Log3 $name, 4, "HOMBOT ($name) - HOMBOT_Retrieve status.txt Information: calling Host: $host";
|
Log3 $name, 4, "HOMBOT ($name) - HOMBOT_Retrieve status.txt Information: calling Host: $host";
|
||||||
}
|
}
|
||||||
@ -246,16 +255,16 @@ sub HOMBOT_getStatisticHTML($) {
|
|||||||
|
|
||||||
|
|
||||||
HttpUtils_NonblockingGet(
|
HttpUtils_NonblockingGet(
|
||||||
{
|
{
|
||||||
url => $url,
|
url => $url,
|
||||||
timeout => 10,
|
timeout => 10,
|
||||||
hash => $hash,
|
hash => $hash,
|
||||||
method => "GET",
|
method => "GET",
|
||||||
doTrigger => 1,
|
doTrigger => 1,
|
||||||
callback => \&HOMBOT_RetrieveHomebotInfoFinished,
|
callback => \&HOMBOT_RetrieveHomebotInfoFinished,
|
||||||
id => "statistichtml",
|
id => "statistichtml",
|
||||||
}
|
});
|
||||||
);
|
|
||||||
Log3 $name, 4, "HOMBOT ($name) - NonblockingGet get URL";
|
Log3 $name, 4, "HOMBOT ($name) - NonblockingGet get URL";
|
||||||
Log3 $name, 4, "HOMBOT ($name) - HOMBOT_Retrieve statistic.html Information: calling Host: $host";
|
Log3 $name, 4, "HOMBOT ($name) - HOMBOT_Retrieve statistic.html Information: calling Host: $host";
|
||||||
}
|
}
|
||||||
@ -272,16 +281,16 @@ sub HOMBOT_getSchedule($) {
|
|||||||
|
|
||||||
|
|
||||||
HttpUtils_NonblockingGet(
|
HttpUtils_NonblockingGet(
|
||||||
{
|
{
|
||||||
url => $url,
|
url => $url,
|
||||||
timeout => 10,
|
timeout => 10,
|
||||||
hash => $hash,
|
hash => $hash,
|
||||||
method => "GET",
|
method => "GET",
|
||||||
doTrigger => 1,
|
doTrigger => 1,
|
||||||
callback => \&HOMBOT_RetrieveHomebotInfoFinished,
|
callback => \&HOMBOT_RetrieveHomebotInfoFinished,
|
||||||
id => "schedule",
|
id => "schedule",
|
||||||
}
|
});
|
||||||
);
|
|
||||||
Log3 $name, 4, "HOMBOT ($name) - NonblockingGet get URL";
|
Log3 $name, 4, "HOMBOT ($name) - NonblockingGet get URL";
|
||||||
Log3 $name, 4, "HOMBOT ($name) - HOMBOT_Retrieve Schedule Information: calling Host: $host";
|
Log3 $name, 4, "HOMBOT ($name) - HOMBOT_Retrieve Schedule Information: calling Host: $host";
|
||||||
}
|
}
|
||||||
@ -302,57 +311,58 @@ sub HOMBOT_RetrieveHomebotInfoFinished($$$) {
|
|||||||
### Begin Error Handling
|
### Begin Error Handling
|
||||||
if( $hash->{helper}{requestErrorCounter} > 1 ) {
|
if( $hash->{helper}{requestErrorCounter} > 1 ) {
|
||||||
|
|
||||||
readingsSingleUpdate( $hash, "lastStatusRequestState", "statusRequest_error", 1 );
|
readingsSingleUpdate( $hash, "lastStatusRequestState", "statusRequest_error", 1 );
|
||||||
|
|
||||||
|
if( $hash->{helper}{requestErrorCounter} > 1 && ReadingsVal( $name, "luigiHttpSrvState", "not running" ) eq "running" ) {
|
||||||
|
|
||||||
if( $hash->{helper}{requestErrorCounter} > 1 && ReadingsVal( $name, "luigiHttpSrvState", "not running" ) eq "running" ) {
|
Log3 $name, 3, "HOMBOT ($name) - Connecting Problem, will check Luigi HTTP Server" unless(exists($hash->{helper}{RUNNING_PID}));
|
||||||
|
|
||||||
Log3 $name, 3, "HOMBOT ($name) - Connecting Problem, will check Luigi HTTP Server" unless(exists($hash->{helper}{RUNNING_PID}));
|
$hash->{helper}{RUNNING_PID} = BlockingCall("HOMBOT_Check_Bot_Alive", $name."|request", "HOMBOT_Evaluation_Bot_Alive", 15, "HOMBOT_Aborted_Bot_Alive", $hash) unless(exists($hash->{helper}{RUNNING_PID}));
|
||||||
|
|
||||||
$hash->{helper}{RUNNING_PID} = BlockingCall("HOMBOT_Check_Bot_Alive", $name."|request", "HOMBOT_Evaluation_Bot_Alive", 15, "HOMBOT_Aborted_Bot_Alive", $hash) unless(exists($hash->{helper}{RUNNING_PID}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
readingsBeginUpdate( $hash );
|
readingsBeginUpdate( $hash );
|
||||||
|
|
||||||
if( $hash->{helper}{requestErrorCounter} > 6 && $hash->{helper}{setErrorCounter} > 3 && ReadingsVal( $name, "luigiHttpSrvState", "running" ) eq "running" ) {
|
if( $hash->{helper}{requestErrorCounter} > 6 && $hash->{helper}{setErrorCounter} > 3 && ReadingsVal( $name, "luigiHttpSrvState", "running" ) eq "running" ) {
|
||||||
|
|
||||||
readingsBulkUpdate( $hash, "lastStatusRequestError", "unknown error, please contact the developer" );
|
readingsBulkUpdate( $hash, "lastStatusRequestError", "unknown error, please contact the developer" );
|
||||||
|
|
||||||
Log3 $name, 4, "HOMBOT ($name) - UNKNOWN ERROR, PLEASE CONTACT THE DEVELOPER, DEVICE DISABLED";
|
Log3 $name, 4, "HOMBOT ($name) - UNKNOWN ERROR, PLEASE CONTACT THE DEVELOPER, DEVICE DISABLED";
|
||||||
|
|
||||||
$attr{$name}{disable} = 1;
|
$attr{$name}{disable} = 1;
|
||||||
readingsBulkUpdate ( $hash, "state", "Unknown Error, device disabled");
|
readingsBulkUpdate ( $hash, "state", "Unknown Error, device disabled");
|
||||||
|
|
||||||
$hash->{helper}{requestErrorCounter} = 0;
|
$hash->{helper}{requestErrorCounter} = 0;
|
||||||
$hash->{helper}{setErrorCounter} = 0;
|
$hash->{helper}{setErrorCounter} = 0;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( $hash->{helper}{requestErrorCounter} > 6 && $hash->{helper}{setErrorCounter} == 0 && ReadingsVal( $name, "luigiHttpSrvState", "running" ) eq "running" ) {
|
if( $hash->{helper}{requestErrorCounter} > 6 && $hash->{helper}{setErrorCounter} == 0 && ReadingsVal( $name, "luigiHttpSrvState", "running" ) eq "running" ) {
|
||||||
readingsBulkUpdate( $hash, "lastStatusRequestError", "Homebot is offline" );
|
readingsBulkUpdate( $hash, "lastStatusRequestError", "Homebot is offline" );
|
||||||
|
|
||||||
Log3 $name, 4, "HOMBOT ($name) - Homebot is offline";
|
Log3 $name, 4, "HOMBOT ($name) - Homebot is offline";
|
||||||
|
|
||||||
readingsBulkUpdate ( $hash, "hombotState", "OFFLINE");
|
readingsBulkUpdate ( $hash, "hombotState", "OFFLINE");
|
||||||
readingsBulkUpdate ( $hash, "state", "Homebot offline");
|
readingsBulkUpdate ( $hash, "state", "Homebot offline");
|
||||||
|
|
||||||
$hash->{helper}{requestErrorCounter} = 0;
|
$hash->{helper}{requestErrorCounter} = 0;
|
||||||
$hash->{helper}{setErrorCounter} = 0;
|
$hash->{helper}{setErrorCounter} = 0;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif( $hash->{helper}{requestErrorCounter} > 6 && $hash->{helper}{setErrorCounter} > 0 && ReadingsVal( $name, "luigiHttpSrvState", "running" ) eq "running" ) {
|
elsif( $hash->{helper}{requestErrorCounter} > 6 && $hash->{helper}{setErrorCounter} > 0 && ReadingsVal( $name, "luigiHttpSrvState", "running" ) eq "running" ) {
|
||||||
readingsBulkUpdate( $hash, "lastStatusRequestError", "to many errors, check your network configuration" );
|
readingsBulkUpdate( $hash, "lastStatusRequestError", "to many errors, check your network configuration" );
|
||||||
|
|
||||||
Log3 $name, 4, "HOMBOT ($name) - To many Errors please check your Network Configuration";
|
Log3 $name, 4, "HOMBOT ($name) - To many Errors please check your Network Configuration";
|
||||||
|
|
||||||
|
readingsBulkUpdate ( $hash, "hombotState", "OFFLINE");
|
||||||
|
readingsBulkUpdate ( $hash, "state", "To many Errors");
|
||||||
|
$hash->{helper}{requestErrorCounter} = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
readingsEndUpdate( $hash, 1 );
|
||||||
|
|
||||||
readingsBulkUpdate ( $hash, "hombotState", "OFFLINE");
|
|
||||||
readingsBulkUpdate ( $hash, "state", "To many Errors");
|
|
||||||
$hash->{helper}{requestErrorCounter} = 0;
|
|
||||||
}
|
|
||||||
readingsEndUpdate( $hash, 1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( defined( $err ) && $err ne "" ) {
|
if( defined( $err ) && $err ne "" ) {
|
||||||
@ -364,37 +374,37 @@ sub HOMBOT_RetrieveHomebotInfoFinished($$$) {
|
|||||||
readingsBulkUpdate( $hash, "lastStatusRequestState", "statusRequest_error" );
|
readingsBulkUpdate( $hash, "lastStatusRequestState", "statusRequest_error" );
|
||||||
readingsBulkUpdate($hash, "lastStatusRequestError", $err );
|
readingsBulkUpdate($hash, "lastStatusRequestError", $err );
|
||||||
|
|
||||||
readingsEndUpdate( $hash, 1 );
|
readingsEndUpdate( $hash, 1 );
|
||||||
|
|
||||||
Log3 $name, 4, "HOMBOT ($name) - HOMBOT_Parse_HomebotInfomations: error while request: $err";
|
Log3 $name, 4, "HOMBOT ($name) - HOMBOT_Parse_HomebotInfomations: error while request: $err";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif( $data eq "" and exists( $param->{code} ) ) {
|
elsif( $data eq "" and exists( $param->{code} ) ) {
|
||||||
readingsBeginUpdate( $hash );
|
readingsBeginUpdate( $hash );
|
||||||
readingsBulkUpdate ( $hash, "state", $param->{code} ) if( ReadingsVal( $name, "state", 1 ) ne "initialized" );
|
readingsBulkUpdate ( $hash, "state", $param->{code} ) if( ReadingsVal( $name, "state", 1 ) ne "initialized" );
|
||||||
$hash->{helper}{requestErrorCounter} = ( $hash->{helper}{requestErrorCounter} + 1 );
|
$hash->{helper}{requestErrorCounter} = ( $hash->{helper}{requestErrorCounter} + 1 );
|
||||||
|
|
||||||
readingsBulkUpdate( $hash, "lastStatusRequestState", "statusRequest_error" );
|
readingsBulkUpdate( $hash, "lastStatusRequestState", "statusRequest_error" );
|
||||||
|
|
||||||
if( $param->{code} ne 200 ) {
|
if( $param->{code} ne 200 ) {
|
||||||
readingsBulkUpdate( $hash," lastStatusRequestError", "http Error ".$param->{code} );
|
readingsBulkUpdate( $hash," lastStatusRequestError", "http Error ".$param->{code} );
|
||||||
}
|
}
|
||||||
|
|
||||||
readingsBulkUpdate( $hash, "lastStatusRequestError", "empty response" );
|
readingsBulkUpdate( $hash, "lastStatusRequestError", "empty response" );
|
||||||
readingsEndUpdate( $hash, 1 );
|
readingsEndUpdate( $hash, 1 );
|
||||||
|
|
||||||
Log3 $name, 4, "HOMBOT ($name) - HOMBOT_RetrieveHomebotInfomationsFinished: received http code ".$param->{code}." without any data after requesting HOMBOT Device";
|
Log3 $name, 4, "HOMBOT ($name) - HOMBOT_RetrieveHomebotInfomationsFinished: received http code ".$param->{code}." without any data after requesting HOMBOT Device";
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif( ( $data =~ /Error/i ) and exists( $param->{code} ) ) {
|
elsif( ( $data =~ /Error/i ) and exists( $param->{code} ) ) {
|
||||||
readingsBeginUpdate( $hash );
|
readingsBeginUpdate( $hash );
|
||||||
readingsBulkUpdate( $hash, "state", $param->{code} ) if( ReadingsVal( $name, "state" ,0) ne "initialized" );
|
readingsBulkUpdate( $hash, "state", $param->{code} ) if( ReadingsVal( $name, "state" ,0) ne "initialized" );
|
||||||
$hash->{helper}{requestErrorCounter} = ( $hash->{helper}{requestErrorCounter} + 1 );
|
$hash->{helper}{requestErrorCounter} = ( $hash->{helper}{requestErrorCounter} + 1 );
|
||||||
|
|
||||||
readingsBulkUpdate( $hash, "lastStatusRequestState", "statusRequest_error" );
|
readingsBulkUpdate( $hash, "lastStatusRequestState", "statusRequest_error" );
|
||||||
|
|
||||||
if( $param->{code} eq 404 ) {
|
if( $param->{code} eq 404 ) {
|
||||||
readingsBulkUpdate( $hash, "lastStatusRequestError", "HTTP Server at Homebot offline" );
|
readingsBulkUpdate( $hash, "lastStatusRequestError", "HTTP Server at Homebot offline" );
|
||||||
@ -402,11 +412,11 @@ sub HOMBOT_RetrieveHomebotInfoFinished($$$) {
|
|||||||
readingsBulkUpdate( $hash, "lastStatusRequestError", "http error ".$param->{code} );
|
readingsBulkUpdate( $hash, "lastStatusRequestError", "http error ".$param->{code} );
|
||||||
}
|
}
|
||||||
|
|
||||||
readingsEndUpdate( $hash, 1 );
|
readingsEndUpdate( $hash, 1 );
|
||||||
|
|
||||||
Log3 $name, 4, "HOMBOT ($name) - HOMBOT_Parse_HomebotInfomations: received http code ".$param->{code}." receive Error after requesting HOMBOT";
|
Log3 $name, 4, "HOMBOT ($name) - HOMBOT_Parse_HomebotInfomations: received http code ".$param->{code}." receive Error after requesting HOMBOT";
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
### End Error Handling
|
### End Error Handling
|
||||||
@ -452,11 +462,18 @@ sub HOMBOT_RetrieveHomebotInfoFinished($$$) {
|
|||||||
$t =~ s/JSON_TURBO/turbo/g;
|
$t =~ s/JSON_TURBO/turbo/g;
|
||||||
$t =~ s/JSON_ROBOT_STATE/hombotState/g;
|
$t =~ s/JSON_ROBOT_STATE/hombotState/g;
|
||||||
$t =~ s/CLREC_CURRENTBUMPING/currentBumping/g;
|
$t =~ s/CLREC_CURRENTBUMPING/currentBumping/g;
|
||||||
$t =~ s/CLREC_LAST_CLEAN/lastClean/g;
|
|
||||||
|
if( $t eq "CLREC_LAST_CLEAN" ) {
|
||||||
|
my @lctime = split( '/' , $v );
|
||||||
|
$v = $lctime[2].".".$lctime[1].".".$lctime[0]." ".$lctime[3].":".$lctime[4];
|
||||||
|
$t = "lastClean";
|
||||||
|
}
|
||||||
|
|
||||||
$t =~ s/JSON_BATTPERC/batteryPercent/g;
|
$t =~ s/JSON_BATTPERC/batteryPercent/g;
|
||||||
$t =~ s/JSON_VERSION/firmware/g;
|
$t =~ s/JSON_VERSION/firmware/g;
|
||||||
$t =~ s/LGSRV_VERSION/luigiSrvVersion/g;
|
$t =~ s/LGSRV_VERSION/luigiSrvVersion/g;
|
||||||
|
|
||||||
|
|
||||||
readingsBulkUpdate( $hash, $t, $v ) if( $t =~ m/[a-z]/s && defined( $t ) && defined( $v ) );
|
readingsBulkUpdate( $hash, $t, $v ) if( $t =~ m/[a-z]/s && defined( $t ) && defined( $v ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -536,42 +553,42 @@ sub HOMBOT_Set($$@) {
|
|||||||
my ( $hash, $name, $cmd, @val ) = @_;
|
my ( $hash, $name, $cmd, @val ) = @_;
|
||||||
|
|
||||||
|
|
||||||
my $list = "";
|
my $list = "";
|
||||||
$list .= "cleanStart:noArg ";
|
$list .= "cleanStart:noArg ";
|
||||||
$list .= "homing:noArg ";
|
$list .= "homing:noArg ";
|
||||||
$list .= "pause:noArg ";
|
$list .= "pause:noArg ";
|
||||||
$list .= "statusRequest:noArg ";
|
$list .= "statusRequest:noArg ";
|
||||||
$list .= "cleanMode:SB,ZZ,SPOT ";
|
$list .= "cleanMode:SB,ZZ,SPOT ";
|
||||||
$list .= "repeat:true,false ";
|
$list .= "repeat:true,false ";
|
||||||
$list .= "turbo:true,false ";
|
$list .= "turbo:true,false ";
|
||||||
$list .= "nickname " ;
|
$list .= "nickname ";
|
||||||
$list .= "schedule " ;
|
$list .= "schedule ";
|
||||||
|
|
||||||
|
|
||||||
if( lc $cmd eq 'cleanstart'
|
if( lc $cmd eq 'cleanstart'
|
||||||
|| lc $cmd eq 'homing'
|
|| lc $cmd eq 'homing'
|
||||||
|| lc $cmd eq 'pause'
|
|| lc $cmd eq 'pause'
|
||||||
|| lc $cmd eq 'statusrequest'
|
|| lc $cmd eq 'statusrequest'
|
||||||
|| lc $cmd eq 'cleanmode'
|
|| lc $cmd eq 'cleanmode'
|
||||||
|| lc $cmd eq 'repeat'
|
|| lc $cmd eq 'repeat'
|
||||||
|| lc $cmd eq 'turbo'
|
|| lc $cmd eq 'turbo'
|
||||||
|| lc $cmd eq 'nickname'
|
|| lc $cmd eq 'nickname'
|
||||||
|| lc $cmd eq 'schedule' ) {
|
|| lc $cmd eq 'schedule' ) {
|
||||||
|
|
||||||
Log3 $name, 5, "HOMBOT ($name) - set $name $cmd ".join(" ", @val);
|
Log3 $name, 5, "HOMBOT ($name) - set $name $cmd ".join(" ", @val);
|
||||||
|
|
||||||
|
|
||||||
my $val = join( " ", @val );
|
my $val = join( " ", @val );
|
||||||
my $wordlenght = length($val);
|
my $wordlenght = length($val);
|
||||||
|
|
||||||
return HOMBOT_SelectSetCmd( $hash, $cmd, @val ) if( lc $cmd eq 'statusrequest' );
|
return HOMBOT_SelectSetCmd( $hash, $cmd, @val ) if( lc $cmd eq 'statusrequest' );
|
||||||
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 "set command only works if state not equal initialized, please wait for next interval run" if( ReadingsVal( $hash->{NAME}, "state", 0 ) eq "initialized");
|
||||||
return "to many character for Nickname" if(( $wordlenght < 2 || $wordlenght > 16 ) && lc $cmd eq 'nickname' );
|
return "to many character for Nickname" if(( $wordlenght < 2 || $wordlenght > 16 ) && lc $cmd eq 'nickname' );
|
||||||
|
|
||||||
return HOMBOT_SelectSetCmd( $hash, $cmd, @val ) if( ( ( @val ) && lc $cmd eq 'statusrequest' || lc $cmd eq 'cleanstart'|| lc $cmd eq 'homing' || lc $cmd eq 'pause' ) );
|
return HOMBOT_SelectSetCmd( $hash, $cmd, @val ) if( ( ( @val ) || lc $cmd eq 'cleanstart'|| lc $cmd eq 'homing' || lc $cmd eq 'pause' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Unknown argument $cmd, bearword as argument or wrong parameter(s), choose one of $list";
|
return "Unknown argument $cmd, bearword as argument or wrong parameter(s), choose one of $list";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub HOMBOT_SelectSetCmd($$@) {
|
sub HOMBOT_SelectSetCmd($$@) {
|
||||||
@ -583,74 +600,74 @@ sub HOMBOT_SelectSetCmd($$@) {
|
|||||||
|
|
||||||
if( lc $cmd eq 'cleanstart' ) {
|
if( lc $cmd eq 'cleanstart' ) {
|
||||||
|
|
||||||
my $url = "http://" . $host . ":" . $port . "/json.cgi?%7b%22COMMAND%22:%22CLEAN_START%22%7d";
|
my $url = "http://" . $host . ":" . $port . "/json.cgi?%7b%22COMMAND%22:%22CLEAN_START%22%7d";
|
||||||
|
|
||||||
Log3 $name, 4, "HOMBOT ($name) - Homebot start cleaning";
|
Log3 $name, 4, "HOMBOT ($name) - Homebot start cleaning";
|
||||||
|
|
||||||
return HOMBOT_HTTP_POST( $hash,$url );
|
return HOMBOT_HTTP_POST( $hash,$url );
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif( lc $cmd eq 'homing' ) {
|
elsif( lc $cmd eq 'homing' ) {
|
||||||
|
|
||||||
my $url = "http://" . $host . ":" . $port . "/json.cgi?%7b%22COMMAND%22:%22HOMING%22%7d";
|
my $url = "http://" . $host . ":" . $port . "/json.cgi?%7b%22COMMAND%22:%22HOMING%22%7d";
|
||||||
|
|
||||||
Log3 $name, 4, "HOMBOT ($name) - Homebot come home";
|
Log3 $name, 4, "HOMBOT ($name) - Homebot come home";
|
||||||
|
|
||||||
return HOMBOT_HTTP_POST( $hash,$url );
|
return HOMBOT_HTTP_POST( $hash,$url );
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif( lc $cmd eq 'pause' ) {
|
elsif( lc $cmd eq 'pause' ) {
|
||||||
|
|
||||||
my $url = "http://" . $host . ":" . $port . "/json.cgi?%7b%22COMMAND%22:%22PAUSE%22%7d";
|
my $url = "http://" . $host . ":" . $port . "/json.cgi?%7b%22COMMAND%22:%22PAUSE%22%7d";
|
||||||
|
|
||||||
Log3 $name, 4, "HOMBOT ($name) - Homebot paused";
|
Log3 $name, 4, "HOMBOT ($name) - Homebot paused";
|
||||||
|
|
||||||
return HOMBOT_HTTP_POST( $hash,$url );
|
return HOMBOT_HTTP_POST( $hash,$url );
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif( lc $cmd eq 'cleanmode' ) {
|
elsif( lc $cmd eq 'cleanmode' ) {
|
||||||
my $mode = join( " ", @data );
|
my $mode = join( " ", @data );
|
||||||
|
|
||||||
my $url = "http://" . $host . ":" . $port . "/json.cgi?%7b%22COMMAND%22:%7b%22CLEAN_MODE%22:%22CLEAN_".$mode."%22%7d%7d";
|
my $url = "http://" . $host . ":" . $port . "/json.cgi?%7b%22COMMAND%22:%7b%22CLEAN_MODE%22:%22CLEAN_".$mode."%22%7d%7d";
|
||||||
|
|
||||||
Log3 $name, 4, "HOMBOT ($name) - set Cleanmode to $mode";
|
Log3 $name, 4, "HOMBOT ($name) - set Cleanmode to $mode";
|
||||||
|
|
||||||
return HOMBOT_HTTP_POST( $hash,$url );
|
return HOMBOT_HTTP_POST( $hash,$url );
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif( lc $cmd eq 'statusrequest' ) {
|
elsif( lc $cmd eq 'statusrequest' ) {
|
||||||
HOMBOT_Get_stateRequestLocal( $hash );
|
HOMBOT_Get_stateRequestLocal( $hash );
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif( lc $cmd eq 'repeat' ) {
|
elsif( lc $cmd eq 'repeat' ) {
|
||||||
my $repeat = join( " ", @data );
|
my $repeat = join( " ", @data );
|
||||||
|
|
||||||
my $url = "http://" . $host . ":" . $port . "/json.cgi?%7b%22COMMAND%22:%7b%22REPEAT%22:%22".$repeat."%22%7d%7d";
|
my $url = "http://" . $host . ":" . $port . "/json.cgi?%7b%22COMMAND%22:%7b%22REPEAT%22:%22".$repeat."%22%7d%7d";
|
||||||
|
|
||||||
Log3 $name, 4, "HOMBOT ($name) - set Repeat to $repeat";
|
Log3 $name, 4, "HOMBOT ($name) - set Repeat to $repeat";
|
||||||
|
|
||||||
return HOMBOT_HTTP_POST( $hash,$url );
|
return HOMBOT_HTTP_POST( $hash,$url );
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif( lc $cmd eq 'turbo' ) {
|
elsif( lc $cmd eq 'turbo' ) {
|
||||||
my $turbo = join( " ", @data );
|
my $turbo = join( " ", @data );
|
||||||
|
|
||||||
my $url = "http://" . $host . ":" . $port . "/json.cgi?%7b%22COMMAND%22:%7b%22TURBO%22:%22".$turbo."%22%7d%7d";
|
my $url = "http://" . $host . ":" . $port . "/json.cgi?%7b%22COMMAND%22:%7b%22TURBO%22:%22".$turbo."%22%7d%7d";
|
||||||
|
|
||||||
Log3 $name, 4, "HOMBOT ($name) - set Turbo to $turbo";
|
Log3 $name, 4, "HOMBOT ($name) - set Turbo to $turbo";
|
||||||
|
|
||||||
return HOMBOT_HTTP_POST( $hash,$url );
|
return HOMBOT_HTTP_POST( $hash,$url );
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif( lc $cmd eq 'nickname' ) {
|
elsif( lc $cmd eq 'nickname' ) {
|
||||||
my $nick = join( " ", @data );
|
my $nick = join( " ", @data );
|
||||||
|
|
||||||
my $url = "http://" . $host . ":" . $port . "/json.cgi?%7b%22NICKNAME%22:%7b%22SET%22:%22".$nick."%22%7d%7d";
|
my $url = "http://" . $host . ":" . $port . "/json.cgi?%7b%22NICKNAME%22:%7b%22SET%22:%22".$nick."%22%7d%7d";
|
||||||
|
|
||||||
Log3 $name, 4, "HOMBOT ($name) - set Nickname to $nick";
|
Log3 $name, 4, "HOMBOT ($name) - set Nickname to $nick";
|
||||||
|
|
||||||
return HOMBOT_HTTP_POST( $hash,$url );
|
return HOMBOT_HTTP_POST( $hash,$url );
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif( lc $cmd eq 'schedule' ) {
|
elsif( lc $cmd eq 'schedule' ) {
|
||||||
@ -670,11 +687,11 @@ sub HOMBOT_SelectSetCmd($$@) {
|
|||||||
#my $su = $data[6];
|
#my $su = $data[6];
|
||||||
$data[6] =~ s/So/SUNDAY/g;
|
$data[6] =~ s/So/SUNDAY/g;
|
||||||
|
|
||||||
my $url = "http://" . $host . ":" . $port . "/sites/schedule.html?".$data[0]."&".$data[1]."&".$data[2]."&".$data[3]."&".$data[4]."&".$data[5]."&".$data[6]."&SEND=Save";
|
my $url = "http://" . $host . ":" . $port . "/sites/schedule.html?".$data[0]."&".$data[1]."&".$data[2]."&".$data[3]."&".$data[4]."&".$data[5]."&".$data[6]."&SEND=Save";
|
||||||
|
|
||||||
Log3 $name, 4, "HOMBOT ($name) - set schedule to $data[0],$data[1],$data[2],$data[3],$data[4],$data[5],$data[6]";
|
Log3 $name, 4, "HOMBOT ($name) - set schedule to $data[0],$data[1],$data[2],$data[3],$data[4],$data[5],$data[6]";
|
||||||
|
|
||||||
return HOMBOT_HTTP_POST( $hash,$url );
|
return HOMBOT_HTTP_POST( $hash,$url );
|
||||||
}
|
}
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
@ -690,15 +707,15 @@ sub HOMBOT_HTTP_POST($$) {
|
|||||||
readingsSingleUpdate( $hash, "state", "Send HTTP POST", 1 );
|
readingsSingleUpdate( $hash, "state", "Send HTTP POST", 1 );
|
||||||
|
|
||||||
HttpUtils_NonblockingGet(
|
HttpUtils_NonblockingGet(
|
||||||
{
|
{
|
||||||
url => $url,
|
url => $url,
|
||||||
timeout => 10,
|
timeout => 10,
|
||||||
hash => $hash,
|
hash => $hash,
|
||||||
method => "GET",
|
method => "GET",
|
||||||
doTrigger => 1,
|
doTrigger => 1,
|
||||||
callback => \&HOMBOT_HTTP_POSTerrorHandling,
|
callback => \&HOMBOT_HTTP_POSTerrorHandling,
|
||||||
}
|
});
|
||||||
);
|
|
||||||
Log3 $name, 4, "HOMBOT ($name) - Send HTTP POST with URL $url";
|
Log3 $name, 4, "HOMBOT ($name) - Send HTTP POST with URL $url";
|
||||||
|
|
||||||
readingsSingleUpdate( $hash, "state", $state, 1 );
|
readingsSingleUpdate( $hash, "state", $state, 1 );
|
||||||
@ -716,10 +733,10 @@ sub HOMBOT_HTTP_POSTerrorHandling($$$) {
|
|||||||
### Begin Error Handling
|
### Begin Error Handling
|
||||||
if( $hash->{helper}{setErrorCounter} > 1 ) {
|
if( $hash->{helper}{setErrorCounter} > 1 ) {
|
||||||
|
|
||||||
readingsSingleUpdate( $hash, "lastSetCommandState", "statusRequest_error", 1 );
|
readingsSingleUpdate( $hash, "lastSetCommandState", "statusRequest_error", 1 );
|
||||||
|
|
||||||
|
|
||||||
if( $hash->{helper}{setErrorCounter} > 1 && ReadingsVal( $name, "luigiHttpSrvState", "not running" ) eq "running" ) {
|
if( $hash->{helper}{setErrorCounter} > 1 && ReadingsVal( $name, "luigiHttpSrvState", "not running" ) eq "running" ) {
|
||||||
|
|
||||||
Log3 $name, 3, "HOMBOT ($name) - Connecting Problem, will check Luigi HTTP Server" unless(exists($hash->{helper}{RUNNING_PID}));
|
Log3 $name, 3, "HOMBOT ($name) - Connecting Problem, will check Luigi HTTP Server" unless(exists($hash->{helper}{RUNNING_PID}));
|
||||||
|
|
||||||
@ -728,41 +745,42 @@ sub HOMBOT_HTTP_POSTerrorHandling($$$) {
|
|||||||
|
|
||||||
readingsBeginUpdate( $hash );
|
readingsBeginUpdate( $hash );
|
||||||
|
|
||||||
if( $hash->{helper}{requestErrorCounter} > 6 && $hash->{helper}{setErrorCounter} > 2 && ReadingsVal( $name, "luigiHttpSrvState", "running" ) eq "running" ) {
|
if( $hash->{helper}{requestErrorCounter} > 6 && $hash->{helper}{setErrorCounter} > 2 && ReadingsVal( $name, "luigiHttpSrvState", "running" ) eq "running" ) {
|
||||||
readingsBulkUpdate($hash, "lastSetCommandError", "unknown error, please contact the developer" );
|
readingsBulkUpdate($hash, "lastSetCommandError", "unknown error, please contact the developer" );
|
||||||
|
|
||||||
Log3 $name, 4, "HOMBOT ($name) - UNKNOWN ERROR, PLEASE CONTACT THE DEVELOPER, DEVICE DISABLED";
|
Log3 $name, 4, "HOMBOT ($name) - UNKNOWN ERROR, PLEASE CONTACT THE DEVELOPER, DEVICE DISABLED";
|
||||||
|
|
||||||
$attr{$name}{disable} = 1;
|
$attr{$name}{disable} = 1;
|
||||||
readingsBulkUpdate( $hash, "state", "Unknown Error" );
|
readingsBulkUpdate( $hash, "state", "Unknown Error" );
|
||||||
$hash->{helper}{requestErrorCounter} = 0;
|
$hash->{helper}{requestErrorCounter} = 0;
|
||||||
$hash->{helper}{setErrorCounter} = 0;
|
$hash->{helper}{setErrorCounter} = 0;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif( $hash->{helper}{setErrorCounter} > 3 && ReadingsVal( $name, "luigiHttpSrvState", "running" ) eq "not running" ){
|
elsif( $hash->{helper}{setErrorCounter} > 3 && ReadingsVal( $name, "luigiHttpSrvState", "running" ) eq "not running" ){
|
||||||
readingsBulkUpdate( $hash, "lastSetCommandError", "HTTP Server at Homebot offline" );
|
readingsBulkUpdate( $hash, "lastSetCommandError", "HTTP Server at Homebot offline" );
|
||||||
readingsBulkUpdate ( $hash, "hombotState", "OFFLINE");
|
readingsBulkUpdate ( $hash, "hombotState", "OFFLINE");
|
||||||
|
|
||||||
Log3 $name, 4, "HOMBOT ($name) - Please check HTTP Server at Homebot";
|
Log3 $name, 4, "HOMBOT ($name) - Please check HTTP Server at Homebot";
|
||||||
|
|
||||||
$hash->{helper}{requestErrorCounter} = 0;
|
$hash->{helper}{requestErrorCounter} = 0;
|
||||||
$hash->{helper}{setErrorCounter} = 0;
|
$hash->{helper}{setErrorCounter} = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif( $hash->{helper}{setErrorCounter} > 3 && ReadingsVal( $name, "luigiHttpSrvState", "running" ) eq "running" ) {
|
elsif( $hash->{helper}{setErrorCounter} > 3 && ReadingsVal( $name, "luigiHttpSrvState", "running" ) eq "running" ) {
|
||||||
readingsBulkUpdate( $hash, "lastSetCommandError", "to many errors, check your network or device configuration" );
|
readingsBulkUpdate( $hash, "lastSetCommandError", "to many errors, check your network or device configuration" );
|
||||||
|
|
||||||
Log3 $name, 4, "HOMBOT ($name) - To many Errors please check your Network or Device Configuration";
|
Log3 $name, 4, "HOMBOT ($name) - To many Errors please check your Network or Device Configuration";
|
||||||
|
|
||||||
readingsBulkUpdate( $hash, "state", "To many Errors" );
|
readingsBulkUpdate( $hash, "state", "To many Errors" );
|
||||||
readingsBulkUpdate ( $hash, "hombotState", "OFFLINE");
|
readingsBulkUpdate ( $hash, "hombotState", "OFFLINE");
|
||||||
|
|
||||||
$hash->{helper}{setErrorCounter} = 0;
|
$hash->{helper}{setErrorCounter} = 0;
|
||||||
$hash->{helper}{requestErrorCounter} = 0;
|
$hash->{helper}{requestErrorCounter} = 0;
|
||||||
}
|
}
|
||||||
readingsEndUpdate( $hash, 1 );
|
|
||||||
|
readingsEndUpdate( $hash, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( defined( $err ) && $err ne "" ) {
|
if( defined( $err ) && $err ne "" ) {
|
||||||
@ -782,35 +800,35 @@ sub HOMBOT_HTTP_POSTerrorHandling($$$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( $data eq "" and exists( $param->{code} ) && $param->{code} ne 200 ) {
|
if( $data eq "" and exists( $param->{code} ) && $param->{code} ne 200 ) {
|
||||||
readingsBeginUpdate( $hash );
|
readingsBeginUpdate( $hash );
|
||||||
readingsBulkUpdate( $hash, "state", $param->{code} ) if( ReadingsVal( $hash, "state", 0 ) ne "initialized" );
|
readingsBulkUpdate( $hash, "state", $param->{code} ) if( ReadingsVal( $hash, "state", 0 ) ne "initialized" );
|
||||||
|
|
||||||
$hash->{helper}{setErrorCounter} = ( $hash->{helper}{setErrorCounter} + 1 );
|
$hash->{helper}{setErrorCounter} = ( $hash->{helper}{setErrorCounter} + 1 );
|
||||||
|
|
||||||
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 );
|
||||||
|
|
||||||
Log3 $name, 5, "HOMBOT ($name) - HOMBOT_HTTP_POST: received http code ".$param->{code};
|
Log3 $name, 5, "HOMBOT ($name) - HOMBOT_HTTP_POST: received http code ".$param->{code};
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ( $data =~ /Error/i ) and exists( $param->{code} ) ) {
|
if( ( $data =~ /Error/i ) and exists( $param->{code} ) ) {
|
||||||
readingsBeginUpdate( $hash );
|
readingsBeginUpdate( $hash );
|
||||||
readingsBulkUpdate( $hash, "state", $param->{code} ) if( ReadingsVal( $name, "state", 0 ) ne "initialized" );
|
readingsBulkUpdate( $hash, "state", $param->{code} ) if( ReadingsVal( $name, "state", 0 ) ne "initialized" );
|
||||||
|
|
||||||
$hash->{helper}{setErrorCounter} = ( $hash->{helper}{setErrorCounter} + 1 );
|
$hash->{helper}{setErrorCounter} = ( $hash->{helper}{setErrorCounter} + 1 );
|
||||||
|
|
||||||
readingsBulkUpdate( $hash, "lastSetCommandState", "cmd_error" );
|
readingsBulkUpdate( $hash, "lastSetCommandState", "cmd_error" );
|
||||||
|
|
||||||
if( $param->{code} eq 404 ) {
|
if( $param->{code} eq 404 ) {
|
||||||
readingsBulkUpdate( $hash, "lastSetCommandError", "HTTP Server at Homebot is offline!" );
|
readingsBulkUpdate( $hash, "lastSetCommandError", "HTTP Server at Homebot is offline!" );
|
||||||
} else {
|
} else {
|
||||||
readingsBulkUpdate( $hash, "lastSetCommandError", "http error ".$param->{code} );
|
readingsBulkUpdate( $hash, "lastSetCommandError", "http error ".$param->{code} );
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
### End Error Handling
|
### End Error Handling
|
||||||
@ -832,19 +850,20 @@ sub HOMBOT_Check_Bot_Alive($) {
|
|||||||
my $hash = $defs{$name};
|
my $hash = $defs{$name};
|
||||||
my $host = $hash->{HOST};
|
my $host = $hash->{HOST};
|
||||||
my $sshalive;
|
my $sshalive;
|
||||||
|
my $sshpass = $hash->{helper}{sshpass};
|
||||||
|
|
||||||
Log3 $name, 3, "HOMBOT ($name) - Start SSH Connection for check Hombot alive";
|
Log3 $name, 3, "HOMBOT ($name) - Start SSH Connection for check Hombot alive";
|
||||||
|
|
||||||
|
|
||||||
$sshalive = qx(/usr/bin/sshpass -p 'most9981' /usr/bin/ssh root\@$host 'uname' );
|
$sshalive = qx($sshpass -p 'most9981' /usr/bin/ssh root\@$host 'uname' );
|
||||||
|
|
||||||
if( $sshalive ) {
|
if( $sshalive ) {
|
||||||
|
|
||||||
my $lgSrvPID = ((split (/\s+/,qx(/usr/bin/sshpass -p 'most9981' /usr/bin/ssh root\@$host 'ps | grep -v grep | grep /usr/bin/lg.srv' )))[1]);
|
my $lgSrvPID = ((split (/\s+/,qx($sshpass -p 'most9981' /usr/bin/ssh root\@$host 'ps | grep -v grep | grep /usr/bin/lg.srv' )))[1]);
|
||||||
|
|
||||||
if( not defined( $lgSrvPID ) ) {
|
if( not defined( $lgSrvPID ) ) {
|
||||||
|
|
||||||
qx(/usr/bin/sshpass -p 'most9981' /usr/bin/ssh root\@$host '/usr/bin/lg.srv &' );
|
qx($sshpass -p 'most9981' /usr/bin/ssh root\@$host '/usr/bin/lg.srv &' );
|
||||||
|
|
||||||
return "$name|$callingtype|restarted";
|
return "$name|$callingtype|restarted";
|
||||||
|
|
||||||
@ -906,7 +925,7 @@ sub HOMBOT_Evaluation_Bot_Alive($) {
|
|||||||
|
|
||||||
readingsBulkUpdate( $hash, "luigiHttpSrvState", "running");
|
readingsBulkUpdate( $hash, "luigiHttpSrvState", "running");
|
||||||
readingsBulkUpdate ( $hash, "hombotState", "OFFLINE");
|
readingsBulkUpdate ( $hash, "hombotState", "OFFLINE");
|
||||||
readingsBulkUpdate ( $hash, "state", "Homebot offline");
|
readingsBulkUpdate ( $hash, "state", "Homebot offline");
|
||||||
|
|
||||||
Log3 $name, 3, "HOMBOT ($name) - Hombot is not online";
|
Log3 $name, 3, "HOMBOT ($name) - Hombot is not online";
|
||||||
}
|
}
|
||||||
@ -941,7 +960,7 @@ sub HOMBOT_Evaluation_Bot_Alive($) {
|
|||||||
|
|
||||||
readingsBulkUpdate( $hash, "luigiHttpSrvState", "running");
|
readingsBulkUpdate( $hash, "luigiHttpSrvState", "running");
|
||||||
readingsBulkUpdate ( $hash, "hombotState", "OFFLINE");
|
readingsBulkUpdate ( $hash, "hombotState", "OFFLINE");
|
||||||
readingsBulkUpdate ( $hash, "state", "Homebot offline");
|
readingsBulkUpdate ( $hash, "state", "Homebot offline");
|
||||||
|
|
||||||
Log3 $name, 3, "HOMBOT ($name) - Hombot is not online";
|
Log3 $name, 3, "HOMBOT ($name) - Hombot is not online";
|
||||||
}
|
}
|
||||||
@ -959,6 +978,16 @@ sub HOMBOT_Aborted_Bot_Alive($) {
|
|||||||
Log3 $name, 3, "HOMBOT ($name) - The BlockingCall Process terminated unexpectedly. Timedout";
|
Log3 $name, 3, "HOMBOT ($name) - The BlockingCall Process terminated unexpectedly. Timedout";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub HOMBOT_DetailFn() { # Patch von Andre (justme1968)
|
||||||
|
|
||||||
|
my ($FW_wname, $d, $room, $pageHash) = @_; # pageHash is set for summaryFn.
|
||||||
|
my $hash = $defs{$d};
|
||||||
|
|
||||||
|
return if( !defined( $hash->{HOST} ) );
|
||||||
|
|
||||||
|
return "<b><u><a href=\"http://$hash->{HOST}:6260\" target=\"_blank\">Control Center</a></u></b><br>"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -968,6 +997,8 @@ sub HOMBOT_Aborted_Bot_Alive($) {
|
|||||||
|
|
||||||
|
|
||||||
=pod
|
=pod
|
||||||
|
=item summary connection to LG Homebot robotic vacuum cleaner
|
||||||
|
=item summary_DE Anbindung LG Homebot Staubsaugerroboter
|
||||||
=begin html
|
=begin html
|
||||||
|
|
||||||
<a name="HOMBOT"></a>
|
<a name="HOMBOT"></a>
|
||||||
@ -1056,21 +1087,23 @@ sub HOMBOT_Aborted_Bot_Alive($) {
|
|||||||
<ul>
|
<ul>
|
||||||
<u><b>HOMBOT - LG Homebot Staubsaugerroboter</b></u>
|
<u><b>HOMBOT - LG Homebot Staubsaugerroboter</b></u>
|
||||||
<br>
|
<br>
|
||||||
Dieses Modul gibt Euch die Möglichkeit Euren Hombot nach erfolgreichen Hack in FHEM ein zu binden.
|
Dieses Modul gibt Euch die Möglichkeit Euren Hombot nach erfolgreichen Hack in FHEM ein zu binden.
|
||||||
Voraussetzung ist das Ihr den Hombot Hack gemacht und einen WLAN Stick eingebaut habt. Als Schnittstelle zwischen FHEM und Bot wird der Luigi HTTP Server verwendet. Was genau könnt Ihr nun mit dem Modul machen:
|
Voraussetzung ist das Ihr den Hombot Hack gemacht und einen WLAN Stick eingebaut habt. Als Schnittstelle zwischen FHEM und Bot wird der Luigi HTTP Server verwendet. Was genau könnt Ihr nun mit dem Modul machen:
|
||||||
<ul>
|
<ul>
|
||||||
<li>Readings über den Status des Hombots werden angelegt</li>
|
<li>Readings über den Status des Hombots werden angelegt</li>
|
||||||
<li>Auswahl des Reinigungsmodus ist möglich</li>
|
<li>Auswahl des Reinigungsmodus ist möglich</li>
|
||||||
<li>Starten der Reinigung</li>
|
<li>Starten der Reinigung</li>
|
||||||
<li>Beenden der Reinigung</li>
|
<li>Beenden der Reinigung</li>
|
||||||
<li>zurück zur Homebase schicken</li>
|
<li>zurück zur Homebase schicken</li>
|
||||||
<li>Namen vergeben</li>
|
<li>Namen vergeben</li>
|
||||||
<li>Wochenprogramm einstellen</li>
|
<li>Wochenprogramm einstellen</li>
|
||||||
<li>Repeat und Turbo aktivieren</li>
|
<li>Repeat und Turbo aktivieren</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
Das Device für den Hombot legt Ihr wie folgt in FHEM an.
|
!!! Voraussetzungen schaffen !!!
|
||||||
|
<br>Ihr benötigt zum verwenden des Modules die Programme ssh und sshpass. Desweiteren muß im Homeverzeichnis des fhem Users das Verzeichniss .ssh existieren und darin die Datei known_hosts. Diese sollte eine Passphrass des Bots beinhalten. Am besten Ihr macht als normaler User eine ssh Session zum Bot und kopiert danach die known_hosts Eures normalen Users in das .ssh Verzeichnis des fhem Users. Rechte anpassen nicht vergessen.
|
||||||
|
<br>
|
||||||
|
Das Device für den Hombot legt Ihr wie folgt in FHEM an.
|
||||||
<br><br>
|
<br><br>
|
||||||
<a name="HOMBOTdefine"></a>
|
<a name="HOMBOTdefine"></a>
|
||||||
<b>Define</b>
|
<b>Define</b>
|
||||||
@ -1092,10 +1125,10 @@ sub HOMBOT_Aborted_Bot_Alive($) {
|
|||||||
<a name="HOMBOTreadings"></a>
|
<a name="HOMBOTreadings"></a>
|
||||||
<b>Readings</b>
|
<b>Readings</b>
|
||||||
<ul>
|
<ul>
|
||||||
<li>at_* - Reading für das Wochenprogramm. Startzeit für den jeweiligen Tag</li>
|
<li>at_* - Reading für das Wochenprogramm. Startzeit für den jeweiligen Tag</li>
|
||||||
<li>batteryPercent - Status der Batterie in %</li>
|
<li>batteryPercent - Status der Batterie in %</li>
|
||||||
<li>cleanMode - aktuell eingestellter Reinigungsmodus</li>
|
<li>cleanMode - aktuell eingestellter Reinigungsmodus</li>
|
||||||
<li>cpu_* - Informationen über die Prozessorauslastung</li>
|
<li>cpu_* - Informationen über die Prozessorauslastung</li>
|
||||||
<li>currentBumping - Anzahl der Zusammenstöße mit Hindernissen</li>
|
<li>currentBumping - Anzahl der Zusammenstöße mit Hindernissen</li>
|
||||||
<li>firmware - aktuell installierte Firmwareversion</li>
|
<li>firmware - aktuell installierte Firmwareversion</li>
|
||||||
<li>hombotState - Status des Hombots</li>
|
<li>hombotState - Status des Hombots</li>
|
||||||
@ -1119,7 +1152,7 @@ sub HOMBOT_Aborted_Bot_Alive($) {
|
|||||||
<li>cleanStart - Reinigung starten</li>
|
<li>cleanStart - Reinigung starten</li>
|
||||||
<li>homing - Beendet die Reinigung und lässt die Bot zurück zur Bases kommen</li>
|
<li>homing - Beendet die Reinigung und lässt die Bot zurück zur Bases kommen</li>
|
||||||
<li>nickname - setzt des Bot-Namens. Wird im Reading erst nach einem neustart des Luigiservers oder des Bots sichtbar</li>
|
<li>nickname - setzt des Bot-Namens. Wird im Reading erst nach einem neustart des Luigiservers oder des Bots sichtbar</li>
|
||||||
<li>pause - lässt den Reinigungsproßess pausieren</li>
|
<li>pause - lässt den Reinigungsproßess pausieren</li>
|
||||||
<li>repeat - Reinigung wiederholen? (true/false)</li>
|
<li>repeat - Reinigung wiederholen? (true/false)</li>
|
||||||
<li>schedule - setzen des Wochenprogrammes Bsp. set Roberta schedule Mo=13:30 Di= Mi=14:00,ZZ Do=15:20 Fr= Sa=11:20 So= Man kann also auch den Modus mitgeben!</li>
|
<li>schedule - setzen des Wochenprogrammes Bsp. set Roberta schedule Mo=13:30 Di= Mi=14:00,ZZ Do=15:20 Fr= Sa=11:20 So= Man kann also auch den Modus mitgeben!</li>
|
||||||
<li>statusRequest - Fordert einen neuen Statusreport beim Device an</li>
|
<li>statusRequest - Fordert einen neuen Statusreport beim Device an</li>
|
||||||
|
Reference in New Issue
Block a user