2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-08 19:32:42 +00:00

98_dewpoint: Use NOTIFYDEV

git-svn-id: https://svn.fhem.de/fhem/trunk@15840 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
hotbso 2018-01-10 17:01:07 +00:00
parent f1e9947ad7
commit 199a01f17e
2 changed files with 32 additions and 5 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
- change: 98_dewpoint: Use NOTIFYDEV
- bugfix: 93_DbRep: syntax error if perl version < 5.20
- feature: 74_AMADDevice: add new set command "takePicture",change Commandref
- feature: 98_GOOGLECAST: support speak command for TTS

View File

@ -101,9 +101,10 @@ dewpoint_Define($$)
eval { "Hallo" =~ m/^$devname$/ };
return "Bad regexp: $@" if($@);
$hash->{DEV_REGEXP} = $devname;
# set NOTIFYDEV
$hash->{NOTIFYDEV} = 'global';
$hash->{STATE} = "active";
return undef;
}
@ -114,14 +115,39 @@ dewpoint_Notify($$)
{
my ($hash, $dev) = @_;
my $re = $hash->{DEV_REGEXP};
my $hashName = $hash->{NAME};
my $devName = $dev->{NAME};
my $re = $hash->{DEV_REGEXP};
# listen to global in order to update our NOTIFYDEV
if ($devName eq 'global') {
# look for INITIALIZED or any device change
my $rebuild;
foreach (@{deviceEvents($dev, 0)}) {
if ($_ =~ m/^(INITIALIZED$)|((DEFINED|MODIFIED|RENAMED|DELETED)\s+)/) {
$rebuild = 1;
last;
}
}
if ($rebuild) {
# notifyRegexpChanged requires complete device names separated by '|'
# while we allow a true regexp
# build list of devices matching our RE
my @matched_devs = ('global', grep { m/^$re$/ } keys(%defs));
my $notify_re = join('|', @matched_devs);
Log3($hashName, 5, "Update NOTIFYDEV to >>$notify_re<<");
notifyRegexpChanged($hash, $notify_re);
}
return undef;
}
# fast exit
return "" if (!defined($re) || $devName !~ m/^$re$/);
my $hashName = $hash->{NAME};
return "" if (AttrVal($hashName, "disable", undef));
my $cmd_type = $hash->{CMD_TYPE};