mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-21 07:56:03 +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:
parent
f1e9947ad7
commit
199a01f17e
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# 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.
|
# 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
|
- bugfix: 93_DbRep: syntax error if perl version < 5.20
|
||||||
- feature: 74_AMADDevice: add new set command "takePicture",change Commandref
|
- feature: 74_AMADDevice: add new set command "takePicture",change Commandref
|
||||||
- feature: 98_GOOGLECAST: support speak command for TTS
|
- feature: 98_GOOGLECAST: support speak command for TTS
|
||||||
|
@ -101,9 +101,10 @@ dewpoint_Define($$)
|
|||||||
|
|
||||||
eval { "Hallo" =~ m/^$devname$/ };
|
eval { "Hallo" =~ m/^$devname$/ };
|
||||||
return "Bad regexp: $@" if($@);
|
return "Bad regexp: $@" if($@);
|
||||||
|
|
||||||
$hash->{DEV_REGEXP} = $devname;
|
$hash->{DEV_REGEXP} = $devname;
|
||||||
|
# set NOTIFYDEV
|
||||||
|
$hash->{NOTIFYDEV} = 'global';
|
||||||
$hash->{STATE} = "active";
|
$hash->{STATE} = "active";
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -114,14 +115,39 @@ dewpoint_Notify($$)
|
|||||||
{
|
{
|
||||||
my ($hash, $dev) = @_;
|
my ($hash, $dev) = @_;
|
||||||
|
|
||||||
my $re = $hash->{DEV_REGEXP};
|
my $hashName = $hash->{NAME};
|
||||||
my $devName = $dev->{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
|
# fast exit
|
||||||
return "" if (!defined($re) || $devName !~ m/^$re$/);
|
return "" if (!defined($re) || $devName !~ m/^$re$/);
|
||||||
|
|
||||||
my $hashName = $hash->{NAME};
|
|
||||||
|
|
||||||
return "" if (AttrVal($hashName, "disable", undef));
|
return "" if (AttrVal($hashName, "disable", undef));
|
||||||
|
|
||||||
my $cmd_type = $hash->{CMD_TYPE};
|
my $cmd_type = $hash->{CMD_TYPE};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user