Skip to content

Commit

Permalink
A more robust method to test if RRD modules are installed
Browse files Browse the repository at this point in the history
  • Loading branch information
hplato committed Sep 18, 2022
1 parent 4cd71cf commit a76170c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/Tasmota_HTTP_Item.pm
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,18 @@ sub new {

$self->{RRD} = 0;
$self->{RRD} = 1 if ( $options =~ m/rrd/i );

eval {
require RRD::Simple;
require RRDs;
};
if ($@) {
&main::print_log("[Tasmota_HTTP::Switch_PowerMon] Warning, RRD specified but RRD::Simple and/or RRDs are not found. Disabling RRD functionality");
$self->{RRD} = 0;
}

if ($self->{RRD}) {
use RRD::Simple;
use RRDs;

mkdir($$::config_parms{data_dir} . "/rrd") unless (-d $::config_parms{data_dir} . "/rrd");
$self->set_rrd($::config_parms{data_dir} . "/rrd/" . $self->{address} . ".rrd","power,current");
unless ( -e $self->get_rrd()) {
Expand Down

0 comments on commit a76170c

Please sign in to comment.