Anpassungen nach merge von Cooltux

This commit is contained in:
Manfred 2022-11-23 21:57:49 +01:00
parent 23d037f2a5
commit 77a6212498
2 changed files with 27 additions and 17 deletions

View File

@ -33,8 +33,8 @@ use FHEM::Meta;
use GPUtils qw(GP_Export GP_Import); use GPUtils qw(GP_Export GP_Import);
use JSON; use JSON;
use vars qw(%data); #(CoolTux) sollte auch nicht nötig sein da Du es in dem Package nichts verwendest #use vars qw(%data);
# use FHEM::Core::Authentication::Passwords qw(:ALL); #(CoolTux) Kann raus da Du es ja hier nicht verwendest #use FHEM::Core::Authentication::Passwords qw(:ALL);
require FHEM::Devices::Matrix::Matrix; require FHEM::Devices::Matrix::Matrix;
#-- Run before package compilation #-- Run before package compilation
@ -52,14 +52,14 @@ BEGIN {
sub Initialize { sub Initialize {
my ($hash) = @_; my ($hash) = @_;
$hash->{DefFn} = \&FHEM::Devices::Matrix::Define; $hash->{DefFn} = \&FHEM::Matrix::Define;
$hash->{UndefFn} = \&FHEM::Devices::Matrix::Undef; $hash->{UndefFn} = \&FHEM::Matrix::Undef;
$hash->{SetFn} = \&FHEM::Devices::Matrix::Set; $hash->{SetFn} = \&FHEM::Matrix::Set;
$hash->{GetFn} = \&FHEM::Devices::Matrix::Get; $hash->{GetFn} = \&FHEM::Matrix::Get;
$hash->{AttrFn} = \&FHEM::Devices::Matrix::Attr; $hash->{AttrFn} = \&FHEM::Matrix::Attr;
$hash->{ReadFn} = \&FHEM::Devices::Matrix::Read; $hash->{ReadFn} = \&FHEM::Matrix::Read;
$hash->{RenameFn} = \&FHEM::Devices::Matrix::Rename; $hash->{RenameFn} = \&FHEM::Matrix::Rename;
$hash->{NotifyFn} = \&FHEM::Devices::Matrix::Notify; $hash->{NotifyFn} = \&FHEM::Matrix::Notify;
#$hash->{AttrList} = $FHEM::Devices::Matrix::attr_list; #$hash->{AttrList} = $FHEM::Devices::Matrix::attr_list;
$hash->{AttrList} = Attr_List(); $hash->{AttrList} = Attr_List();

View File

@ -9,7 +9,11 @@
# b) die Bezeichnungen der Readings, # b) die Bezeichnungen der Readings,
# c) die Bezeichnungen der Attribute. # c) die Bezeichnungen der Attribute.
package FHEM::Devices::Matrix; #package FHEM::Devices::Matrix;
#(Man-Fred) geh ich Recht in der Annahme, dass hier das gleiche package hin gehört
# wie im Modul 98_Matrix?
package FHEM::Matrix;
use strict; use strict;
use warnings; use warnings;
use HttpUtils; use HttpUtils;
@ -157,6 +161,8 @@ sub Notify
#(CoolTux) bin mir nicht sicher wieso die Schleife. Nötig ist sie aber egal wofür gedacht nicht. #(CoolTux) bin mir nicht sicher wieso die Schleife. Nötig ist sie aber egal wofür gedacht nicht.
#(Man-Fred) die Schleife ist vom Debugging, ich wollte wissen was im Notify ankommt.
# kann raus in einer späteren Version
foreach my $event (@{$events}) { foreach my $event (@{$events}) {
$event = "" if(!defined($event)); $event = "" if(!defined($event));
### Writing log entry ### Writing log entry
@ -181,13 +187,18 @@ sub Rename {
my $new = shift; my $new = shift;
my $old = shift; my $old = shift;
my $hash = $defs{$new}; my $hash = $defs{$new};
my $name = $hash->{NAME};
$data{MATRIX}{"$new"} = $data{MATRIX}{"$old"};
#$data{MATRIX}{"$old"} = undef; (CoolTux) Wenn ein Hash nicht mehr benötigt wird dann delete
delete $data{MATRIX}{"$old"}
my ($passResp,$passErr); my ($passResp,$passErr);
$data{MATRIX}{"$new"} = $data{MATRIX}{"$old"};
$data{MATRIX}{"$old"} = undef; #(CoolTux) Wenn ein Hash nicht mehr benötigt wird dann delete
# Fehler in der nächsten Zeile:
# delete argument is not a HASH or ARRAY element or slice at lib/FHEM/Devices/Matrix/Matrix.pm line 197.
# delete $data{MATRIX}{"$old"}
($passResp,$passErr) = $hash->{helper}->{passwdobj}->setRename($new,$old); #(CoolTux) Es empfiehlt sich ab zu fragen ob der Wechsel geklappt hat ($passResp,$passErr) = $hash->{helper}->{passwdobj}->setRename($new,$old); #(CoolTux) Es empfiehlt sich ab zu fragen ob der Wechsel geklappt hat
Log3($name, 1, "$name : Matrix::Rename - error while change the password hash after rename - $passErr") Log3($name, 1, "$name : Matrix::Rename - error while change the password hash after rename - $passErr")
@ -341,7 +352,6 @@ sub Attr {
if($cmd eq "set") { if($cmd eq "set") {
if ($attr_name eq "matrixQuestion_") { if ($attr_name eq "matrixQuestion_") {
my @erg = split(/ /, $attr_value, 2); my @erg = split(/ /, $attr_value, 2);
$_[2] = "matrixQuestion_n";
return qq("attr $name $attr_name" ).I18N('require2') if (!$erg[1] || $erg[0] !~ /[0-9]/); return qq("attr $name $attr_name" ).I18N('require2') if (!$erg[1] || $erg[0] !~ /[0-9]/);
$_[2] = "matrixQuestion_$erg[0]"; $_[2] = "matrixQuestion_$erg[0]";
$_[3] = $erg[1]; $_[3] = $erg[1];