add remaining time enexus

This commit is contained in:
garnier-quentin 2020-04-29 15:02:12 +02:00
parent cadba7de3b
commit ba1e4a4873
1 changed files with 11 additions and 2 deletions

View File

@ -208,6 +208,7 @@ my $mapping = {
batteryRemainingCapacityValue => { oid => '.1.3.6.1.4.1.12148.10.10.9.5' }, # ah or % batteryRemainingCapacityValue => { oid => '.1.3.6.1.4.1.12148.10.10.9.5' }, # ah or %
batteryRemainingCapacityMinorLowLevel => { oid => '.1.3.6.1.4.1.12148.10.10.9.6' }, batteryRemainingCapacityMinorLowLevel => { oid => '.1.3.6.1.4.1.12148.10.10.9.6' },
batteryRemainingCapacityMajorLowLevel => { oid => '.1.3.6.1.4.1.12148.10.10.9.7' }, batteryRemainingCapacityMajorLowLevel => { oid => '.1.3.6.1.4.1.12148.10.10.9.7' },
loadCurrentValue => { oid => '.1.3.6.1.4.1.12148.10.9.2.5' }, # A or dA
}; };
sub threshold_eltek_configured { sub threshold_eltek_configured {
@ -246,9 +247,17 @@ sub manage_selection {
charge_remaining_unit => $result->{powerSystemCapacityScale} charge_remaining_unit => $result->{powerSystemCapacityScale}
}; };
# we can calculate the time remaining if unit is ah (amperehour) and current battery is discharging (negative value) # we can calculate the time remaining if unit is ah (amperehour) and current battery is discharging (negative value)
if ($result->{powerSystemCapacityScale} eq 'ah' && $result->{batteryCurrentsValue} < 0) { my $current;
if ($result->{batteryCurrentsValue} < 0) {
$current = $result->{batteryCurrentsValue} * -1
} elsif ($result->{loadCurrentValue} > 0) {
$current = $result->{loadCurrentValue};
}
if ($result->{powerSystemCapacityScale} eq 'ah' && defined($current)) {
$self->{battery}->{charge_remaining_time} = $self->{battery}->{charge_remaining_time} =
int($result->{batteryRemainingCapacityValue} * 3600 / $result->{batteryCurrentsValue} * $scale_current * -1); int($result->{batteryRemainingCapacityValue} * 3600 / $current * $scale_current);
} }
$self->threshold_eltek_configured( $self->threshold_eltek_configured(