From 98384791451ef71cd51d9743fcdc5f351a50c2bb Mon Sep 17 00:00:00 2001
From: rudolfkoenig <>
Date: Thu, 8 Feb 2024 11:22:13 +0000
Subject: [PATCH] 10_ZWave.pm: better parameter parsing for METER get (Forum
#136912)
git-svn-id: https://svn.fhem.de/fhem/trunk@28490 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/FHEM/10_ZWave.pm | 37 ++++++++++++++++++++++++-------------
1 file changed, 24 insertions(+), 13 deletions(-)
diff --git a/fhem/FHEM/10_ZWave.pm b/fhem/FHEM/10_ZWave.pm
index a327fcb68..064d1d5e0 100644
--- a/fhem/FHEM/10_ZWave.pm
+++ b/fhem/FHEM/10_ZWave.pm
@@ -1925,16 +1925,31 @@ ZWave_meterSet($$)
sub
ZWave_meterGet($)
{
- my ($scale) = @_;
+ my ($scale, $exp) = split(" ", $_[0]);
if ($scale eq "%s") { # no parameter specified, use V1 get without scale
return("", "01");
};
- if($scale < 7) {
- return ("",sprintf('01%02x', $scale << 3));
+ if($scale !~ m/^[0-9]+/) {
+ my $scaleAsInt;
+ foreach my $arr (values %zwm_unit) {
+ for(my $i1=0; $i1<@{$arr}; $i1++) {
+ $scaleAsInt = $i1 if($arr->[$i1] eq $scale);
+ }
+ }
+ return "unknown unit $scale" if(!defined($scaleAsInt));
+ $scale = $scaleAsInt;
+ }
+
+ return "invalid parameter $exp, only import or export is allowed"
+ if($exp && $exp !~ m/^(export|import)$/);
+ $exp = ($exp ? ($exp eq "export" ? 0x80 : 0x40) : 0);
+
+ if($scale < 7) { # V1:no scale, V2:2 bits, V3: 3bits
+ return ("",sprintf('01%02x', ($scale << 3) | $exp));
} else { # Version 4
- return ("",sprintf('01%02x%02x', 7<<3, $scale-8));
+ return ("",sprintf('01%02x%02x', (7<<3) | $exp, $scale-7));
}
}
@@ -7125,18 +7140,14 @@ ZWave_tmSet($)
Class METER
-