From 8f62e3d7ea7811c9f4b97ea168191a451dd9474d Mon Sep 17 00:00:00 2001 From: hexenmeister Date: Tue, 25 Apr 2017 18:08:41 +0000 Subject: [PATCH] SYSMON: fix warnings git-svn-id: https://svn.fhem.de/fhem/trunk@14106 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/42_SYSMON.pm | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/fhem/FHEM/42_SYSMON.pm b/fhem/FHEM/42_SYSMON.pm index dbbadecac..d3201f555 100644 --- a/fhem/FHEM/42_SYSMON.pm +++ b/fhem/FHEM/42_SYSMON.pm @@ -3623,20 +3623,23 @@ sub SYSMON_PowerAcInfo($$) { my $type="ac"; my $base = "cat /sys/class/power_supply/".$type."/"; + + my $d_online_t = SYSMON_execute($hash, $base."online"); + if($d_online_t) { + my $d_online = trim($d_online_t); + my $d_present = trim(SYSMON_execute($hash, $base."present 2>/dev/null")); + my $d_current = SYSMON_execute($hash, $base."current_now 2>/dev/null"); + if(defined $d_current) {$d_current/=1000;} else {return $map;} + my $d_voltage = SYSMON_execute($hash, $base."voltage_now 2>/dev/null"); + if(defined $d_voltage) {$d_voltage/=1000000;} else {return $map;} - my $d_online = trim(SYSMON_execute($hash, $base."online")); - my $d_present = trim(SYSMON_execute($hash, $base."present 2>/dev/null")); - my $d_current = SYSMON_execute($hash, $base."current_now 2>/dev/null"); - if(defined $d_current) {$d_current/=1000;} else {return $map;} - my $d_voltage = SYSMON_execute($hash, $base."voltage_now 2>/dev/null"); - if(defined $d_voltage) {$d_voltage/=1000000;} else {return $map;} - - #$map->{"power_".$type."_online"}=$d_online; - #$map->{"power_".$type."_present"}=$d_present; - #$map->{"power_".$type."_current"}=$d_current; - #$map->{"power_".$type."_voltage"}=$d_voltage; - $map->{"power_".$type."_stat"}="$d_online $d_present $d_voltage $d_current"; - $map->{"power_".$type."_text"}=$type.": ".(($d_present eq "1") ? "present" : "absent")." / ".($d_online eq "1" ? "online" : "offline").", voltage: ".$d_voltage." V, current: ".$d_current." mA, ".(int(($d_voltage*$d_current/100+0.5))/10)." W"; + #$map->{"power_".$type."_online"}=$d_online; + #$map->{"power_".$type."_present"}=$d_present; + #$map->{"power_".$type."_current"}=$d_current; + #$map->{"power_".$type."_voltage"}=$d_voltage; + $map->{"power_".$type."_stat"}="$d_online $d_present $d_voltage $d_current"; + $map->{"power_".$type."_text"}=$type.": ".(($d_present eq "1") ? "present" : "absent")." / ".($d_online eq "1" ? "online" : "offline").", voltage: ".$d_voltage." V, current: ".$d_current." mA, ".(int(($d_voltage*$d_current/100+0.5))/10)." W"; + } return $map; }