2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-16 04:36:02 +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:
jpawlowski 2015-04-12 13:19:08 +00:00
parent 8343a68d79
commit 83b53d4671

View File

@ -1199,23 +1199,16 @@ sub RESIDENTStk_AttrFnDummy(@) {
sub RESIDENTStk_wakeupGetNext($) {
my ($name) = @_;
my $wakeupDeviceAttrName = "";
my $wakeupDeviceList = (
AttrVal( $name, "rgr_wakeupDevice", 0 )
? AttrVal( $name, "rgr_wakeupDevice", 0 )
: (
AttrVal( $name, "rr_wakeupDevice", 0 )
? AttrVal( $name, "rr_wakeupDevice", 0 )
: (
AttrVal( $name, "rg_wakeupDevice", 0 )
? AttrVal( $name, "rg_wakeupDevice", 0 )
: 0
)
)
);
$wakeupDeviceAttrName = "rgr_wakeupDevice"
if ( defined( $attr{$name}{"rgr_wakeupDevice"} ) );
$wakeupDeviceAttrName = "rr_wakeupDevice"
if ( defined( $attr{$name}{"rr_wakeupDevice"} ) );
$wakeupDeviceAttrName = "rg_wakeupDevice"
if ( defined( $attr{$name}{"rg_wakeupDevice"} ) );
return "Device $name does not seem to have any wakeup devices registered."
if ( !$wakeupDeviceList );
my $wakeupDeviceList = AttrVal( $name, $wakeupDeviceAttrName, 0 );
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) =
localtime(time);
@ -1237,6 +1230,26 @@ sub RESIDENTStk_wakeupGetNext($) {
# check for each registered wake-up device
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,
"RESIDENTStk $name: 00 - checking for next wake-up candidate $wakeupDevice";
@ -1244,7 +1257,8 @@ sub RESIDENTStk_wakeupGetNext($) {
my $wakeupAtdevice = AttrVal( $wakeupDevice, "wakeupAtdevice", 0 );
my $wakeupOffset = AttrVal( $wakeupDevice, "wakeupOffset", 0 );
my $wakeupAtNTM = (
defined( $defs{$wakeupAtdevice}{NTM} )
defined( $defs{$wakeupAtdevice} )
&& defined( $defs{$wakeupAtdevice}{NTM} )
? substr( $defs{$wakeupAtdevice}{NTM}, 0, -3 )
: 0
);