mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-28 17:12:32 +00:00
98_GAEBUS.pm : add support if ebusd returns a list of semicolon separated values. now several readings can be defined to hold the values
git-svn-id: https://svn.fhem.de/fhem/trunk@9836 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
e344956f20
commit
4c20b6fab3
@ -21,6 +21,9 @@
|
|||||||
# timeout for reads increased
|
# timeout for reads increased
|
||||||
# 19.10.2015 : A.Goebel : add attribute disable to disable loop to collect readings
|
# 19.10.2015 : A.Goebel : add attribute disable to disable loop to collect readings
|
||||||
# 05.11.2015 : A.Goebel : add support for "h" (broadcast update) commands from csv, handle them equal to (r)ead
|
# 05.11.2015 : A.Goebel : add support for "h" (broadcast update) commands from csv, handle them equal to (r)ead
|
||||||
|
# 09.11.2015 : A.Goebel : add support for multiple readings generated from one command to ebusd
|
||||||
|
# ebusd may return a list of values like "52.0;43.0;8.000;41.0;45.0;error"
|
||||||
|
# defining a reading "VL;RL;dummy;VLWW;RLWW" will create redings VL, RL, VLWW and RLWW
|
||||||
|
|
||||||
|
|
||||||
package main;
|
package main;
|
||||||
@ -586,9 +589,11 @@ GAEBUS_Attr(@)
|
|||||||
$reading =~ s/ .*//;
|
$reading =~ s/ .*//;
|
||||||
$reading =~ s/:.*//;
|
$reading =~ s/:.*//;
|
||||||
|
|
||||||
|
foreach my $r (split /;/, $reading) {
|
||||||
Log3 ($name, 3, "$name: delete reading: $reading");
|
Log3 ($name, 3, "$name: delete reading: $reading");
|
||||||
delete($defs{$name}{READINGS}{$reading});
|
delete($defs{$name}{READINGS}{$reading});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -604,26 +609,35 @@ GAEBUS_Attr(@)
|
|||||||
$newreading =~ s/ .*//;
|
$newreading =~ s/ .*//;
|
||||||
$newreading =~ s/:.*//;
|
$newreading =~ s/:.*//;
|
||||||
|
|
||||||
if ($oldreading ne $newreading)
|
my @or = split /;/, $oldreading;
|
||||||
{
|
my @nr = split /;/, $newreading;
|
||||||
#Log3 ($name, 2, "$name: adjust reading: $oldreading");
|
|
||||||
|
|
||||||
if (defined($defs{$name}{READINGS}{$oldreading}))
|
for (my $i; $i <= $#or; $i++)
|
||||||
{
|
{
|
||||||
unless ($newreading =~ /^1*$/) # matches "1" or ""
|
if ($or[$i] ne $nr[$i])
|
||||||
{
|
{
|
||||||
#Log3 ($name, 2, "$name: change attribute $attrname ($oldreading -> $newreading)");
|
#Log3 ($name, 2, "$name: adjust reading: $or[$i]");
|
||||||
|
|
||||||
$defs{$name}{READINGS}{$newreading}{VAL} = $defs{$name}{READINGS}{$oldreading}{VAL};
|
if (defined($defs{$name}{READINGS}{$or[$i]}))
|
||||||
$defs{$name}{READINGS}{$newreading}{TIME} = $defs{$name}{READINGS}{$oldreading}{TIME};
|
{
|
||||||
|
if (defined ($nr[$i] and $nr[$i] ne "dummy" ))
|
||||||
|
{
|
||||||
|
unless ($nr[$i] =~ /^1*$/) # matches "1" or ""
|
||||||
|
{
|
||||||
|
#Log3 ($name, 2, "$name: change attribute $attrname ($or[$i] -> $nr[$i])");
|
||||||
|
|
||||||
|
$defs{$name}{READINGS}{$nr[$i]}{VAL} = $defs{$name}{READINGS}{$or[$i]}{VAL};
|
||||||
|
$defs{$name}{READINGS}{$nr[$i]}{TIME} = $defs{$name}{READINGS}{$or[$i]}{TIME};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete($defs{$name}{READINGS}{$oldreading});
|
delete($defs{$name}{READINGS}{$or[$i]});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Log3 (undef, 2, "called GAEBUS_Attr($a[0],$a[1],$a[2],<$a[3]>)");
|
Log3 (undef, 2, "called GAEBUS_Attr($a[0],$a[1],$a[2],<$a[3]>)");
|
||||||
|
|
||||||
@ -884,7 +898,7 @@ GAEBUS_doEbusCmd($$$$$$$)
|
|||||||
#Log3 ($name, 2, "$name try to read");
|
#Log3 ($name, 2, "$name try to read");
|
||||||
sysread ($hash->{TCPDev}, $actMessage, 4096);
|
sysread ($hash->{TCPDev}, $actMessage, 4096);
|
||||||
$actMessage =~ s/\n//g;
|
$actMessage =~ s/\n//g;
|
||||||
$actMessage =~ s/;/ /g;
|
#$actMessage =~ s/;/ /g;
|
||||||
|
|
||||||
Log3 ($name, 3, "$name answer $action $readingname $actMessage");
|
Log3 ($name, 3, "$name answer $action $readingname $actMessage");
|
||||||
|
|
||||||
@ -907,17 +921,53 @@ GAEBUS_doEbusCmd($$$$$$$)
|
|||||||
Log3 ($name, 2, "$name $actMessage");
|
Log3 ($name, 2, "$name $actMessage");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action eq "r") {
|
my @values = split /;/, $actMessage;
|
||||||
if (defined ($readingname)) {
|
my @targetreading = defined ($readingname) ? split /;/, $readingname : ();
|
||||||
# BlockingCall changes
|
|
||||||
readingsSingleUpdate ($hash, $readingname, "$actMessage", 1);
|
|
||||||
|
if ($inBlockingCall)
|
||||||
|
{
|
||||||
|
$actMessage = "";
|
||||||
|
|
||||||
|
for (my $i=0; $i <= $#targetreading; $i++)
|
||||||
|
{
|
||||||
|
next if ($targetreading[$i] eq "dummy");
|
||||||
|
my $v = defined($values[$i]) ? $values[$i] : "";
|
||||||
|
|
||||||
|
$actMessage .= $targetreading[$i]."|".$v."|";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$actMessage =~ s/\|$//;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($inBlockingCall) {
|
if ($action eq "r")
|
||||||
$actMessage = $readingname."|".$actMessage;
|
{
|
||||||
|
readingsBeginUpdate ($hash);
|
||||||
|
for (my $i=0; $i <= $#targetreading; $i++)
|
||||||
|
{
|
||||||
|
next if ($targetreading[$i] eq "dummy");
|
||||||
|
my $v = defined($values[$i]) ? $values[$i] : "";
|
||||||
|
|
||||||
|
readingsBulkUpdate ($hash, $targetreading[$i], $v);
|
||||||
}
|
}
|
||||||
|
readingsEndUpdate($hash, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if ($inBlockingCall) {
|
||||||
|
# $actMessage = $readingname."|".$actMessage;
|
||||||
|
#}
|
||||||
|
#else {
|
||||||
|
#
|
||||||
|
# if ($action eq "r") {
|
||||||
|
# if (defined ($readingname)) {
|
||||||
|
# # BlockingCall changes
|
||||||
|
# readingsSingleUpdate ($hash, $readingname, "$actMessage", 1);
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
#}
|
||||||
|
|
||||||
|
|
||||||
return $actMessage;
|
return $actMessage;
|
||||||
|
|
||||||
@ -1016,7 +1066,7 @@ GAEBUS_GetUpdatesDoit($)
|
|||||||
}
|
}
|
||||||
|
|
||||||
# returnvalue for BlockingCall ... done routine
|
# returnvalue for BlockingCall ... done routine
|
||||||
return "$name".$readingsToUpdate;
|
return $name.$readingsToUpdate;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1153,7 +1203,9 @@ GAEBUS_GetUpdatesAborted($)
|
|||||||
define variables that can be retrieved from the ebusd.
|
define variables that can be retrieved from the ebusd.
|
||||||
They will appear when they are defined by a "set" command as described above.<br>
|
They will appear when they are defined by a "set" command as described above.<br>
|
||||||
The value assigned to an attribute specifies the name of the reading for this variable.<br>
|
The value assigned to an attribute specifies the name of the reading for this variable.<br>
|
||||||
The name of the reading can be suffixed by "<number>" which is a multiplicator for
|
If ebusd returns a list of semicolon separated values then several semicolon separated readings can be defined.<br>
|
||||||
|
"dummy" is a placeholder for a reading that will be ignored. (e.g.: temperature;dummy;pressure).<br>
|
||||||
|
The name of the reading can be suffixed by "<:number>" which is a multiplicator for
|
||||||
the evaluation within the specified interval. (eg. OutsideTemp:3 will evaluate this reading every 3-th cycle)<br>
|
the evaluation within the specified interval. (eg. OutsideTemp:3 will evaluate this reading every 3-th cycle)<br>
|
||||||
All text followed the reading seperated by a blank is given as an additional parameter to ebusd.
|
All text followed the reading seperated by a blank is given as an additional parameter to ebusd.
|
||||||
This can be used to request a single value if more than one is retrieved from ebus.<br>
|
This can be used to request a single value if more than one is retrieved from ebus.<br>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user