From 8cd869a4cd1c96268fb3af486cd03b569fc52c7d Mon Sep 17 00:00:00 2001 From: Mark Frasa Date: Fri, 4 Jan 2019 11:27:10 +0000 Subject: [PATCH 1/2] Support for dual-string metrics to influx --- eversolar.pl | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/eversolar.pl b/eversolar.pl index f5d2e17..793e081 100755 --- a/eversolar.pl +++ b/eversolar.pl @@ -945,9 +945,18 @@ sub get_timestamp { my $temp = $data[$DATA_BYTES{'TEMP'}]/10; my $volts = $data[$DATA_BYTES{'VAC'}]/10; my $dc_volt = $data[$DATA_BYTES{'VPV'}]/10, - my $dc_imp = $data[$DATA_BYTES{'IPV'}]/10, + my $dc_imp = $data[$DATA_BYTES{'IPV'}]/10, my $ac_volt = $data[$DATA_BYTES{'VAC'}]/10, my $ac_imp = $data[$DATA_BYTES{'IAC'}]/10, + my $op_hours = $data[$DATA_BYTES{'HOURS_UP'}], + my $frequency = $data[$DATA_BYTES{'FREQUENCY'}]/100; + + # Dual string metrics + if($config->options_strings == 2) { + my $dc_imp2 = $data[$DATA_BYTES{'IPV2'}]/10; + my $dc_volt2 = $data[$DATA_BYTES{'VPV2'}]/10; + } + $combined_power = $combined_power +$data[$DATA_BYTES{'PAC'}]; $combined_daykwh = $combined_daykwh +$data[$DATA_BYTES{'E_TODAY'}]/100; @@ -1120,7 +1129,11 @@ sub get_timestamp { my $influxdb_dbname = $config->influxdb_dbname; my $influxdb_panelname = $config->influxdb_panelname; my $time = time() * 1000000000; - my $cmd = `curl -s -i -XPOST "http://$influxdb_address:$influxdb_port/write?db=$influxdb_dbname" --data-binary "usage,panel=$influxdb_panelname ac_imp=$ac_imp,ac_volts=$ac_volt,dc_imp=$dc_imp,dc_volts=$dc_volt,power=$pac,temp=$temp,total=$e_total,totaltoday=$e_today_kwh $time"`; + if($config->options_strings == 1) { + my $cmd = `curl -s -i -XPOST "http://$influxdb_address:$influxdb_port/write?db=$influxdb_dbname" --data-binary "usage,panel=$influxdb_panelname ac_imp=$ac_imp,ac_volts=$ac_volt,dc_imp=$dc_imp,dc_volts=$dc_volt,power=$pac,temp=$temp,total=$e_total,totaltoday=$e_today_kwh $time"`; + } else { + my $cmd = `curl -s -i -XPOST "http://$influxdb_address:$influxdb_port/write?db=$influxdb_dbname" --data-binary "usage,panel=$influxdb_panelname ac_imp=$ac_imp,ac_volts=$ac_volt,dc_imp=$dc_imp,dc_imp2=$dc_imp2,dc_volts=$dc_volt,dc_volts2=$dc_volt2,power=$pac,temp=$temp,total=$e_total,totaltoday=$e_today_kwh,frequency=$frequency,operating_hours=$op_hours $time"`; + } chomp($cmd); From 94d76f600c83e538b3f424ed43939f8109610b1f Mon Sep 17 00:00:00 2001 From: Mark Frasa Date: Fri, 4 Jan 2019 13:00:31 +0000 Subject: [PATCH 2/2] Unable to check for config options here, it seems --- eversolar.pl | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/eversolar.pl b/eversolar.pl index 793e081..7bde54a 100755 --- a/eversolar.pl +++ b/eversolar.pl @@ -952,11 +952,8 @@ sub get_timestamp { my $frequency = $data[$DATA_BYTES{'FREQUENCY'}]/100; # Dual string metrics - if($config->options_strings == 2) { - my $dc_imp2 = $data[$DATA_BYTES{'IPV2'}]/10; - my $dc_volt2 = $data[$DATA_BYTES{'VPV2'}]/10; - } - + my $dc_imp2 = $data[$DATA_BYTES{'IPV2'}]/10; + my $dc_volt2 = $data[$DATA_BYTES{'VPV2'}]/10; $combined_power = $combined_power +$data[$DATA_BYTES{'PAC'}]; $combined_daykwh = $combined_daykwh +$data[$DATA_BYTES{'E_TODAY'}]/100;