mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-15 22:26:04 +00:00
RESIDENTStk wakeuptimer: use new at-device attribute computeAfterInit
git-svn-id: https://svn.fhem.de/fhem/trunk@12026 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
eb356cb166
commit
3da1f2ee3f
@ -218,13 +218,17 @@ sub GUEST_Notify($$) {
|
|||||||
foreach my $wakeupDev (@registeredWakeupdevs) {
|
foreach my $wakeupDev (@registeredWakeupdevs) {
|
||||||
my $wakeupAtdevice = AttrVal( $wakeupDev, "wakeupAtdevice", 0 );
|
my $wakeupAtdevice = AttrVal( $wakeupDev, "wakeupAtdevice", 0 );
|
||||||
|
|
||||||
# as a replacement for missing NotifyFn in 90_at.pm:
|
# make sure computeAfterInit is set at at-device
|
||||||
# trigger recalculation of at device internal timer
|
# and re-calculate on our own this time
|
||||||
if ( defined( $defs{$wakeupAtdevice} )
|
if ( defined( $defs{$wakeupAtdevice} )
|
||||||
&& $defs{$wakeupAtdevice}{TYPE} eq "at" )
|
&& $defs{$wakeupAtdevice}{TYPE} eq "at"
|
||||||
|
&& AttrVal( $wakeupAtdevice, "computeAfterInit", 0 ) ne
|
||||||
|
"1" )
|
||||||
{
|
{
|
||||||
Log3 $wakeupDev, 4,
|
Log3 $wakeupDev, 3,
|
||||||
"$wakeupDev: Triggered recalculation via Perl function after reboot";
|
"RESIDENTStk $wakeupDev: Correcting '$wakeupAtdevice' attribute computeAfterInit required for correct recalculation after reboot";
|
||||||
|
fhem "attr $wakeupAtdevice computeAfterInit 1";
|
||||||
|
|
||||||
my $command;
|
my $command;
|
||||||
( $command, undef ) =
|
( $command, undef ) =
|
||||||
split( "[ \t]+", $defs{$wakeupAtdevice}{DEF}, 2 );
|
split( "[ \t]+", $defs{$wakeupAtdevice}{DEF}, 2 );
|
||||||
@ -495,7 +499,7 @@ sub GUEST_Set($@) {
|
|||||||
|
|
||||||
# stop any running wakeup-timers in case state changed
|
# stop any running wakeup-timers in case state changed
|
||||||
my $wakeupState = ReadingsVal( $name, "wakeup", 0 );
|
my $wakeupState = ReadingsVal( $name, "wakeup", 0 );
|
||||||
if ($wakeupState > 0) {
|
if ( $wakeupState > 0 ) {
|
||||||
my $wakeupDeviceList = AttrVal( $name, "rg_wakeupDevice", 0 );
|
my $wakeupDeviceList = AttrVal( $name, "rg_wakeupDevice", 0 );
|
||||||
|
|
||||||
for my $wakeupDevice ( split /,/, $wakeupDeviceList ) {
|
for my $wakeupDevice ( split /,/, $wakeupDeviceList ) {
|
||||||
@ -506,11 +510,13 @@ sub GUEST_Set($@) {
|
|||||||
{
|
{
|
||||||
# forced-stop only if resident is not present anymore
|
# forced-stop only if resident is not present anymore
|
||||||
if ( $newpresence eq "present" ) {
|
if ( $newpresence eq "present" ) {
|
||||||
Log3 $name, 4, "ROOMMATE $name: ending wakeup-timer $wakeupDevice";
|
Log3 $name, 4,
|
||||||
|
"ROOMMATE $name: ending wakeup-timer $wakeupDevice";
|
||||||
fhem "set $wakeupDevice:FILTER=running!=0 end";
|
fhem "set $wakeupDevice:FILTER=running!=0 end";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log3 $name, 4, "ROOMMATE $name: stopping wakeup-timer $wakeupDevice";
|
Log3 $name, 4,
|
||||||
|
"ROOMMATE $name: stopping wakeup-timer $wakeupDevice";
|
||||||
fhem "set $wakeupDevice:FILTER=running!=0 stop";
|
fhem "set $wakeupDevice:FILTER=running!=0 stop";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,18 +170,6 @@ sub ROOMMATE_Define($$) {
|
|||||||
. "). Some attribute based functions like auto-creations will not be available.";
|
. "). Some attribute based functions like auto-creations will not be available.";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Injecting NotifyFn for use with RESIDENTS Toolkit
|
|
||||||
# if ( !defined( $modules{at}{NotifyFn} ) ) {
|
|
||||||
# Log3 $name, 1, "RESIDENTStk $name: DEBUG - INJECTED AT";
|
|
||||||
# $modules{at}{NotifyFn} = "RESIDENTStk_NotifyFnAt";
|
|
||||||
# }
|
|
||||||
# elsif ( $modules{at}{NotifyFn} ne "RESIDENTStk_NotifyFnAt" ) {
|
|
||||||
# Log3 $name, 4,
|
|
||||||
#"RESIDENTStk $name: concurrent NotifyFn already defined for at module ("
|
|
||||||
# . $modules{at}{NotifyFn}
|
|
||||||
# . "). This might lead to issues for restoring wakeuptimer after FHEM reboot!";
|
|
||||||
# }
|
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,13 +223,17 @@ sub ROOMMATE_Notify($$) {
|
|||||||
foreach my $wakeupDev (@registeredWakeupdevs) {
|
foreach my $wakeupDev (@registeredWakeupdevs) {
|
||||||
my $wakeupAtdevice = AttrVal( $wakeupDev, "wakeupAtdevice", 0 );
|
my $wakeupAtdevice = AttrVal( $wakeupDev, "wakeupAtdevice", 0 );
|
||||||
|
|
||||||
# as a replacement for missing NotifyFn in 90_at.pm:
|
# make sure computeAfterInit is set at at-device
|
||||||
# trigger recalculation of at device internal timer
|
# and re-calculate on our own this time
|
||||||
if ( defined( $defs{$wakeupAtdevice} )
|
if ( defined( $defs{$wakeupAtdevice} )
|
||||||
&& $defs{$wakeupAtdevice}{TYPE} eq "at" )
|
&& $defs{$wakeupAtdevice}{TYPE} eq "at"
|
||||||
|
&& AttrVal( $wakeupAtdevice, "computeAfterInit", 0 ) ne
|
||||||
|
"1" )
|
||||||
{
|
{
|
||||||
Log3 $wakeupDev, 4,
|
Log3 $wakeupDev, 3,
|
||||||
"$wakeupDev: Triggered recalculation via Perl function after reboot";
|
"RESIDENTStk $wakeupDev: Correcting '$wakeupAtdevice' attribute computeAfterInit required for correct recalculation after reboot";
|
||||||
|
fhem "attr $wakeupAtdevice computeAfterInit 1";
|
||||||
|
|
||||||
my $command;
|
my $command;
|
||||||
( $command, undef ) =
|
( $command, undef ) =
|
||||||
split( "[ \t]+", $defs{$wakeupAtdevice}{DEF}, 2 );
|
split( "[ \t]+", $defs{$wakeupAtdevice}{DEF}, 2 );
|
||||||
|
@ -254,6 +254,7 @@ if (\$EVTPART0 eq \"stop\") {\
|
|||||||
"define $wakeupAtdevice at *{RESIDENTStk_wakeupGetBegin(\"$NAME\",\"$wakeupAtdevice\")} set $NAME trigger";
|
"define $wakeupAtdevice at *{RESIDENTStk_wakeupGetBegin(\"$NAME\",\"$wakeupAtdevice\")} set $NAME trigger";
|
||||||
fhem
|
fhem
|
||||||
"attr $wakeupAtdevice comment Auto-created by RESIDENTS Toolkit: trigger wake-up timer at specific time";
|
"attr $wakeupAtdevice comment Auto-created by RESIDENTS Toolkit: trigger wake-up timer at specific time";
|
||||||
|
fhem "attr $wakeupAtdevice computeAfterInit 1";
|
||||||
fhem "attr $wakeupAtdevice room $room"
|
fhem "attr $wakeupAtdevice room $room"
|
||||||
if ($room);
|
if ($room);
|
||||||
|
|
||||||
@ -684,6 +685,11 @@ if (\$EVTPART0 eq \"stop\") {\
|
|||||||
Log3 $NAME, 3,
|
Log3 $NAME, 3,
|
||||||
"RESIDENTStk $NAME: WARNING - defined at-device '$wakeupAtdevice' is not an at-device!";
|
"RESIDENTStk $NAME: WARNING - defined at-device '$wakeupAtdevice' is not an at-device!";
|
||||||
}
|
}
|
||||||
|
elsif ( AttrVal( $wakeupAtdevice, "computeAfterInit", 0 ) ne "1" ) {
|
||||||
|
Log3 $NAME, 3,
|
||||||
|
"RESIDENTStk $NAME: Correcting '$wakeupAtdevice' attribute computeAfterInit required for correct recalculation after reboot";
|
||||||
|
fhem "attr $wakeupAtdevice computeAfterInit 1";
|
||||||
|
}
|
||||||
|
|
||||||
# verify holiday2we attribute
|
# verify holiday2we attribute
|
||||||
if ($wakeupHolidays) {
|
if ($wakeupHolidays) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user