added: ctrl attr show_device_info
git-svn-id: https://svn.fhem.de/fhem/trunk@21838 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -31,7 +31,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
my $VERSION = "0.9.5";
|
my $VERSION = "0.9.7";
|
||||||
|
|
||||||
my $DEFAULT_INTERVAL = 60; # in minuten
|
my $DEFAULT_INTERVAL = 60; # in minuten
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ sub SMARTMON_Initialize($)
|
|||||||
$hash->{GetFn} = "SMARTMON_Get";
|
$hash->{GetFn} = "SMARTMON_Get";
|
||||||
#$hash->{SetFn} = "SMARTMON_Set";
|
#$hash->{SetFn} = "SMARTMON_Set";
|
||||||
$hash->{AttrFn} = "SMARTMON_Attr";
|
$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($$$) {
|
sub SMARTMON_Log($$$) {
|
||||||
@@ -213,6 +213,10 @@ sub SMARTMON_Attr($$$) {
|
|||||||
SMARTMON_refreshReadings($hash);
|
SMARTMON_refreshReadings($hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($attrName eq "show_device_info") {
|
||||||
|
SMARTMON_refreshReadings($hash);
|
||||||
|
}
|
||||||
|
|
||||||
#return $attrName ." set to ". $attrVal;
|
#return $attrName ." set to ". $attrVal;
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@@ -224,6 +228,11 @@ sub SMARTMON_Attr($$$) {
|
|||||||
SMARTMON_refreshReadings($hash);
|
SMARTMON_refreshReadings($hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($attrName eq "show_device_info") {
|
||||||
|
delete $attr{$name}{$attrName};
|
||||||
|
SMARTMON_refreshReadings($hash);
|
||||||
|
}
|
||||||
|
|
||||||
if($attrName eq "include") {
|
if($attrName eq "include") {
|
||||||
delete $attr{$name}{$attrName};
|
delete $attr{$name}{$attrName};
|
||||||
SMARTMON_refreshReadings($hash);
|
SMARTMON_refreshReadings($hash);
|
||||||
@@ -389,22 +398,28 @@ sub SMARTMON_readDeviceData($%) {
|
|||||||
if($hash->{PARAMETERS}) {$param=" ".$hash->{PARAMETERS};}
|
if($hash->{PARAMETERS}) {$param=" ".$hash->{PARAMETERS};}
|
||||||
my ($r, @dev_data) = SMARTMON_execute($hash, "sudo smartctl -i".$param." ".$hash->{DEVICE});
|
my ($r, @dev_data) = SMARTMON_execute($hash, "sudo smartctl -i".$param." ".$hash->{DEVICE});
|
||||||
SMARTMON_Log($hash, 5, "device data: ".Dumper(@dev_data));
|
SMARTMON_Log($hash, 5, "device data: ".Dumper(@dev_data));
|
||||||
|
my $sd = AttrVal($hash->{NAME}, "show_device_info", "0");
|
||||||
if(defined($dev_data[0])) {
|
if(defined($dev_data[0])) {
|
||||||
while(scalar(@dev_data)>0) {
|
while(scalar(@dev_data)>0) {
|
||||||
my $line = $dev_data[0];
|
my $line = $dev_data[0];
|
||||||
shift @dev_data;
|
shift @dev_data;
|
||||||
my($k,$v) = split(/:\s*/,$line);
|
my($k,$v) = split(/:\s*/,$line);
|
||||||
|
$v = trim($v);
|
||||||
if($k eq "Device Model") {
|
if($k eq "Device Model") {
|
||||||
$hash->{DEVICE_MODEL}=$v;
|
$hash->{DEVICE_MODEL}=$v;
|
||||||
|
$map->{"deviceModel"}=$v if($sd eq '1');
|
||||||
}
|
}
|
||||||
if($k eq "Serial Number") {
|
if($k eq "Serial Number") {
|
||||||
$hash->{DEVICE_SERIAL}=$v;
|
$hash->{DEVICE_SERIAL}=$v;
|
||||||
|
$map->{"deviceSerial"}=$v if($sd eq '1');
|
||||||
}
|
}
|
||||||
if($k eq "Firmware Version") {
|
if($k eq "Firmware Version") {
|
||||||
$hash->{DEVICE_FIRMWARE}=$v;
|
$hash->{DEVICE_FIRMWARE}=$v;
|
||||||
|
$map->{"deviceFirmware"}=$v if($sd eq '1');
|
||||||
}
|
}
|
||||||
if($k eq "User Capacity") {
|
if($k eq "User Capacity") {
|
||||||
$hash->{DEVICE_CAPACITY}=$v;
|
$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.
|
Valid values: 0: no RAW Readings (default), 1: show all, are not included in interpreted Readings, 2: show all.
|
||||||
</li>
|
</li>
|
||||||
<br>
|
<br>
|
||||||
|
<li>show_device_info<br>
|
||||||
|
Valid values: 0: no device info as reading, 1: show show device info as readings.
|
||||||
|
</li>
|
||||||
|
<br>
|
||||||
<li>include<br>
|
<li>include<br>
|
||||||
Comma separated list of IDs for desired SMART parameters. If nothing passed, all available values are displayed.
|
Comma separated list of IDs for desired SMART parameters. If nothing passed, all available values are displayed.
|
||||||
</li>
|
</li>
|
||||||
@@ -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.
|
Gültige Werte: 0: keine RAW-Readings anzeigen (default), 1: alle anzeigen, die nicht in interpretierten Readings enthalten sind, 2: alle anzeigen.
|
||||||
</li>
|
</li>
|
||||||
<br>
|
<br>
|
||||||
|
<li>show_device_info<br>
|
||||||
|
Gültige Werte: 0: keine Geräteinforamtionen in readings, 1: Geräteinformationen in readings anzeigen.
|
||||||
|
</li>
|
||||||
|
<br>
|
||||||
<li>include<br>
|
<li>include<br>
|
||||||
Kommaseparierte Liste der IDs gewünschten SMART-Parameter. Wenn nichts angegeben, werden alle verfügbaren angezeigt.
|
Kommaseparierte Liste der IDs gewünschten SMART-Parameter. Wenn nichts angegeben, werden alle verfügbaren angezeigt.
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
Reference in New Issue
Block a user