2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00

30_tradfri.pm, 39_alexa.pm: stop and start CoProcess on events from npmjs module

git-svn-id: https://svn.fhem.de/fhem/trunk@18602 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme-1968 2019-02-15 19:18:13 +00:00
parent 30b4e89f4e
commit d2f8255ccc
2 changed files with 26 additions and 7 deletions

View File

@ -7,7 +7,6 @@ use strict;
use warnings; use warnings;
use CoProcess; use CoProcess;
#require "30_HUEBridge.pm";
require "$attr{global}{modpath}/FHEM/30_HUEBridge.pm"; require "$attr{global}{modpath}/FHEM/30_HUEBridge.pm";
use JSON; use JSON;
@ -78,7 +77,7 @@ tradfri_Define($$)
tradfri_AttrDefaults($hash); tradfri_AttrDefaults($hash);
$hash->{NOTIFYDEV} = "global"; $hash->{NOTIFYDEV} = "global,global:npmjs.*tradfri-fhem.*";
if( !AttrVal($name, 'devStateIcon', undef ) ) { if( !AttrVal($name, 'devStateIcon', undef ) ) {
CommandAttr(undef, "$name createGroupReadings 0"); CommandAttr(undef, "$name createGroupReadings 0");
@ -107,9 +106,19 @@ tradfri_Notify($$)
my ($hash,$dev) = @_; my ($hash,$dev) = @_;
return if($dev->{NAME} ne "global"); return if($dev->{NAME} ne "global");
return if(!grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}}));
CoProcess::start($hash); if( grep(m/^npmjs:BEGIN.*tradfri-fhem.*/, @{$dev->{CHANGED}}) ) {
CoProcess::stop($hash);
return undef;
} elsif( grep(m/^npmjs:FINISH.*tradfri-fhem.*/, @{$dev->{CHANGED}}) ) {
CoProcess::start($hash);
return undef;
} elsif( grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}}) ) {
CoProcess::start($hash);
return undef;
}
return undef; return undef;
} }

View File

@ -129,7 +129,7 @@ alexa_Define($$)
alexa_AttrDefaults($hash); alexa_AttrDefaults($hash);
$hash->{NOTIFYDEV} = "global"; $hash->{NOTIFYDEV} = "global,global:npmjs.*alexa-fhem.*";
if( $attr{global}{logdir} ) { if( $attr{global}{logdir} ) {
CommandAttr(undef, "$name alexaFHEM-log %L/alexa-%Y-%m-%d.log") if( !AttrVal($name, 'alexaFHEM-log', undef ) ); CommandAttr(undef, "$name alexaFHEM-log %L/alexa-%Y-%m-%d.log") if( !AttrVal($name, 'alexaFHEM-log', undef ) );
@ -163,9 +163,19 @@ alexa_Notify($$)
my ($hash,$dev) = @_; my ($hash,$dev) = @_;
return if($dev->{NAME} ne "global"); return if($dev->{NAME} ne "global");
return if(!grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}}));
CoProcess::start($hash); if( grep(m/^npmjs:BEGIN.*alexa-fhem.*/, @{$dev->{CHANGED}}) ) {
CoProcess::stop($hash);
return undef;
} elsif( grep(m/^npmjs:FINISH.*alexa-fhem.*/, @{$dev->{CHANGED}}) ) {
CoProcess::start($hash);
return undef;
} elsif( grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}}) ) {
CoProcess::start($hash);
return undef;
}
return undef; return undef;
} }