2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

HMCCU: Version 3.9.003

git-svn-id: https://svn.fhem.de/fhem/trunk@13427 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
zap 2017-02-17 16:30:12 +00:00
parent 30aa28b6ec
commit 757bced06b
3 changed files with 35 additions and 51 deletions

View File

@ -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.
- feature: 88_HMCCU: advanced reading filters
- feature: 74_AMAD: add closeCall command - feature: 74_AMAD: add closeCall command
- bugfix: 98_DOIFtools: some more webname issues - bugfix: 98_DOIFtools: some more webname issues
- bugfix: 98_DOIFtools: webname ignored - bugfix: 98_DOIFtools: webname ignored

View File

@ -4,7 +4,7 @@
# #
# $Id$ # $Id$
# #
# Version 3.9.002 # Version 3.9.003
# #
# Module for communication between FHEM and Homematic CCU2. # Module for communication between FHEM and Homematic CCU2.
# Supports BidCos-RF, BidCos-Wired, HmIP-RF, virtual CCU channels, # Supports BidCos-RF, BidCos-Wired, HmIP-RF, virtual CCU channels,
@ -104,7 +104,7 @@ my %HMCCU_CUST_CHN_DEFAULTS;
my %HMCCU_CUST_DEV_DEFAULTS; my %HMCCU_CUST_DEV_DEFAULTS;
# HMCCU version # HMCCU version
my $HMCCU_VERSION = '3.9.002'; my $HMCCU_VERSION = '3.9.003';
# RPC Ports and URL extensions # RPC Ports and URL extensions
my %HMCCU_RPC_NUMPORT = ( my %HMCCU_RPC_NUMPORT = (
@ -335,7 +335,7 @@ sub HMCCU_Define ($$)
$hash->{CCUNum} = $ccucount+1; $hash->{CCUNum} = $ccucount+1;
$hash->{version} = $HMCCU_VERSION; $hash->{version} = $HMCCU_VERSION;
$hash->{ccutype} = 'CCU2'; $hash->{ccutype} = 'CCU2';
$hash->{DevCount} = HMCCU_GetDeviceList ($hash); ($hash->{DevCount}, $hash->{ChnCount}) = HMCCU_GetDeviceList ($hash);
$hash->{NewDevices} = 0; $hash->{NewDevices} = 0;
$hash->{DelDevices} = 0; $hash->{DelDevices} = 0;
$hash->{RPCState} = "stopped"; $hash->{RPCState} = "stopped";
@ -969,8 +969,6 @@ sub HMCCU_Set ($@)
my $ccuflags = AttrVal ($name, 'ccuflags', 'null'); my $ccuflags = AttrVal ($name, 'ccuflags', 'null');
my $stripchar = AttrVal ($name, "stripchar", ''); my $stripchar = AttrVal ($name, "stripchar", '');
# my ($sc, $statedatapoint, $cc, $cd) = HMCCU_GetSpecialDatapoints ($hash, '', 'STATE', '', '');
# my $statevals = AttrVal ($name, "statevals", '');
my $ccureadings = AttrVal ($name, "ccureadings", 1); my $ccureadings = AttrVal ($name, "ccureadings", 1);
my $readingformat = HMCCU_GetAttrReadingFormat ($hash, $hash); my $readingformat = HMCCU_GetAttrReadingFormat ($hash, $hash);
my $substitute = HMCCU_GetAttrSubstitute ($hash, $hash); my $substitute = HMCCU_GetAttrSubstitute ($hash, $hash);
@ -1144,9 +1142,6 @@ sub HMCCU_Get ($@)
my $ccureadingformat = HMCCU_GetAttrReadingFormat ($hash, $hash); my $ccureadingformat = HMCCU_GetAttrReadingFormat ($hash, $hash);
my $ccureadings = AttrVal ($name, "ccureadings", 1); my $ccureadings = AttrVal ($name, "ccureadings", 1);
my $parfile = AttrVal ($name, "parfile", ''); my $parfile = AttrVal ($name, "parfile", '');
# my ($sc, $statedatapoint, $cc, $cd) = HMCCU_GetSpecialDatapoints ($hash, '', 'STATE', '', '');
# my $substitute = AttrVal ($name, 'substitute', '');
# my $rpcport = AttrVal ($name, 'rpcport', 2001);
my $rpcport = $hash->{hmccu}{rpcports}; my $rpcport = $hash->{hmccu}{rpcports};
my $readname; my $readname;
@ -1282,10 +1277,10 @@ sub HMCCU_Get ($@)
return "RPC process not running"; return "RPC process not running";
} }
elsif ($opt eq 'devicelist') { elsif ($opt eq 'devicelist') {
$hash->{DevCount} = HMCCU_GetDeviceList ($hash); ($hash->{DevCount}, $hash->{ChnCount}) = HMCCU_GetDeviceList ($hash);
return HMCCU_SetError ($hash, -2) if ($hash->{DevCount} < 0); return HMCCU_SetError ($hash, -2) if ($hash->{DevCount} < 0);
return HMCCU_SetError ($hash, "No devices received from CCU") if ($hash->{DevCount} == 0); return HMCCU_SetError ($hash, "No devices received from CCU") if ($hash->{DevCount} == 0);
$result = "Read ".$hash->{DevCount}." devices/channels from CCU"; $result = "Read ".$hash->{DevCount}." devices with ".$hash->{ChnCount}." channels from CCU";
my $optcmd = shift @$a; my $optcmd = shift @$a;
if (defined ($optcmd)) { if (defined ($optcmd)) {
@ -1551,6 +1546,7 @@ sub HMCCU_FilterReading ($$$)
{ {
my ($hash, $chn, $dpt) = @_; my ($hash, $chn, $dpt) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $fnc = "FilterReading";
my $hmccu_hash = HMCCU_GetHash ($hash); my $hmccu_hash = HMCCU_GetHash ($hash);
return 1 if (!defined ($hmccu_hash)); return 1 if (!defined ($hmccu_hash));
@ -1559,35 +1555,36 @@ sub HMCCU_FilterReading ($$$)
my $grf = AttrVal ($hmccu_hash->{NAME}, 'ccudef-readingfilter', ''); my $grf = AttrVal ($hmccu_hash->{NAME}, 'ccudef-readingfilter', '');
$grf = '.*' if ($grf eq ''); $grf = '.*' if ($grf eq '');
my $rf = AttrVal ($name, 'ccureadingfilter', $grf); my $rf = AttrVal ($name, 'ccureadingfilter', $grf);
$rf .= ";".$grf if ($rf ne $grf && $grf ne '.*' && $grf ne ''); $rf = $grf.";".$rf if ($rf ne $grf && $grf ne '.*' && $grf ne '');
my $chnnam = HMCCU_IsChnAddr ($chn, 0) ? HMCCU_GetChannelName ($hmccu_hash, $chn, '') : $chn; my $chnnam = HMCCU_IsChnAddr ($chn, 0) ? HMCCU_GetChannelName ($hmccu_hash, $chn, '') : $chn;
Log3 $name, 2, "HMCCU: FilterReading: dpt=$dpt chnname=$chnnam rf=$rf" if ($cf =~ /trace/);
my $rm = 1;
my @rules = split (';', $rf); my @rules = split (';', $rf);
foreach my $r (@rules) { foreach my $r (@rules) {
$rm = 1;
if ($r =~ /^N:/) {
$rm = 0;
$r =~ s/^N://;
}
Log3 $name, 2, "HMCCU: rm=$rm, r=$r, dpt=$dpt" if ($cf =~ /trace/);
my ($c, $f) = split ("!", $r); my ($c, $f) = split ("!", $r);
if (defined ($f) && $chnnam ne '') { if (defined ($f) && $chnnam ne '') {
if ($chnnam =~ /$c/) { if ($chnnam =~ /$c/) {
if ($dpt !~ /$f/) { return $rm if (($rm && $dpt =~ /$r/) || (!$rm && $dpt =~ /$r/));
Log3 $name, 2, "HMCCU: FilterReading: Datapoint $dpt doesn't match filter $rf" return $rm ? 0 : 1;
if ($cf =~ /trace/);
return 0;
}
else {
return 1;
}
} }
} }
else { else {
return 1 if ($dpt =~ /$r/); Log3 $name, 2, "HMCCU: Check $rm = 1 AND $dpt = $r OR $rm = 0 AND $dpt = $r"
if ($cf =~ /trace/);
return $rm if (($rm && $dpt =~ /$r/) || (!$rm && $dpt =~ /$r/));
Log3 $name, 2, "HMCCU: Check negative" if ($cf =~ /trace/);
} }
} }
Log3 $name, 2, "HMCCU: FilterReading: Datapoint $dpt doesn't match filter $rf" Log3 $name, 2, "HMCCU: rm = $rm ? 0 : 1" if ($cf =~ /trace/);
if ($cf =~ /trace/); return $rm ? 0 : 1;
return 0;
} }
###################################################################### ######################################################################
@ -1855,8 +1852,6 @@ sub HMCCU_SubstRule ($$$)
if ($value =~ /^\d*\.?\d+?$/ && $value >= $mi && $value <= $ma) { if ($value =~ /^\d*\.?\d+?$/ && $value >= $mi && $value <= $ma) {
$value = $text; $value = $text;
$rc = 1; $rc = 1;
# my $x = eval { $value =~ s/^\d*\.?\d+?/$text/ };
# $rc = 1 if (defined ($x)); last;
} }
} }
if ($mode == 0 && $value =~ /$regexp/ && $value !~ /^[+-]?\d+$/) { if ($mode == 0 && $value =~ /$regexp/ && $value !~ /^[+-]?\d+$/) {
@ -2422,13 +2417,6 @@ sub HMCCU_StartIntRPCServer ($)
$child->{devname} = $name; $child->{devname} = $name;
$child->{queue} = $rpcqueueport; $child->{queue} = $rpcqueueport;
# Log3 $name, 2, "HMCCU: Child socket snd buffer = ".$child->getsndbuffer ($child->child());
# Log3 $name, 2, "HMCCU: Child socket rcv buffer = ".$child->getrcvbuffer ($child->child());
# Log3 $name, 2, "HMCCU: Parent socket snd buffer = ".$child->getrcvbuffer ($child->parent());
# Log3 $name, 2, "HMCCU: Parent socket rcv buffer = ".$child->getrcvbuffer ($child->parent());
# Log3 $name, 2, "HMCCU: Parent socket snd lowat = ".$child->getsndlowat ($child->parent());
# Log3 $name, 2, "HMCCU: Parent socket rcv lowat = ".$child->getrcvlowat ($child->parent());
# Start child process # Start child process
my $pid = $child->run (); my $pid = $child->run ();
if (!defined ($pid)) { if (!defined ($pid)) {
@ -2743,7 +2731,8 @@ sub HMCCU_FormatDeviceInfo ($)
sub HMCCU_GetDeviceList ($) sub HMCCU_GetDeviceList ($)
{ {
my ($hash) = @_; my ($hash) = @_;
my $count = 0; my $devcount = 0;
my $chncount = 0;
my $script = qq( my $script = qq(
string devid; string devid;
@ -2782,7 +2771,7 @@ foreach(devid, root.Devices().EnumUsedIDs()) {
$hash->{hmccu}{adr}{$hmdata[3]}{address} = $hmdata[2]; $hash->{hmccu}{adr}{$hmdata[3]}{address} = $hmdata[2];
$hash->{hmccu}{adr}{$hmdata[3]}{addtype} = 'dev'; $hash->{hmccu}{adr}{$hmdata[3]}{addtype} = 'dev';
$hash->{hmccu}{adr}{$hmdata[3]}{valid} = 1; $hash->{hmccu}{adr}{$hmdata[3]}{valid} = 1;
$count++; $devcount++;
} }
elsif ($hmdata[0] eq 'C') { elsif ($hmdata[0] eq 'C') {
# 1=Channel-Address 2=Channel-Name # 1=Channel-Address 2=Channel-Name
@ -2793,7 +2782,7 @@ foreach(devid, root.Devices().EnumUsedIDs()) {
$hash->{hmccu}{adr}{$hmdata[2]}{address} = $hmdata[1]; $hash->{hmccu}{adr}{$hmdata[2]}{address} = $hmdata[1];
$hash->{hmccu}{adr}{$hmdata[2]}{addtype} = 'chn'; $hash->{hmccu}{adr}{$hmdata[2]}{addtype} = 'chn';
$hash->{hmccu}{adr}{$hmdata[2]}{valid} = 1; $hash->{hmccu}{adr}{$hmdata[2]}{valid} = 1;
$count++; $chncount++;
} }
} }
@ -2826,7 +2815,7 @@ foreach(devid, root.Devices().EnumUsedIDs()) {
$hash->{NewDevices} = 0; $hash->{NewDevices} = 0;
$hash->{DelDevices} = 0; $hash->{DelDevices} = 0;
return $count; return ($devcount, $chncount);
} }
#################################################### ####################################################
@ -3012,16 +3001,9 @@ sub HMCCU_GetCCUDeviceParam ($$)
if (exists ($hash->{hmccu}{adr}{$param})) { if (exists ($hash->{hmccu}{adr}{$param})) {
$add = $hash->{hmccu}{adr}{$param}{address}; $add = $hash->{hmccu}{adr}{$param}{address};
} }
# else {
# Log3 $name, 2, "HMCCU: Address for $param not found";
# }
} }
} }
# Log3 $name, 2, "HMCCU: Address not defined" if (!defined ($add));
# Log3 $name, 2, "HMCCU: Device not found for $add" if (!exists ($hash->{hmccu}{dev}{$add}));
# Log3 $name, 2, "HMCCU: Device invalid for $add" if ($hash->{hmccu}{dev}{$add}{valid} == 0);
return (undef, undef, undef, undef) if (!defined ($add)); return (undef, undef, undef, undef) if (!defined ($add));
($devadd, $chn) = HMCCU_SplitChnAddr ($add); ($devadd, $chn) = HMCCU_SplitChnAddr ($add);
return (undef, undef, undef, undef) if (!defined ($devadd) || return (undef, undef, undef, undef) if (!defined ($devadd) ||

View File

@ -4,7 +4,7 @@
# #
# $Id$ # $Id$
# #
# Version 3.9.001 # Version 3.9.003
# #
# (c) 2016 zap (zap01 <at> t-online <dot> de) # (c) 2016 zap (zap01 <at> t-online <dot> de)
# #
@ -808,11 +808,12 @@ sub HMCCUCHN_SetError ($$)
</li><br/> </li><br/>
<li><b>ccureadingfilter &lt;filter-rule[;...]&gt;</b><br/> <li><b>ccureadingfilter &lt;filter-rule[;...]&gt;</b><br/>
Only datapoints matching specified expression are stored as readings.<br/> Only datapoints matching specified expression are stored as readings.<br/>
Syntax for <i>filter-rule</i> is: [&lt;channel-name&gt;!]&lt;RegExp&gt;<br/> Syntax for <i>filter-rule</i> is: [N:][&lt;channel-name&gt;!]&lt;RegExp&gt;<br/>
If <i>channel-name</i> is specified the following rule applies only to this channel. If <i>channel-name</i> is specified the following rule applies only to this channel.
If ccuflag 'nohmstate' is not set in I/O device datapoints UNREACH, LOWBAT, LOW_BAT, By default all datapoints will be stored as readings. Attribute ccudef-readingfilter
ERROR.* and FAULT.* are always stored as readings and must not be specified in this of I/O device will be checked before this attribute.<br/>
attribute. If a rule starts with 'N:' the filter is negated which means that a reading is
stored if rule doesn't match.
</li><br/> </li><br/>
<li><b>ccureadingformat {address[lc] | name[lc] | datapoint[lc]}</b><br/> <li><b>ccureadingformat {address[lc] | name[lc] | datapoint[lc]}</b><br/>
Set format of reading names. Default is 'name'. If set to 'address' format of reading names Set format of reading names. Default is 'name'. If set to 'address' format of reading names