mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
74_HOMBOT: add commandref summary, code design
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@16458 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
e1e87bda9d
commit
d5a8933177
1
CHANGED
1
CHANGED
@ -1,5 +1,6 @@
|
|||||||
# 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.
|
||||||
|
- added: 74_HOMBOT: add commandref summary, code design
|
||||||
- change: 73_GardenaSmartBridge: change logging output for username and
|
- change: 73_GardenaSmartBridge: change logging output for username and
|
||||||
password
|
password
|
||||||
- feature: 93_DbRep: 7.14.6, attr expimpfile can use some kinds of wildcards
|
- feature: 93_DbRep: 7.14.6, attr expimpfile can use some kinds of wildcards
|
||||||
|
@ -157,6 +157,7 @@ sub EQ3BT_Initialize($) {
|
|||||||
$hash->{SetFn} = 'EQ3BT_Set';
|
$hash->{SetFn} = 'EQ3BT_Set';
|
||||||
$hash->{AttrFn} = 'EQ3BT_Attribute';
|
$hash->{AttrFn} = 'EQ3BT_Attribute';
|
||||||
$hash->{AttrList} = 'sshHost maxRetries timeout '.
|
$hash->{AttrList} = 'sshHost maxRetries timeout '.
|
||||||
|
'blockingCallLoglevel:2,3,4,5 '.
|
||||||
$readingFnAttributes;
|
$readingFnAttributes;
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
@ -172,6 +173,7 @@ sub EQ3BT_Define($$) {
|
|||||||
|
|
||||||
$hash->{STATE} = "initialized";
|
$hash->{STATE} = "initialized";
|
||||||
$hash->{VERSION} = "2.0.4";
|
$hash->{VERSION} = "2.0.4";
|
||||||
|
$hash->{loglevel} = 4;
|
||||||
Log3 $hash, 3, "EQ3BT: EQ-3 Bluetooth Thermostat ".$hash->{VERSION};
|
Log3 $hash, 3, "EQ3BT: EQ-3 Bluetooth Thermostat ".$hash->{VERSION};
|
||||||
|
|
||||||
if (int(@a) > 4) {
|
if (int(@a) > 4) {
|
||||||
@ -236,12 +238,21 @@ sub EQ3BT_pairDevice {
|
|||||||
|
|
||||||
sub EQ3BT_Attribute($$$$) {
|
sub EQ3BT_Attribute($$$$) {
|
||||||
my ($mode, $devName, $attrName, $attrValue) = @_;
|
my ($mode, $devName, $attrName, $attrValue) = @_;
|
||||||
|
my $hash = $defs{$devName};
|
||||||
|
|
||||||
if($mode eq "set") {
|
if($mode eq "set") {
|
||||||
|
if( $attrName eq "blockingCallLoglevel" ) {
|
||||||
|
$hash->{loglevel} = $attrValue;
|
||||||
|
Log3 $devName, 3, "EQ3BT ($devName) - set blockingCallLoglevel to $attrValue";
|
||||||
|
}
|
||||||
|
|
||||||
} elsif($mode eq "del") {
|
} elsif($mode eq "del") {
|
||||||
|
if( $attrName eq "blockingCallLoglevel" ) {
|
||||||
|
$hash->{loglevel} = 4;
|
||||||
|
Log3 $devName, 3, "EQ3BT ($devName) - set blockingCallLoglevel to default";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -381,7 +392,7 @@ sub EQ3BT_setDesiredTemperature($$) {
|
|||||||
|
|
||||||
my $eq3Temp = sprintf("%02X", $desiredTemp * 2);
|
my $eq3Temp = sprintf("%02X", $desiredTemp * 2);
|
||||||
|
|
||||||
$hash->{helper}{RUNNING_PID} = BlockingCall("EQ3BT_execGatttool", $name."|".$hash->{MAC}."|setDesiredTemperature|0x0411|41".$eq3Temp, "EQ3BT_processGatttoolResult", 60, "EQ3BT_killGatttool", $hash);
|
$hash->{helper}{RUNNING_PID} = BlockingCall("EQ3BT_execGatttool", $name."|".$hash->{MAC}."|setDesiredTemperature|0x0411|41".$eq3Temp, "EQ3BT_processGatttoolResult", 90, "EQ3BT_killGatttool", $hash);
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,7 +416,7 @@ sub EQ3BT_setBoost {
|
|||||||
my $data = "01";
|
my $data = "01";
|
||||||
$data = "00" if($onoff eq "off");
|
$data = "00" if($onoff eq "off");
|
||||||
|
|
||||||
$hash->{helper}{RUNNING_PID} = BlockingCall("EQ3BT_execGatttool", $name."|".$hash->{MAC}."|setBoost|0x0411|45".$data, "EQ3BT_processGatttoolResult", 60, "EQ3BT_killGatttool", $hash);
|
$hash->{helper}{RUNNING_PID} = BlockingCall("EQ3BT_execGatttool", $name."|".$hash->{MAC}."|setBoost|0x0411|45".$data, "EQ3BT_processGatttoolResult", 90, "EQ3BT_killGatttool", $hash);
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,7 +440,7 @@ sub EQ3BT_setMode {
|
|||||||
my $data = "40";
|
my $data = "40";
|
||||||
$data = "00" if($mode eq "automatic");
|
$data = "00" if($mode eq "automatic");
|
||||||
|
|
||||||
$hash->{helper}{RUNNING_PID} = BlockingCall("EQ3BT_execGatttool", $name."|".$hash->{MAC}."|setMode|0x0411|40".$data."|listen", "EQ3BT_processGatttoolResult", 60, "EQ3BT_killGatttool", $hash);
|
$hash->{helper}{RUNNING_PID} = BlockingCall("EQ3BT_execGatttool", $name."|".$hash->{MAC}."|setMode|0x0411|40".$data."|listen", "EQ3BT_processGatttoolResult", 90, "EQ3BT_killGatttool", $hash);
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,7 +461,7 @@ sub EQ3BT_setEco {
|
|||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
$hash->{helper}{RUNNING_PID} = BlockingCall("EQ3BT_execGatttool", $name."|".$hash->{MAC}."|setEco|0x0411|44|listen", "EQ3BT_processGatttoolResult", 60, "EQ3BT_killGatttool", $hash);
|
$hash->{helper}{RUNNING_PID} = BlockingCall("EQ3BT_execGatttool", $name."|".$hash->{MAC}."|setEco|0x0411|44|listen", "EQ3BT_processGatttoolResult", 90, "EQ3BT_killGatttool", $hash);
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,7 +482,7 @@ sub EQ3BT_setComfort {
|
|||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
$hash->{helper}{RUNNING_PID} = BlockingCall("EQ3BT_execGatttool", $name."|".$hash->{MAC}."|setComfort|0x0411|43|listen", "EQ3BT_processGatttoolResult", 60, "EQ3BT_killGatttool", $hash);
|
$hash->{helper}{RUNNING_PID} = BlockingCall("EQ3BT_execGatttool", $name."|".$hash->{MAC}."|setComfort|0x0411|43|listen", "EQ3BT_processGatttoolResult", 90, "EQ3BT_killGatttool", $hash);
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,14 +501,14 @@ sub EQ3BT_setComfortRetry {
|
|||||||
### Gatttool functions ###
|
### Gatttool functions ###
|
||||||
sub EQ3BT_retryGatttool {
|
sub EQ3BT_retryGatttool {
|
||||||
my ($hash, $workType) = @_;
|
my ($hash, $workType) = @_;
|
||||||
$hash->{helper}{RUNNING_PID} = BlockingCall("EQ3BT_execGatttool", $hash->{NAME}."|".$hash->{MAC}."|$workType|".$hash->{helper}{"handle$workType"}."|".$hash->{helper}{"value$workType"}."|".$hash->{helper}{"listen$workType"}, "EQ3BT_processGatttoolResult", 60, "EQ3BT_killGatttool", $hash);
|
$hash->{helper}{RUNNING_PID} = BlockingCall("EQ3BT_execGatttool", $hash->{NAME}."|".$hash->{MAC}."|$workType|".$hash->{helper}{"handle$workType"}."|".$hash->{helper}{"value$workType"}."|listen", "EQ3BT_processGatttoolResult", 90, "EQ3BT_killGatttool", $hash);
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub EQ3BT_execGatttool($) {
|
sub EQ3BT_execGatttool($) {
|
||||||
my ($string) = @_;
|
my ($string) = @_;
|
||||||
my ($name, $mac, $workType, $handle, $value, $listen) = split("\\|", $string);
|
my ($name, $mac, $workType, $handle, $value, $listen) = split("\\|", $string);
|
||||||
my $wait = 1;
|
|
||||||
my $hash = $main::defs{$name};
|
my $hash = $main::defs{$name};
|
||||||
|
|
||||||
my $gatttool = qx(which gatttool);
|
my $gatttool = qx(which gatttool);
|
||||||
@ -506,13 +517,19 @@ sub EQ3BT_execGatttool($) {
|
|||||||
if(-x $gatttool) {
|
if(-x $gatttool) {
|
||||||
my $gtResult;
|
my $gtResult;
|
||||||
my $cmd;
|
my $cmd;
|
||||||
|
my $wait = 1;
|
||||||
my $sshHost = AttrVal($name,"sshHost","none");
|
my $sshHost = AttrVal($name,"sshHost","none");
|
||||||
|
my $hciDevice = "hci".$hash->{helper}{hcidevices}[$hash->{helper}{currenthcidevice}];
|
||||||
|
|
||||||
|
|
||||||
while($wait) {
|
while($wait) {
|
||||||
my $grepGatttool = qx(ps ax| grep -E \'gatttool -b $mac\' | grep -v grep);
|
|
||||||
|
my $grepGatttool;
|
||||||
|
$grepGatttool = qx(ps ax| grep -E \'gatttool -i $hciDevice -b $mac\' | grep -v grep) if($sshHost eq 'none');
|
||||||
|
$grepGatttool = qx(ssh $sshHost 'ps ax| grep -E "gatttool -i $hciDevice -b $mac" | grep -v grep') if($sshHost ne 'none');
|
||||||
|
|
||||||
if(not $grepGatttool =~ /^\s*$/) {
|
if(not $grepGatttool =~ /^\s*$/) {
|
||||||
#another gattool is running
|
Log3 $name, 4, "EQ3BT ($name) - ExecGatttool_Run: another gatttool process is running. waiting...";
|
||||||
Log3 $name, 5, "EQ3BT ($name): another gatttool process is running. waiting...";
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
} else {
|
} else {
|
||||||
$wait = 0;
|
$wait = 0;
|
||||||
@ -525,26 +542,16 @@ sub EQ3BT_execGatttool($) {
|
|||||||
$value .= $currentDate;
|
$value .= $currentDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $hciDevice = "hci".$hash->{helper}{hcidevices}[$hash->{helper}{currenthcidevice}];
|
|
||||||
#my $cmd = "gatttool -b $mac -i $hciDevice --char-write-req --handle=$handle --value=$value";
|
|
||||||
if( $sshHost ne 'none' ) {
|
|
||||||
$cmd = "ssh $sshHost 'gatttool -b $mac -i $hciDevice --char-write-req --handle=$handle --value=$value";
|
|
||||||
} else {
|
|
||||||
$cmd = "gatttool -b $mac -i $hciDevice --char-write-req --handle=$handle --value=$value";
|
|
||||||
}
|
|
||||||
|
|
||||||
if(defined($listen) && $listen eq "listen") {
|
$cmd = "ssh $sshHost '" if($sshHost ne 'none');
|
||||||
$cmd = "timeout ".AttrVal($name, "timeout", 15)." ".$cmd." --listen";
|
$cmd .= "timeout 10 " if(defined($listen) and $listen eq "listen");
|
||||||
}
|
$cmd .= "gatttool -i $hciDevice -b $mac ";
|
||||||
|
$cmd .= "--char-write-req -a $handle -n $value";
|
||||||
|
$cmd .= " --listen" if(defined($listen) and $listen eq "listen");
|
||||||
|
$cmd .= " 2>&1 /dev/null";
|
||||||
|
$cmd .= "'" if($sshHost ne 'none');
|
||||||
|
|
||||||
#redirect stderr to stdout
|
Log3 $name, 4, "EQ3BT ($name): $cmd";
|
||||||
if( $sshHost ne 'none' ) {
|
|
||||||
$cmd .= " 2>&1'";
|
|
||||||
} else {
|
|
||||||
$cmd .= " 2>&1";
|
|
||||||
}
|
|
||||||
|
|
||||||
Log3 $name, 5, "EQ3BT ($name): $cmd";
|
|
||||||
$gtResult = qx($cmd);
|
$gtResult = qx($cmd);
|
||||||
chomp $gtResult;
|
chomp $gtResult;
|
||||||
my @gtResultArr = split("\n", $gtResult);
|
my @gtResultArr = split("\n", $gtResult);
|
||||||
@ -554,7 +561,7 @@ sub EQ3BT_execGatttool($) {
|
|||||||
if(defined($gtResultArr[1]) && $gtResultArr[1] =~ /Notification handle = 0x0421 value: (.*)/) {
|
if(defined($gtResultArr[1]) && $gtResultArr[1] =~ /Notification handle = 0x0421 value: (.*)/) {
|
||||||
return "$name|$mac|ok|$workType|$handle|$value|$1";
|
return "$name|$mac|ok|$workType|$handle|$value|$1";
|
||||||
} else {
|
} else {
|
||||||
if(defined($listen) && $listen eq "listen") {
|
if(defined($listen) and $listen eq "listen") {
|
||||||
return "$name|$mac|error|$workType|$handle|$value|notification missing";
|
return "$name|$mac|error|$workType|$handle|$value|notification missing";
|
||||||
} else {
|
} else {
|
||||||
return "$name|$mac|ok|$workType|$handle|$value";
|
return "$name|$mac|ok|$workType|$handle|$value";
|
||||||
@ -751,7 +758,7 @@ sub EQ3BT_setChildlock($$) {
|
|||||||
my $data = "01";
|
my $data = "01";
|
||||||
$data = "00" if($onoff eq "off");
|
$data = "00" if($onoff eq "off");
|
||||||
|
|
||||||
$hash->{helper}{RUNNING_PID} = BlockingCall("EQ3BT_execGatttool", $name."|".$hash->{MAC}."|setChildlock|0x0411|80".$data, "EQ3BT_processGatttoolResult", 60, "EQ3BT_killGatttool", $hash);
|
$hash->{helper}{RUNNING_PID} = BlockingCall("EQ3BT_execGatttool", $name."|".$hash->{MAC}."|setChildlock|0x0411|80".$data, "EQ3BT_processGatttoolResult", 90, "EQ3BT_killGatttool", $hash);
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ use Time::HiRes qw(gettimeofday);
|
|||||||
use HttpUtils;
|
use HttpUtils;
|
||||||
use Blocking;
|
use Blocking;
|
||||||
|
|
||||||
my $version = "0.2.4";
|
my $version = "0.2.5";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -237,8 +237,8 @@ sub HOMBOT_getStatusTXT($) {
|
|||||||
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";
|
||||||
}
|
}
|
||||||
@ -263,8 +263,8 @@ sub HOMBOT_getStatisticHTML($) {
|
|||||||
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";
|
||||||
}
|
}
|
||||||
@ -289,8 +289,8 @@ sub HOMBOT_getSchedule($) {
|
|||||||
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";
|
||||||
}
|
}
|
||||||
@ -313,7 +313,6 @@ sub HOMBOT_RetrieveHomebotInfoFinished($$$) {
|
|||||||
|
|
||||||
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}));
|
||||||
@ -361,7 +360,9 @@ sub HOMBOT_RetrieveHomebotInfoFinished($$$) {
|
|||||||
readingsBulkUpdate ( $hash, "state", "To many Errors");
|
readingsBulkUpdate ( $hash, "state", "To many Errors");
|
||||||
$hash->{helper}{requestErrorCounter} = 0;
|
$hash->{helper}{requestErrorCounter} = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
readingsEndUpdate( $hash, 1 );
|
readingsEndUpdate( $hash, 1 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( defined( $err ) && $err ne "" ) {
|
if( defined( $err ) && $err ne "" ) {
|
||||||
@ -713,8 +714,8 @@ sub HOMBOT_HTTP_POST($$) {
|
|||||||
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 );
|
||||||
@ -778,6 +779,7 @@ sub HOMBOT_HTTP_POSTerrorHandling($$$) {
|
|||||||
$hash->{helper}{setErrorCounter} = 0;
|
$hash->{helper}{setErrorCounter} = 0;
|
||||||
$hash->{helper}{requestErrorCounter} = 0;
|
$hash->{helper}{requestErrorCounter} = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
readingsEndUpdate( $hash, 1 );
|
readingsEndUpdate( $hash, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -995,6 +997,8 @@ sub HOMBOT_DetailFn() { # Patch von Andre (justme1968)
|
|||||||
|
|
||||||
|
|
||||||
=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>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user