merge from master

This commit is contained in:
Marko Oldenburg 2020-02-27 13:59:50 +01:00
commit 2bfdbd9c05

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 ($hash) = @_; my ( $new, $old ) = @_;
my $name = $hash->{NAME}; my $hash = $defs{$new};
my $index = $hash->{TYPE}."_".$hash->{NAME}."_passwd";
StorePassword( $hash, $new, ReadPassword($hash,$old) );
setKeyValue( $hash->{TYPE} . "_" . $old . "_passwd", undef );
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);