NAME

Device::Neurio - Methods for wrapping the Neurio API calls so that they are accessible via Perl

VERSION

Version 0.11

SYNOPSIS

This module provides a Perl interface to a Neurio sensor via the following 
methods:
  - new
  - connect
  - fetch_Last_Live
  - fetch_Recent_Live
  - fetch_Samples
  - fetch_Full_samples
  - fetch_Energy_Stats

Please note that in order to use this module you will require three parameters
(key, secret, sensor_id) as well as an Energy Aware Neurio sensor installed in
your house.

The module is written entirely in Perl and has been developped on Raspbian Linux.

All date/time values are specified using ISO8601 format (yyyy-mm-ddThh:mm:ssZ)

SAMPLE CODE

  use Device::Neurio;

  $my_Neurio = Device::Neurio->new($key,$secret,$sensor_id,$debug);

  $my_Neurio->connect();

  $data = $my_Neurio->fetch_Last_Live();
  print $data->{'consumptionPower'}

  $data = $my_Neurio->fetch_Recent_Live("2014-06-18T19:20:21Z");
  print $data->[0]->{'consumptionPower'}

  undef $my_Neurio;

EXPORT

All by default.

SUBROUTINES/METHODS

new - the constructor for a Neurio object

Creates a new instance which will be able to fetch data from a unique Neurio 
sensor.

my $Neurio = Device::Neurio->new($key, $secret, $sensor_id, $debug);

  This method accepts the following parameters:
    - $key       : unique key for the account - Required 
    - $secret    : secret key for the account - Required 
    - $sensor_id : sensor ID connected to the account - Required 
    - $debug     : enable or disable debug messages (disabled by default - Optional)

Returns a Neurio object if successful.
Returns 0 on failure

connect - open a secure connection to the Neurio server

Opens a secure connection via HTTPS to the Neurio server which provides
access to a set of API commands to access the sensor data.

  $Neurio->connect();

This method accepts no parameters

Returns 1 on success 
Returns 0 on failure

fetch_Recent_Live - Fetch recent sensor samples

Retrieves recent sensor readings from the Neurio server.
The values represent the sum of all phases.

  $Neurio->fetch_Recent_Live($last);

  This method accepts the following parameters:
     $last - time of last sample received (yyyy-mm-ddThh:mm:ssZ) - Optional
             specified using ISO8601 format
     
     If no value is specified for $last, a default of 2 minutes is used.

Returns an array of Perl data structures on success
$VAR1 = [
         {
           'generationEnergy' => 3716166644,
           'timestamp' => '2014-06-24T11:08:00.000Z',
           'consumptionEnergy' => 6762651207,
           'generationPower' => 564,
           'consumptionPower' => 821
         },
         ...
        ]
Returns 0 on failure

fetch_Last_Live - Fetch the last live sensor sample

Retrieves the last live sensor reading from the Neurio server.  
The values represent the sum of all phases.

  $Neurio->fetch_Last_Live();

  This method accepts no parameters

Returns a Perl data structure on success:
$VAR1 = {
         'generationEnergy' => 3716027450,
         'timestamp' => '2014-06-24T11:03:43.000Z',
         'consumptionEnergy' => 6762445671,
         'generationPower' => 542,
         'consumptionPower' => 800
       };
Returns 0 on failure

fetch_Samples - Fetch sensor samples from the Neurio server

Retrieves sensor readings within the parameters specified.
The values represent the sum of all phases.

$Neurio->fetch_Samples($start,$granularity,$end,$frequency,$perPage,$page);

  This method accepts the following parameters:
    - start       : yyyy-mm-ddThh:mm:ssZ - Required
                    specified using ISO8601 format
    - granularity : seconds|minutes|hours|days - Required
    - end         : yyyy-mm-ddThh:mm:ssZ - Optional
                    specified using ISO8601 format
    - frequency   : if the granularity is specified as 'minutes', then the 
                    frequency must be a multiple of 5 - Optional
    - perPage     : number of results per page - Optional
    - page        : page number to return - Optional

Returns an array of Perl data structures on success
    $VAR1 = [
             {
               'generationEnergy' => 3568948578,
               'timestamp' => '2014-06-21T19:00:00.000Z',
               'consumptionEnergy' => 6487889194,
               'generationPower' => 98,
               'consumptionPower' => 240
             },
            ...
            ]
Returns 0 on failure

fetch_Full_Samples - Fetches full samples for all phases

Retrieves full sensor readings including data for each individual phase within 
the parameters specified.

$Neurio->fetch_Full_Samples($start,$granularity,$end,$frequency,$perPage,$page);

  This method accepts the following parameters:
    - start       : yyyy-mm-ddThh:mm:ssZ - Required
                    specified using ISO8601 format
    - granularity : seconds|minutes|hours|days - Required
    - end         : yyyy-mm-ddThh:mm:ssZ - Optional
                    specified using ISO8601 format
    - frequency   : an integer - Optional
    - perPage     : number of results per page - Optional
    - page        : page number to return - Optional

Returns an array of Perl data structures on success
$VAR1 = [
         {
           'timestamp' => '2014-06-16T19:20:21.000Z',
           'channelSamples' => [
                                 {
                                   'voltage' => '123.19',
                                   'power' => 129,
                                   'name' => '1',
                                   'energyExported' => 27,
                                   'channelType' => 'phase_a',
                                   'energyImported' => 2682910899,
                                   'reactivePower' => 41
                                 },
                                 {
                                   'voltage' => '123.94',
                                   'power' => 199,
                                   'name' => '2',
                                   'energyExported' => 6,
                                   'channelType' => 'phase_b',
                                   'energyImported' => 3296564362,
                                   'reactivePower' => -45
                                 },
                                 {
                                   'voltage' => '123.57',
                                   'power' => 327,
                                   'name' => '3',
                                   'energyExported' => 10,
                                   'channelType' => 'consumption',
                                   'energyImported' => 5979475235,
                                   'reactivePower' => -4
                                 }
                               ]
         },
         ...
        ]
Returns 0 on failure

fetch_Energy_Stats - Fetches energy statistics

Retrieves energy statistics within the parameters specified.
The values represent the sum of all phases.

  $Neurio->fetch_Energy_Stats($start,$granularity,$end,$frequency,$perPage,$page);

  This method accepts the following parameters:
    - start       : yyyy-mm-ddThh:mm:ssZ - Required
                    specified using ISO8601 format
    - granularity : minutes|hours|days|months - Required
    - end         : yyyy-mm-ddThh:mm:ssZ - Optional
                    specified using ISO8601 format
    - frequency   : if the granularity is specified as 'minutes', then the 
                    frequency must be a multiple of 5 - Optional
    - perPage     : number of results per page - Optional
    - page        : page number to return - Optional

Returns a Perl data structure containing all the raw data
Returns 0 on failure

dump_Object - shows the contents of the local Neurio object

shows the contents of the local Neurio object in human readable form

  $Neurio->dump_Object();

  This method accepts no parameters

Returns nothing

AUTHOR

Kedar Warriner, kedar at cpan.org

BUGS

Please report any bugs or feature requests to C<bug-device-Neurio at rt.cpan.org>
or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Device-Neurio
I will be notified, and then you'll automatically be notified of progress on 
your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

 perldoc Device::Neurio

You can also look for information at:

ACKNOWLEDGEMENTS

Many thanks to:
 The guys at Energy Aware Technologies for creating the Neurio sensor and 
     developping the API.
 Everyone involved with CPAN.

LICENSE AND COPYRIGHT

Copyright 2014 Kedar Warriner <kedar at cpan.org>.

This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.