diff --git a/fhem/FHEM/42_SMARTMON.pm b/fhem/FHEM/42_SMARTMON.pm index 17d7a383c..017c78b1f 100644 --- a/fhem/FHEM/42_SMARTMON.pm +++ b/fhem/FHEM/42_SMARTMON.pm @@ -31,7 +31,7 @@ use strict; use warnings; use Data::Dumper; -my $VERSION = "0.9.5"; +my $VERSION = "0.9.7"; my $DEFAULT_INTERVAL = 60; # in minuten @@ -57,7 +57,7 @@ sub SMARTMON_Initialize($) $hash->{GetFn} = "SMARTMON_Get"; #$hash->{SetFn} = "SMARTMON_Set"; $hash->{AttrFn} = "SMARTMON_Attr"; - $hash->{AttrList} = "show_raw:0,1,2 disable:0,1 include parameters ".$readingFnAttributes; + $hash->{AttrList} = "show_raw:0,1,2 disable:0,1 include parameters show_device_info:0,1 ".$readingFnAttributes; } sub SMARTMON_Log($$$) { @@ -213,6 +213,10 @@ sub SMARTMON_Attr($$$) { SMARTMON_refreshReadings($hash); } + if($attrName eq "show_device_info") { + SMARTMON_refreshReadings($hash); + } + #return $attrName ." set to ". $attrVal; return undef; } @@ -224,11 +228,16 @@ sub SMARTMON_Attr($$$) { SMARTMON_refreshReadings($hash); } - if($attrName eq "include") { + if($attrName eq "show_device_info") { delete $attr{$name}{$attrName}; SMARTMON_refreshReadings($hash); } + if($attrName eq "include") { + delete $attr{$name}{$attrName}; + SMARTMON_refreshReadings($hash); + } + if($attrName eq "parameters") { delete $hash->{PARAMETERS}; } @@ -389,22 +398,28 @@ sub SMARTMON_readDeviceData($%) { if($hash->{PARAMETERS}) {$param=" ".$hash->{PARAMETERS};} my ($r, @dev_data) = SMARTMON_execute($hash, "sudo smartctl -i".$param." ".$hash->{DEVICE}); SMARTMON_Log($hash, 5, "device data: ".Dumper(@dev_data)); + my $sd = AttrVal($hash->{NAME}, "show_device_info", "0"); if(defined($dev_data[0])) { while(scalar(@dev_data)>0) { my $line = $dev_data[0]; shift @dev_data; my($k,$v) = split(/:\s*/,$line); + $v = trim($v); if($k eq "Device Model") { $hash->{DEVICE_MODEL}=$v; + $map->{"deviceModel"}=$v if($sd eq '1'); } if($k eq "Serial Number") { $hash->{DEVICE_SERIAL}=$v; + $map->{"deviceSerial"}=$v if($sd eq '1'); } if($k eq "Firmware Version") { $hash->{DEVICE_FIRMWARE}=$v; + $map->{"deviceFirmware"}=$v if($sd eq '1'); } if($k eq "User Capacity") { $hash->{DEVICE_CAPACITY}=$v; + $map->{"deviceCapacity"}=$v if($sd eq '1'); } } } @@ -654,6 +669,10 @@ sub SMARTMON_execute($$) { Valid values: 0: no RAW Readings (default), 1: show all, are not included in interpreted Readings, 2: show all.
+
  • show_device_info
    + Valid values: 0: no device info as reading, 1: show show device info as readings. +
  • +
  • include
    Comma separated list of IDs for desired SMART parameters. If nothing passed, all available values are displayed.
  • @@ -746,6 +765,10 @@ sub SMARTMON_execute($$) { Gültige Werte: 0: keine RAW-Readings anzeigen (default), 1: alle anzeigen, die nicht in interpretierten Readings enthalten sind, 2: alle anzeigen.
    +
  • show_device_info
    + Gültige Werte: 0: keine Geräteinforamtionen in readings, 1: Geräteinformationen in readings anzeigen. +
  • +
  • include
    Kommaseparierte Liste der IDs gewünschten SMART-Parameter. Wenn nichts angegeben, werden alle verfügbaren angezeigt.