From 09b64d5e8d751debbf6d40178fef620597c9821c Mon Sep 17 00:00:00 2001 From: justme-1968 Date: Sun, 12 Apr 2020 18:44:12 +0000 Subject: [PATCH] 39_alexa.pm: possible fix for 0 byte log files with the default name if alexaFHEM-log is used git-svn-id: https://svn.fhem.de/fhem/trunk@21651 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/39_alexa.pm | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/fhem/FHEM/39_alexa.pm b/fhem/FHEM/39_alexa.pm index 13e70dd47..9c43ad120 100644 --- a/fhem/FHEM/39_alexa.pm +++ b/fhem/FHEM/39_alexa.pm @@ -54,7 +54,7 @@ alexa_Initialize($) #"alexaFHEM-filter ". "alexaFHEM-host alexaFHEM-sshUser ". "nrarchive ". - "disable:1 disabledForIntervals ". + "disable:1,0 disabledForIntervals ". $readingFnAttributes; $hash->{FW_detailFn} = "alexa_detailFn"; @@ -116,6 +116,16 @@ alexa_AttrDefaults($) } +sub +alexa_InitLog($) { + my $name = shift; + if( $attr{global}{logdir} ) { + CommandAttr(undef, "$name alexaFHEM-log %L/alexa-%Y-%m-%d.log") if( !AttrVal($name, 'alexaFHEM-log', undef ) ); + } else { + CommandAttr(undef, "$name alexaFHEM-log ./log/alexa-%Y-%m-%d.log") if( !AttrVal($name, 'alexaFHEM-log', undef ) ); + } +} + sub alexa_Define($$) { @@ -144,12 +154,6 @@ alexa_Define($$) $hash->{NOTIFYDEV} = "global,global:npmjs.*alexa-fhem.*"; - if( $attr{global}{logdir} ) { - CommandAttr(undef, "$name alexaFHEM-log %L/alexa-%Y-%m-%d.log") if( !AttrVal($name, 'alexaFHEM-log', undef ) ); - } else { - CommandAttr(undef, "$name alexaFHEM-log ./log/alexa-%Y-%m-%d.log") if( !AttrVal($name, 'alexaFHEM-log', undef ) ); - } - #CommandAttr(undef, "$name alexaFHEM-filter alexaName=..*") if( !AttrVal($name, 'alexaFHEM-filter', undef ) ); if( !AttrVal($name, 'devStateIcon', undef ) ) { @@ -162,6 +166,7 @@ alexa_Define($$) }; if( $init_done ) { + alexa_InitLog($name); CoProcess::start($hash); } else { $hash->{STATE} = 'active'; @@ -186,6 +191,7 @@ alexa_Notify($$) return undef; } elsif( grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}}) ) { + alexa_InitLog($hash->{NAME}); CoProcess::start($hash); return undef; }