2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-21 01:46:08 +00:00

cloneDummy.pm: minor changes

git-svn-id: https://svn.fhem.de/fhem/trunk@13009 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
betateilchen 2017-01-08 11:19:58 +00:00
parent 9dfbf927c4
commit b3a9f1f13b

View File

@ -1,4 +1,8 @@
# $Id$ # $Id$
#
# interims check-in with some bugfixes (betateilchen) 2017-01-07
#
################################################################################ ################################################################################
# 98_cloneDummy # 98_cloneDummy
# Von Joachim Herold # Von Joachim Herold
@ -33,6 +37,7 @@ sub cloneDummy_Initialize($) {
$hash->{DefFn} = "cloneDummy_Define"; $hash->{DefFn} = "cloneDummy_Define";
$hash->{NotifyFn} = "cloneDummy_Notify"; $hash->{NotifyFn} = "cloneDummy_Notify";
$hash->{AttrList} = "cloneIgnore " $hash->{AttrList} = "cloneIgnore "
."deleteBeforeUpdate:0,1 "
."addStateEvent:0,1 " ."addStateEvent:0,1 "
.$readingFnAttributes; .$readingFnAttributes;
} }
@ -51,8 +56,9 @@ sub cloneDummy_Define($$) {
if($a[0] eq $a[2]); if($a[0] eq $a[2]);
my $hn = $hash->{NAME}; my $hn = $hash->{NAME};
$hash->{NOTIFYDEV} = $a[2]; $hash->{NOTIFYDEV} = '.*';
$hash->{NOTIFYSTATE} = $a[3] if(defined($a[3])); # $hash->{NOTIFYDEV} = $a[2];
# $hash->{NOTIFYSTATE} = $a[3] if(defined($a[3]));
$attr{$hn}{stateFormat} = "_state" if(defined($a[3])); $attr{$hn}{stateFormat} = "_state" if(defined($a[3]));
readingsSingleUpdate($hash,'state','defined',1); readingsSingleUpdate($hash,'state','defined',1);
Log3($hash,4,"cloneDummy: $a[0] defined for source $a[2]"); Log3($hash,4,"cloneDummy: $a[0] defined for source $a[2]");
@ -73,7 +79,8 @@ sub cloneDummy_Notify($$) {
$hs = $hash->{NOTIFYSTATE}; $hs = $hash->{NOTIFYSTATE};
} }
readingsSingleUpdate($hash,"state", "active",1); CommandDeleteReading(undef,"$hn .*") if(AttrVal($hn,'deleteBeforeUpdate',0));
readingsBeginUpdate($hash); readingsBeginUpdate($hash);
for(my $i=0;$i<$max;$i++){ for(my $i=0;$i<$max;$i++){
@ -99,7 +106,7 @@ sub cloneDummy_Notify($$) {
} }
} }
readingsEndUpdate($hash, 1); # readingsEndUpdate($hash, 1);
return; return;
} }
@ -107,6 +114,8 @@ sub cloneDummy_Notify($$) {
1; 1;
=pod =pod
=item summary clone a device and its readings
=item summary_DE klont ein device und seine readings
=begin html =begin html
<a name="cloneDummy"></a> <a name="cloneDummy"></a>
@ -158,6 +167,9 @@ sub cloneDummy_Notify($$) {
<li>cloneIgnore <li>cloneIgnore
<br>- comma separated list of readingnames that will NOT be generated.<br> <br>- comma separated list of readingnames that will NOT be generated.<br>
Usefull to prevent truncated readingnames coming from state events.</li> Usefull to prevent truncated readingnames coming from state events.</li>
<br>
<li>deleteBeforeUpdate<br>
If set to 1, all readings will be deleted befor update.</li>
<br> <br>
<li><a href="#readingFnAttributes">readingFnAttributes</a></li> <li><a href="#readingFnAttributes">readingFnAttributes</a></li>
</ul> </ul>
@ -226,6 +238,9 @@ sub cloneDummy_Notify($$) {
Eine durch Kommata getrennte Liste der readings, die cloneDummy nicht in eigene readings Eine durch Kommata getrennte Liste der readings, die cloneDummy nicht in eigene readings
umwandelt</li> umwandelt</li>
<br> <br>
<li>deleteBeforeUpdate<br>
Ist dieses Attribut auf 1 gesetzt, werden alle readings zuerst gelöscht, bevor neue Readings geschrieben werden.</li>
<br>
<li><a href="#readingFnAttributes">readingFnAttributes</a></li> <li><a href="#readingFnAttributes">readingFnAttributes</a></li>
</ul> </ul>
<br> <br>