HiPi
Perl Modules for Raspberry Pi
Version 0.68 - released 29 November 2017

HiPi::Energenie::Command

The hipi_energenie command uses this module internally. You can call the same method directly in your own code.

Pass the elements of any hipi-energenie command as an array to the method "handle_command_arguments".

Note that your setup must be configured first using the normal hipi-energenie commands.

# to replicate a command line call to
# hipi-energenie adapter -n "New Adapter" --off

use HiPi::Energenie::Command;
use JSON;

my $handler = HiPi::Energenie::Command->new;

my $json = $handler->handle_command_arguments( 'adapter', '-n', 'New Adapter', '--off', '--json' );
my $ref = decode_json( $json );

if($ref->{success}) {
    .... good
} else {
    .... bad
}