70_BOTVAC.pm: added state "Password missing", added check for robots in account

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@20276 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
vuffiraa 2019-09-29 16:07:12 +00:00
parent 2d45574098
commit a67f3a04d7
2 changed files with 19 additions and 7 deletions

View File

@ -1,5 +1,7 @@
# 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: 70_BOTVAC: new state "Password missing",
added check for robots in account
- bugfix: 95_Dashboard: fix warnings - bugfix: 95_Dashboard: fix warnings
- change: 88_Timer: spelling mistake - change: 88_Timer: spelling mistake
- bufix: 93_DbRep: fix readingRename without leading device Forum: #104024, - bufix: 93_DbRep: fix readingRename without leading device Forum: #104024,

View File

@ -32,6 +32,7 @@ use warnings;
sub BOTVAC_Initialize($) { sub BOTVAC_Initialize($) {
my ($hash) = @_; my ($hash) = @_;
our $readingFnAttributes;
$hash->{DefFn} = "BOTVAC::Define"; $hash->{DefFn} = "BOTVAC::Define";
$hash->{GetFn} = "BOTVAC::Get"; $hash->{GetFn} = "BOTVAC::Get";
@ -44,7 +45,7 @@ sub BOTVAC_Initialize($) {
$hash->{AttrList} = "disable:0,1 " . $hash->{AttrList} = "disable:0,1 " .
"actionInterval " . "actionInterval " .
"boundaries:textField-long " . "boundaries:textField-long " .
$::readingFnAttributes; $readingFnAttributes;
} }
package BOTVAC; package BOTVAC;
@ -147,6 +148,7 @@ sub Define($$) {
$hash->{INTERVAL} = $interval; $hash->{INTERVAL} = $interval;
unless ( defined( AttrVal( $name, "webCmd", undef ) ) ) { unless ( defined( AttrVal( $name, "webCmd", undef ) ) ) {
no warnings "once";
$::attr{$name}{webCmd} = 'startCleaning:stop:sendToBase'; $::attr{$name}{webCmd} = 'startCleaning:stop:sendToBase';
} }
@ -692,7 +694,10 @@ sub SendCommand($$;$$@) {
$header .= "\r\nContent-Type: application/json"; $header .= "\r\nContent-Type: application/json";
if ($service eq "sessions") { if ($service eq "sessions") {
return if (!defined($password)); if (!defined($password)) {
readingsSingleUpdate($hash, "state", "Password missing (see instructions)",1);
return;
}
my $token = createUniqueId() . createUniqueId(); my $token = createUniqueId() . createUniqueId();
$URL .= GetBeehiveHost($hash->{VENDOR}); $URL .= GetBeehiveHost($hash->{VENDOR});
$URL .= "/sessions"; $URL .= "/sessions";
@ -1186,10 +1191,15 @@ sub ReceiveCommand($$$) {
push(@robotList, $r); push(@robotList, $r);
} }
$hash->{helper}{ROBOTS} = \@robotList; $hash->{helper}{ROBOTS} = \@robotList;
if (@robotList) {
SetRobot($hash, ReadingsNum($name, "robot", 0)); SetRobot($hash, ReadingsNum($name, "robot", 0));
push(@successor , ["robots", "maps"]); push(@successor , ["robots", "maps"]);
} else {
Log3($name, 3, "BOTVAC $name: no robots found");
Log3($name, 4, "BOTVAC $name: drop successors");
LogSuccessors($hash, @successor);
@successor = ();
}
} }
} }
} }