mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-21 07:56:03 +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.
|
||||
# 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;
|
||||
now, also several different Twilight devices are possible
|
||||
- feature: 72_XiaomiDevice: New fan types 1C / P9
|
||||
|
@ -35,7 +35,7 @@ use GPUtils qw(:all);
|
||||
|
||||
use Time::HiRes qw(gettimeofday);
|
||||
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 Encode qw(encode_utf8);
|
||||
use MIME::Base64;
|
||||
@ -620,7 +620,7 @@ sub Set {
|
||||
|
||||
# preferences
|
||||
elsif ( grep { $a[1] =~ /$_/x } @preferences ) {
|
||||
my $item = $1;
|
||||
my $item = $a[1];
|
||||
my %params;
|
||||
|
||||
Log3( $name, 4, "BOTVAC set $name $arg" );
|
||||
@ -783,7 +783,7 @@ sub SendCommand {
|
||||
else {
|
||||
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) );
|
||||
LogSuccessors( $hash, @successor );
|
||||
|
||||
@ -1858,14 +1858,8 @@ sub CheckRegistration {
|
||||
my @nextCmd = ( $service, $cmd, $option );
|
||||
unshift( @successor, [ $service, $cmd, $option ] );
|
||||
|
||||
my @succ_item;
|
||||
my $msg = " 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 );
|
||||
Log3( $name, 4, "BOTVAC $name: register account" );
|
||||
LogSuccessors( $hash, @successor );
|
||||
|
||||
SendCommand( $hash, "sessions", undef, undef, @successor )
|
||||
if ( ReadingsVal( $name, ".accessToken", "" ) eq "" );
|
||||
@ -2138,7 +2132,9 @@ sub LogSuccessors {
|
||||
for ( my $i = 0 ; $i < @successor ; $i++ ) {
|
||||
@succ_item = @{ $successor[$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 );
|
||||
|
||||
|
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