mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
RESIDENTStk wakeuptimer: ignore non-existing wakeupDevice references and correct attribute *_wakeupDevice in ROOMMATE, GUEST or RESIDENTS device
git-svn-id: https://svn.fhem.de/fhem/trunk@8424 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
8343a68d79
commit
83b53d4671
@ -1199,23 +1199,16 @@ sub RESIDENTStk_AttrFnDummy(@) {
|
|||||||
|
|
||||||
sub RESIDENTStk_wakeupGetNext($) {
|
sub RESIDENTStk_wakeupGetNext($) {
|
||||||
my ($name) = @_;
|
my ($name) = @_;
|
||||||
|
my $wakeupDeviceAttrName = "";
|
||||||
|
|
||||||
my $wakeupDeviceList = (
|
$wakeupDeviceAttrName = "rgr_wakeupDevice"
|
||||||
AttrVal( $name, "rgr_wakeupDevice", 0 )
|
if ( defined( $attr{$name}{"rgr_wakeupDevice"} ) );
|
||||||
? AttrVal( $name, "rgr_wakeupDevice", 0 )
|
$wakeupDeviceAttrName = "rr_wakeupDevice"
|
||||||
: (
|
if ( defined( $attr{$name}{"rr_wakeupDevice"} ) );
|
||||||
AttrVal( $name, "rr_wakeupDevice", 0 )
|
$wakeupDeviceAttrName = "rg_wakeupDevice"
|
||||||
? AttrVal( $name, "rr_wakeupDevice", 0 )
|
if ( defined( $attr{$name}{"rg_wakeupDevice"} ) );
|
||||||
: (
|
|
||||||
AttrVal( $name, "rg_wakeupDevice", 0 )
|
|
||||||
? AttrVal( $name, "rg_wakeupDevice", 0 )
|
|
||||||
: 0
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return "Device $name does not seem to have any wakeup devices registered."
|
my $wakeupDeviceList = AttrVal( $name, $wakeupDeviceAttrName, 0 );
|
||||||
if ( !$wakeupDeviceList );
|
|
||||||
|
|
||||||
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) =
|
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) =
|
||||||
localtime(time);
|
localtime(time);
|
||||||
@ -1237,6 +1230,26 @@ sub RESIDENTStk_wakeupGetNext($) {
|
|||||||
|
|
||||||
# check for each registered wake-up device
|
# check for each registered wake-up device
|
||||||
for my $wakeupDevice ( split /,/, $wakeupDeviceList ) {
|
for my $wakeupDevice ( split /,/, $wakeupDeviceList ) {
|
||||||
|
next if !$wakeupDevice;
|
||||||
|
|
||||||
|
if ( !defined( $defs{$wakeupDevice} ) ) {
|
||||||
|
Log3 $name, 4,
|
||||||
|
"RESIDENTStk $name: 00 - ignoring reference to non-existing wakeupDevice $wakeupDevice";
|
||||||
|
|
||||||
|
my $wakeupDeviceListNew = $wakeupDeviceList;
|
||||||
|
$wakeupDeviceListNew =~ s/,$wakeupDevice,/,/g;
|
||||||
|
$wakeupDeviceListNew =~ s/$wakeupDevice,//g;
|
||||||
|
$wakeupDeviceListNew =~ s/,$wakeupDevice//g;
|
||||||
|
|
||||||
|
if ( $wakeupDeviceListNew ne $wakeupDeviceList ) {
|
||||||
|
Log3 $name, 3,
|
||||||
|
"RESIDENTStk $name: reference to non-existing wakeupDevice '$wakeupDevice' was removed";
|
||||||
|
fhem "attr $name $wakeupDeviceAttrName $wakeupDeviceListNew";
|
||||||
|
}
|
||||||
|
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
Log3 $name, 4,
|
Log3 $name, 4,
|
||||||
"RESIDENTStk $name: 00 - checking for next wake-up candidate $wakeupDevice";
|
"RESIDENTStk $name: 00 - checking for next wake-up candidate $wakeupDevice";
|
||||||
|
|
||||||
@ -1244,7 +1257,8 @@ sub RESIDENTStk_wakeupGetNext($) {
|
|||||||
my $wakeupAtdevice = AttrVal( $wakeupDevice, "wakeupAtdevice", 0 );
|
my $wakeupAtdevice = AttrVal( $wakeupDevice, "wakeupAtdevice", 0 );
|
||||||
my $wakeupOffset = AttrVal( $wakeupDevice, "wakeupOffset", 0 );
|
my $wakeupOffset = AttrVal( $wakeupDevice, "wakeupOffset", 0 );
|
||||||
my $wakeupAtNTM = (
|
my $wakeupAtNTM = (
|
||||||
defined( $defs{$wakeupAtdevice}{NTM} )
|
defined( $defs{$wakeupAtdevice} )
|
||||||
|
&& defined( $defs{$wakeupAtdevice}{NTM} )
|
||||||
? substr( $defs{$wakeupAtdevice}{NTM}, 0, -3 )
|
? substr( $defs{$wakeupAtdevice}{NTM}, 0, -3 )
|
||||||
: 0
|
: 0
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user