HMCCU: bug fixes and enhanced handling of datapoints
git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@10181 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
# $Id:$
|
# $Id:$
|
||||||
#
|
#
|
||||||
# Version 2.2
|
# Version 2.3
|
||||||
#
|
#
|
||||||
# (c) 2015 zap (zap01 <at> t-online <dot> de)
|
# (c) 2015 zap (zap01 <at> t-online <dot> de)
|
||||||
#
|
#
|
||||||
@@ -25,6 +25,7 @@
|
|||||||
#
|
#
|
||||||
# attr <name> ccureadings { 0 | 1 }
|
# attr <name> ccureadings { 0 | 1 }
|
||||||
# attr <name> ccureadingformat { address | name }
|
# attr <name> ccureadingformat { address | name }
|
||||||
|
# attr <name> ccureadingfilter <regexp>
|
||||||
# attr <name> statechannel <channel>
|
# attr <name> statechannel <channel>
|
||||||
# attr <name> statedatapoint <datapoint>
|
# attr <name> statedatapoint <datapoint>
|
||||||
# attr <name> statevals <text1>:<subtext1>[,...]
|
# attr <name> statevals <text1>:<subtext1>[,...]
|
||||||
@@ -60,7 +61,7 @@ sub HMCCUDEV_Initialize ($)
|
|||||||
$hash->{GetFn} = "HMCCUDEV_Get";
|
$hash->{GetFn} = "HMCCUDEV_Get";
|
||||||
$hash->{AttrFn} = "HMCCUDEV_Attr";
|
$hash->{AttrFn} = "HMCCUDEV_Attr";
|
||||||
|
|
||||||
$hash->{AttrList} = "IODev ccureadingformat:name,address ccureadings:0,1 statevals substitute statechannel statedatapoint loglevel:0,1,2,3,4,5,6 ". $readingFnAttributes;
|
$hash->{AttrList} = "IODev ccureadingfilter ccureadingformat:name,address ccureadings:0,1 statevals substitute statechannel statedatapoint stripnumber:0,1,2 loglevel:0,1,2,3,4,5,6 ". $readingFnAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
@@ -202,7 +203,7 @@ sub HMCCUDEV_Set ($@)
|
|||||||
if (!defined ($objname) || $objname !~ /^[0-9]+\..+$/ || !defined ($objvalue)) {
|
if (!defined ($objname) || $objname !~ /^[0-9]+\..+$/ || !defined ($objvalue)) {
|
||||||
return HMCCUDEV_SetError ($hash, "Usage: set <name> datapoint <channel-number>.<datapoint> <value> [...]");
|
return HMCCUDEV_SetError ($hash, "Usage: set <name> datapoint <channel-number>.<datapoint> <value> [...]");
|
||||||
}
|
}
|
||||||
$objvalue = HMCCU_Substitute ($objvalue, $statevals, 1);
|
$objvalue = HMCCU_Substitute ($objvalue, $statevals, 1, '');
|
||||||
|
|
||||||
# Build datapoint address
|
# Build datapoint address
|
||||||
$objname = $hash->{ccuif}.'.'.$hash->{ccuaddr}.':'.$objname;
|
$objname = $hash->{ccuif}.'.'.$hash->{ccuaddr}.':'.$objname;
|
||||||
@@ -214,6 +215,7 @@ sub HMCCUDEV_Set ($@)
|
|||||||
($rc, $result) = HMCCU_GetDatapoint ($hash, $objname);
|
($rc, $result) = HMCCU_GetDatapoint ($hash, $objname);
|
||||||
return HMCCUDEV_SetError ($hash, $rc) if ($rc < 0);
|
return HMCCUDEV_SetError ($hash, $rc) if ($rc < 0);
|
||||||
|
|
||||||
|
HMCCU_SetState ($hash, "OK");
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
elsif ($opt =~ /^($hash->{statevals})$/) {
|
elsif ($opt =~ /^($hash->{statevals})$/) {
|
||||||
@@ -223,7 +225,7 @@ sub HMCCUDEV_Set ($@)
|
|||||||
return HMCCUDEV_SetError ($hash, "No state channel specified") if ($statechannel eq '');
|
return HMCCUDEV_SetError ($hash, "No state channel specified") if ($statechannel eq '');
|
||||||
return HMCCUDEV_SetError ($hash, "Usage: set <name> devstate <value> [...]") if (!defined ($objvalue));
|
return HMCCUDEV_SetError ($hash, "Usage: set <name> devstate <value> [...]") if (!defined ($objvalue));
|
||||||
|
|
||||||
$objvalue = HMCCU_Substitute ($objvalue, $statevals, 1);
|
$objvalue = HMCCU_Substitute ($objvalue, $statevals, 1, '');
|
||||||
|
|
||||||
# Build datapoint address
|
# Build datapoint address
|
||||||
my $objname = $hash->{ccuif}.'.'.$hash->{ccuaddr}.':'.$statechannel.'.'.$statedatapoint;
|
my $objname = $hash->{ccuif}.'.'.$hash->{ccuaddr}.':'.$statechannel.'.'.$statedatapoint;
|
||||||
@@ -235,6 +237,7 @@ sub HMCCUDEV_Set ($@)
|
|||||||
($rc, $result) = HMCCU_GetDatapoint ($hash, $objname);
|
($rc, $result) = HMCCU_GetDatapoint ($hash, $objname);
|
||||||
return HMCCUDEV_SetError ($hash, $rc) if ($rc < 0);
|
return HMCCUDEV_SetError ($hash, $rc) if ($rc < 0);
|
||||||
|
|
||||||
|
HMCCU_SetState ($hash, "OK");
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
elsif ($opt eq 'config') {
|
elsif ($opt eq 'config') {
|
||||||
@@ -244,6 +247,8 @@ sub HMCCUDEV_Set ($@)
|
|||||||
|
|
||||||
my $rc = HMCCU_RPCSetConfig ($hash, $objname, \@a);
|
my $rc = HMCCU_RPCSetConfig ($hash, $objname, \@a);
|
||||||
return HMCCUDEV_SetError ($hash, $rc) if ($rc < 0);
|
return HMCCUDEV_SetError ($hash, $rc) if ($rc < 0);
|
||||||
|
|
||||||
|
HMCCU_SetState ($hash, "OK");
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -308,6 +313,8 @@ sub HMCCUDEV_Get ($@)
|
|||||||
($rc, $result) = HMCCU_GetDatapoint ($hash, $objname);
|
($rc, $result) = HMCCU_GetDatapoint ($hash, $objname);
|
||||||
|
|
||||||
return HMCCUDEV_SetError ($hash, $rc) if ($rc < 0);
|
return HMCCUDEV_SetError ($hash, $rc) if ($rc < 0);
|
||||||
|
|
||||||
|
HMCCU_SetState ($hash, "OK") if (exists ($hash->{STATE}) && $hash->{STATE} eq "Error");
|
||||||
return $ccureadings ? undef : $result;
|
return $ccureadings ? undef : $result;
|
||||||
}
|
}
|
||||||
elsif ($opt eq 'channel') {
|
elsif ($opt eq 'channel') {
|
||||||
@@ -320,6 +327,9 @@ sub HMCCUDEV_Get ($@)
|
|||||||
else {
|
else {
|
||||||
return HMCCUDEV_SetError ($hash, "Invalid channel number: $objname");
|
return HMCCUDEV_SetError ($hash, "Invalid channel number: $objname");
|
||||||
}
|
}
|
||||||
|
if ($objname =~ /^[0-9]{1,2}.*=/) {
|
||||||
|
$objname =~ s/=/ /;
|
||||||
|
}
|
||||||
push (@chnlist, $hash->{ccuif}.'.'.$hash->{ccuaddr}.':'.$objname);
|
push (@chnlist, $hash->{ccuif}.'.'.$hash->{ccuaddr}.':'.$objname);
|
||||||
}
|
}
|
||||||
if (@chnlist == 0) {
|
if (@chnlist == 0) {
|
||||||
@@ -328,8 +338,15 @@ sub HMCCUDEV_Get ($@)
|
|||||||
|
|
||||||
($rc, $result) = HMCCU_GetChannel ($hash, \@chnlist);
|
($rc, $result) = HMCCU_GetChannel ($hash, \@chnlist);
|
||||||
return HMCCUDEV_SetError ($hash, $rc) if ($rc < 0);
|
return HMCCUDEV_SetError ($hash, $rc) if ($rc < 0);
|
||||||
|
|
||||||
|
HMCCU_SetState ($hash, "OK") if (exists ($hash->{STATE}) && $hash->{STATE} eq "Error");
|
||||||
return $ccureadings ? undef : $result;
|
return $ccureadings ? undef : $result;
|
||||||
}
|
}
|
||||||
|
elsif ($opt eq 'deviceinfo') {
|
||||||
|
$result = HMCCU_GetDeviceInfo ($hash, $hash->{ccuaddr});
|
||||||
|
return HMCCUDEV_SetError ($hash, -2) if ($result eq '');
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
elsif ($opt eq 'config') {
|
elsif ($opt eq 'config') {
|
||||||
my $channel = shift @a;
|
my $channel = shift @a;
|
||||||
my $ccuobj = $hash->{ccuaddr};
|
my $ccuobj = $hash->{ccuaddr};
|
||||||
@@ -337,6 +354,7 @@ sub HMCCUDEV_Get ($@)
|
|||||||
|
|
||||||
my ($rc, $res) = HMCCU_RPCGetConfig ($hash, $ccuobj, "getParamset");
|
my ($rc, $res) = HMCCU_RPCGetConfig ($hash, $ccuobj, "getParamset");
|
||||||
return HMCCUDEV_SetError ($hash, $rc) if ($rc < 0);
|
return HMCCUDEV_SetError ($hash, $rc) if ($rc < 0);
|
||||||
|
HMCCU_SetState ($hash, "OK") if (exists ($hash->{STATE}) && $hash->{STATE} eq "Error");
|
||||||
return $ccureadings ? undef : $result;
|
return $ccureadings ? undef : $result;
|
||||||
}
|
}
|
||||||
elsif ($opt eq 'configdesc') {
|
elsif ($opt eq 'configdesc') {
|
||||||
@@ -346,10 +364,11 @@ sub HMCCUDEV_Get ($@)
|
|||||||
|
|
||||||
my ($rc, $res) = HMCCU_RPCGetConfig ($hash, $ccuobj, "getParamsetDescription");
|
my ($rc, $res) = HMCCU_RPCGetConfig ($hash, $ccuobj, "getParamsetDescription");
|
||||||
return HMCCUDEV_SetError ($hash, $rc) if ($rc < 0);
|
return HMCCUDEV_SetError ($hash, $rc) if ($rc < 0);
|
||||||
|
HMCCU_SetState ($hash, "OK") if (exists ($hash->{STATE}) && $hash->{STATE} eq "Error");
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
my $retmsg = "HMCCUDEV: Unknown argument $opt, choose one of datapoint channel config configdesc";
|
my $retmsg = "HMCCUDEV: Unknown argument $opt, choose one of datapoint channel config configdesc deviceinfo:noArg";
|
||||||
if ($statechannel ne '') {
|
if ($statechannel ne '') {
|
||||||
$retmsg .= ' devstate:noArg';
|
$retmsg .= ' devstate:noArg';
|
||||||
}
|
}
|
||||||
@@ -484,6 +503,11 @@ sub HMCCUDEV_SetError ($$)
|
|||||||
<br/>
|
<br/>
|
||||||
If set to 1 values read from CCU will be stored as readings.
|
If set to 1 values read from CCU will be stored as readings.
|
||||||
</li><br/>
|
</li><br/>
|
||||||
|
<li>ccureadingfilter <datapoint-expr>
|
||||||
|
<br/>
|
||||||
|
Only datapoints matching specified expression are stored as
|
||||||
|
readings.
|
||||||
|
</li><br/>
|
||||||
<li>ccureadingformat <address | name>
|
<li>ccureadingformat <address | name>
|
||||||
<br/>
|
<br/>
|
||||||
Set format of readings. Default is 'name'.
|
Set format of readings. Default is 'name'.
|
||||||
@@ -503,10 +527,11 @@ sub HMCCUDEV_SetError ($$)
|
|||||||
<code>attr my_switch statevals on:true,off:false</code><br/>
|
<code>attr my_switch statevals on:true,off:false</code><br/>
|
||||||
<code>set my_switch on</code>
|
<code>set my_switch on</code>
|
||||||
</li><br/>
|
</li><br/>
|
||||||
<li>substitude <expression>:<subststr>[,...]
|
<li>substitude <subst-rule>[;...]
|
||||||
<br/>
|
<br/>
|
||||||
Define substitions for reading values. Substitutions for parfile values must
|
Define substitions for reading values. Substitutions for parfile values must
|
||||||
be specified in parfiles.
|
be specified in parfiles. Syntax of subst-rule is<br/><br/>
|
||||||
|
[datapoint!]<regexp1>:<text1>[,...]
|
||||||
</li><br/>
|
</li><br/>
|
||||||
</ul>
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
Reference in New Issue
Block a user