2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

21_HEOSMaster: fix rename passwordstore bug

git-svn-id: https://svn.fhem.de/fhem/trunk@21293 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
LeonGaultier 2020-02-27 13:05:56 +00:00
parent bdc73be463
commit c67aebc933
2 changed files with 26 additions and 13 deletions

View File

@ -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: 21_HEOSMaster: fix rename passwordstore bug
- bugfix: 73_GardenaSmartBridge: fix rename passwordstore bug - bugfix: 73_GardenaSmartBridge: fix rename passwordstore bug
- feature: 73_WaterCalculator: New Attribute DecimalPlace - feature: 73_WaterCalculator: New Attribute DecimalPlace
- feature: 73_GasCalculator: New Attribute DecimalPlace - feature: 73_GasCalculator: New Attribute DecimalPlace

View File

@ -67,6 +67,7 @@ eval "use Encode;1" or $missingModul .= "Encode ";
my $version = "1.0.3"; my $version = "1.0.3";
my %heosCmds = ( my %heosCmds = (
'enableChangeEvents' => 'system/register_for_change_events?enable=', 'enableChangeEvents' => 'system/register_for_change_events?enable=',
'checkAccount' => 'system/check_account', 'checkAccount' => 'system/check_account',
@ -132,8 +133,9 @@ sub HEOSMaster_GetPlayers($);
sub HEOSMaster_EnableChangeEvents($); sub HEOSMaster_EnableChangeEvents($);
sub HEOSMaster_PreProcessingReadings($$); sub HEOSMaster_PreProcessingReadings($$);
sub HEOSMaster_ReOpen($); sub HEOSMaster_ReOpen($);
sub HEOSMaster_ReadPassword($); sub HEOSMaster_ReadPassword($$);
sub HEOSMaster_StorePassword($$); sub HEOSMaster_StorePassword($@);
sub HEOSMaster_Rename(@);
sub HEOSMaster_GetGroups($); sub HEOSMaster_GetGroups($);
sub HEOSMaster_ProcessRead($$); sub HEOSMaster_ProcessRead($$);
sub HEOSMaster_ParseMsg($$); sub HEOSMaster_ParseMsg($$);
@ -278,7 +280,7 @@ sub HEOSMaster_Get($$@) {
if( $cmd eq 'showAccount' ) { if( $cmd eq 'showAccount' ) {
return "usage: $cmd" if( @args != 0 ); return "usage: $cmd" if( @args != 0 );
return AttrVal($name,'heosUsername',0) . ":" .HEOSMaster_ReadPassword($hash); return AttrVal($name,'heosUsername',0) . ":" .HEOSMaster_ReadPassword($hash,$name);
} }
my $list = 'showAccount:noArg'; my $list = 'showAccount:noArg';
@ -330,12 +332,12 @@ sub HEOSMaster_Set($@) {
return "please set account informattion first" if(AttrVal($name,'heosUsername','none') eq 'none'); return "please set account informattion first" if(AttrVal($name,'heosUsername','none') eq 'none');
$heosCmd = $cmd . $args[0]; $heosCmd = $cmd . $args[0];
$action = 'un='. AttrVal($name,'heosUsername','none') . '&pw=' . HEOSMaster_ReadPassword($hash) if($args[0] eq 'In'); $action = 'un='. AttrVal($name,'heosUsername','none') . '&pw=' . HEOSMaster_ReadPassword($hash,$name) if($args[0] eq 'In');
} elsif($cmd eq 'password') { } elsif($cmd eq 'password') {
return "usage: $cmd" if( @args != 1 ); return "usage: $cmd" if( @args != 1 );
return HEOSMaster_StorePassword( $hash, $args[0] ); return HEOSMaster_StorePassword( $hash, $name, $args[0] );
} elsif($cmd eq 'reboot') { } elsif($cmd eq 'reboot') {
return "usage: $cmd" if( @args != 0 ); return "usage: $cmd" if( @args != 0 );
@ -361,7 +363,7 @@ sub HEOSMaster_Open($) {
my $port = 1255; my $port = 1255;
my $timeout = 0.1; my $timeout = 0.1;
my $user = AttrVal($name,'heosUsername',undef); my $user = AttrVal($name,'heosUsername',undef);
my $password = HEOSMaster_ReadPassword($hash); my $password = HEOSMaster_ReadPassword($hash,$name);
Log3 $name, 4, "HEOSMaster ($name) - Build socket connection"; Log3 $name, 4, "HEOSMaster ($name) - Build socket connection";
@ -1257,10 +1259,10 @@ sub HEOSMaster_CheckAccount($) {
Log3 $name, 4, "HEOSMaster ($name) - checkAccount"; Log3 $name, 4, "HEOSMaster ($name) - checkAccount";
} }
sub HEOSMaster_StorePassword($$) { sub HEOSMaster_StorePassword($@) {
my ($hash, $password) = @_; my ($hash, $name, $password) = @_;
my $index = $hash->{TYPE}."_".$hash->{NAME}."_passwd"; my $index = $hash->{TYPE}."_".$name."_passwd";
my $key = getUniqueId().$index; my $key = getUniqueId().$index;
my $enc_pwd = ""; my $enc_pwd = "";
@ -1284,11 +1286,21 @@ sub HEOSMaster_StorePassword($$) {
return "password successfully saved"; return "password successfully saved";
} }
sub HEOSMaster_ReadPassword($) { sub HEOSMaster_Rename(@) {
my ( $new, $old ) = @_;
my $hash = $defs{$new};
my ($hash) = @_; StorePassword( $hash, $new, ReadPassword($hash,$old) );
my $name = $hash->{NAME}; setKeyValue( $hash->{TYPE} . "_" . $old . "_passwd", undef );
my $index = $hash->{TYPE}."_".$hash->{NAME}."_passwd";
return undef;
}
sub HEOSMaster_ReadPassword($$) {
my ($hash, $name) = @_;
my $index = $hash->{TYPE}."_".$name."_passwd";
my $key = getUniqueId().$index; my $key = getUniqueId().$index;
my ($password, $err); my ($password, $err);