2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 09:16:53 +00:00

70_ENIGMA2: convert HDD values to GB

git-svn-id: https://svn.fhem.de/fhem/trunk@14163 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2017-05-02 12:11:14 +00:00
parent 7289108623
commit 050e02fbba

View File

@ -1384,19 +1384,37 @@ sub ENIGMA2_ReceiveCommand($$$) {
my @value =
split( / /,
$return->{e2about}{e2hddinfo}[$i]{capacity} );
readingsBulkUpdate( $hash, $readingname, $value[0] )
if ( @value
&& ReadingsVal( $name, $readingname, "" ) ne
$value[0] );
if (@value) {
if ( $value[0] =~ /^\d+(?:\.\d+)?$/ ) {
$value[0] = round( $value[0] * 1024, 1 )
if ( $value[1] && $value[1] =~ /TB/i );
$value[0] = round( $value[0] / 1024, 1 )
if ( $value[1] && $value[1] =~ /MB/i );
$value[0] =
round( $value[0] / 1024 / 1024, 1 )
if ( $value[1] && $value[1] =~ /KB/i );
}
readingsBulkUpdateIfChanged( $hash,
$readingname, $value[0] );
}
$readingname = "hdd" . $counter . "_free";
@value =
split( / /,
$return->{e2about}{e2hddinfo}[$i]{free} );
readingsBulkUpdate( $hash, $readingname, $value[0] )
if ( @value
&& ReadingsVal( $name, $readingname, "" ) ne
$value[0] );
if (@value) {
if ( $value[0] =~ /^\d+(?:\.\d+)?$/ ) {
$value[0] = round( $value[0] * 1024, 1 )
if ( $value[1] && $value[1] =~ /TB/i );
$value[0] = round( $value[0] / 1024, 1 )
if ( $value[1] && $value[1] =~ /MB/i );
$value[0] =
round( $value[0] / 1024 / 1024, 1 )
if ( $value[1] && $value[1] =~ /KB/i );
}
readingsBulkUpdateIfChanged( $hash,
$readingname, $value[0] );
}
$i++;
}
@ -1413,18 +1431,34 @@ sub ENIGMA2_ReceiveCommand($$$) {
$readingname = "hdd1_capacity";
my @value =
split( / /, $return->{e2about}{e2hddinfo}{capacity} );
readingsBulkUpdate( $hash, $readingname, $value[0] )
if ( @value
&& ReadingsVal( $name, $readingname, "" ) ne
$value[0] );
if (@value) {
if ( $value[0] =~ /^\d+(?:\.\d+)?$/ ) {
$value[0] = round( $value[0] * 1024, 1 )
if ( $value[1] && $value[1] =~ /TB/i );
$value[0] = round( $value[0] / 1024, 1 )
if ( $value[1] && $value[1] =~ /MB/i );
$value[0] = round( $value[0] / 1024 / 1024, 1 )
if ( $value[1] && $value[1] =~ /KB/i );
}
readingsBulkUpdateIfChanged( $hash,
$readingname, $value[0] );
}
$readingname = "hdd1_free";
@value =
split( / /, $return->{e2about}{e2hddinfo}{free} );
readingsBulkUpdate( $hash, $readingname, $value[0] )
if ( @value
&& ReadingsVal( $name, $readingname, "" ) ne
$value[0] );
if (@value) {
if ( $value[0] =~ /^\d+(?:\.\d+)?$/ ) {
$value[0] = round( $value[0] * 1024, 1 )
if ( $value[1] && $value[1] =~ /TB/i );
$value[0] = round( $value[0] / 1024, 1 )
if ( $value[1] && $value[1] =~ /MB/i );
$value[0] = round( $value[0] / 1024 / 1024, 1 )
if ( $value[1] && $value[1] =~ /KB/i );
}
readingsBulkUpdateIfChanged( $hash,
$readingname, $value[0] );
}
}
else {
Log3 $name, 5,