From 881e76524dad17df16ad0381f3e426d59f719668 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Tue, 7 Dec 2021 16:29:12 +0000 Subject: [PATCH] ZWave.pm: METER class: change undef to UNKNOWN_X (Forum #124642) git-svn-id: https://svn.fhem.de/fhem/trunk@25317 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/10_ZWave.pm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/fhem/FHEM/10_ZWave.pm b/fhem/FHEM/10_ZWave.pm index 2debd2b2f..4e48fa6aa 100644 --- a/fhem/FHEM/10_ZWave.pm +++ b/fhem/FHEM/10_ZWave.pm @@ -1817,7 +1817,14 @@ my %zwm_unit = ( heating => ["kWh" ], cooling => ["kWh" ] ); -my @meter_type_text = ("undef", "energy", "gas", "water", "heating", "cooling"); +my @meter_type_text = ( + "UNKNOWN_0", + "energy", + "gas", + "water", + "heating", + "cooling" +); sub ZWave_meterParse($$) @@ -1836,7 +1843,7 @@ ZWave_meterParse($$) my $meter_type = ($v1 & 0x1f); my $meter_type_text = ($meter_type > $#meter_type_text ? - "undef" : $meter_type_text[$meter_type]); + "UNKNOWN_${meter_type}" : $meter_type_text[$meter_type]); my $precision = ($v2>>5) & 0x7; # 3 bits my $scale = ($v2>>3) & 0x3; # 2 bits, meaning unit @@ -1845,8 +1852,8 @@ ZWave_meterParse($$) $scale |= (($v1 & 0x80) >> 5); $scale = 8+hex(substr($v3, -2)) if($scale == 7); # V4 - my $unit_text = ($meter_type_text eq "undef" ? - "undef" : $zwm_unit{$meter_type_text}[$scale]); + my $unit_text = ($meter_type_text =~ m/^UNKNOWN/ ? + "UNKNOWN" : $zwm_unit{$meter_type_text}[$scale]); $meter_type_text = "power" if ($unit_text eq "W"); $meter_type_text = "voltage" if ($unit_text eq "V"); $meter_type_text = "current" if ($unit_text eq "A");