mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-22 02:10:32 +00:00
70_BOTVAC.pm: fix processing of set for preferences
git-svn-id: https://svn.fhem.de/fhem/trunk@22802 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
698a78461b
commit
f2cb4803b0
@ -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.
|
||||||
|
- bugfix: 70_BOTVAC: fix processing of set for preferences
|
||||||
- feature: 59_Twilight: remove dependencies to global lon/lat settings;
|
- feature: 59_Twilight: remove dependencies to global lon/lat settings;
|
||||||
now, also several different Twilight devices are possible
|
now, also several different Twilight devices are possible
|
||||||
- feature: 72_XiaomiDevice: New fan types 1C / P9
|
- feature: 72_XiaomiDevice: New fan types 1C / P9
|
||||||
|
@ -35,7 +35,7 @@ use GPUtils qw(:all);
|
|||||||
|
|
||||||
use Time::HiRes qw(gettimeofday);
|
use Time::HiRes qw(gettimeofday);
|
||||||
use Time::Local qw(timelocal);
|
use Time::Local qw(timelocal);
|
||||||
use JSON qw(decode_json encode_json);
|
use JSON qw(decode_json encode_json to_json);
|
||||||
use Digest::SHA qw(hmac_sha256_hex sha1_hex);
|
use Digest::SHA qw(hmac_sha256_hex sha1_hex);
|
||||||
use Encode qw(encode_utf8);
|
use Encode qw(encode_utf8);
|
||||||
use MIME::Base64;
|
use MIME::Base64;
|
||||||
@ -620,7 +620,7 @@ sub Set {
|
|||||||
|
|
||||||
# preferences
|
# preferences
|
||||||
elsif ( grep { $a[1] =~ /$_/x } @preferences ) {
|
elsif ( grep { $a[1] =~ /$_/x } @preferences ) {
|
||||||
my $item = $1;
|
my $item = $a[1];
|
||||||
my %params;
|
my %params;
|
||||||
|
|
||||||
Log3( $name, 4, "BOTVAC set $name $arg" );
|
Log3( $name, 4, "BOTVAC set $name $arg" );
|
||||||
@ -783,7 +783,7 @@ sub SendCommand {
|
|||||||
else {
|
else {
|
||||||
Log3( $name, 4, "BOTVAC $name: REQ $service/$cmd" );
|
Log3( $name, 4, "BOTVAC $name: REQ $service/$cmd" );
|
||||||
}
|
}
|
||||||
Log3( $name, 4, "BOTVAC $name: REQ option $option" )
|
Log3( $name, 4, "BOTVAC $name: REQ option " . (ref($option) eq 'HASH' ? to_json($option) : $option) )
|
||||||
if ( defined($option) );
|
if ( defined($option) );
|
||||||
LogSuccessors( $hash, @successor );
|
LogSuccessors( $hash, @successor );
|
||||||
|
|
||||||
@ -1858,14 +1858,8 @@ sub CheckRegistration {
|
|||||||
my @nextCmd = ( $service, $cmd, $option );
|
my @nextCmd = ( $service, $cmd, $option );
|
||||||
unshift( @successor, [ $service, $cmd, $option ] );
|
unshift( @successor, [ $service, $cmd, $option ] );
|
||||||
|
|
||||||
my @succ_item;
|
Log3( $name, 4, "BOTVAC $name: register account" );
|
||||||
my $msg = " successor:";
|
LogSuccessors( $hash, @successor );
|
||||||
for ( my $i = 0 ; $i < @successor ; $i++ ) {
|
|
||||||
@succ_item = @{ $successor[$i] };
|
|
||||||
$msg .= " $i: ";
|
|
||||||
$msg .= join( ",", map { defined($_) ? $_ : '' } @succ_item );
|
|
||||||
}
|
|
||||||
Log3( $name, 4, "BOTVAC created" . $msg );
|
|
||||||
|
|
||||||
SendCommand( $hash, "sessions", undef, undef, @successor )
|
SendCommand( $hash, "sessions", undef, undef, @successor )
|
||||||
if ( ReadingsVal( $name, ".accessToken", "" ) eq "" );
|
if ( ReadingsVal( $name, ".accessToken", "" ) eq "" );
|
||||||
@ -2138,7 +2132,9 @@ sub LogSuccessors {
|
|||||||
for ( my $i = 0 ; $i < @successor ; $i++ ) {
|
for ( my $i = 0 ; $i < @successor ; $i++ ) {
|
||||||
@succ_item = @{ $successor[$i] };
|
@succ_item = @{ $successor[$i] };
|
||||||
$msg .= " $i: ";
|
$msg .= " $i: ";
|
||||||
$msg .= join( ",", map { defined($_) ? $_ : '' } @succ_item );
|
$msg .= join( ",",
|
||||||
|
map { defined($_) ? ( ref($_) eq 'HASH' ? to_json($_) : $_ ) : '' }
|
||||||
|
@succ_item );
|
||||||
}
|
}
|
||||||
Log3( $name, 4, $msg ) if ( @successor > 0 );
|
Log3( $name, 4, $msg ) if ( @successor > 0 );
|
||||||
|
|
||||||
|
42
fhem/t/FHEM/70_BOTVAC/CommandSet.t
Normal file
42
fhem/t/FHEM/70_BOTVAC/CommandSet.t
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
################################################
|
||||||
|
# test Set
|
||||||
|
################################################
|
||||||
|
package FHEM::BOTVAC;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
# used to import of FHEM functions from fhem.pl
|
||||||
|
use GPUtils qw(:all);
|
||||||
|
BEGIN {
|
||||||
|
GP_Import(
|
||||||
|
qw(
|
||||||
|
fhem
|
||||||
|
FhemTestUtils_gotLog
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
# trigger without argument
|
||||||
|
fhem('set botvac');
|
||||||
|
is(FhemTestUtils_gotLog('set botvac : No Argument given'), 1, 'Match: No Argument given');
|
||||||
|
|
||||||
|
# trigger with unknown argument
|
||||||
|
fhem('set botvac missing');
|
||||||
|
is( FhemTestUtils_gotLog('set botvac missing : Unknown argument missing, choose one of password statusRequest:noArg schedule:on,off syncRobots:noArg pollingMode:on,off'),
|
||||||
|
1, 'Match: Unknown argument missing' );
|
||||||
|
|
||||||
|
# trigger preferences
|
||||||
|
fhem('setreading botvac pref_filterChangeReminderInterval 3');
|
||||||
|
fhem('setreading botvac .secretKey testing');
|
||||||
|
fhem('set botvac filterChangeReminderInterval 1');
|
||||||
|
is( FhemTestUtils_gotLog('REQ messages/setPreferences'),
|
||||||
|
1, 'Match: REQ messages/setPreferences' );
|
||||||
|
is( FhemTestUtils_gotLog('REQ option {"filterChangeReminderInterval":43200}'),
|
||||||
|
1, 'Match: REQ option {"filterChangeReminderInterval":43200}' );
|
||||||
|
|
||||||
|
done_testing;
|
||||||
|
exit(0);
|
||||||
|
|
||||||
|
1;
|
Loading…
x
Reference in New Issue
Block a user