NAME

Device::CurrentCost::Message - Perl modules for Current Cost energy monitor messages

VERSION

version 1.110792

SYNOPSIS

use Device::CurrentCost::Message;
my $msg = Device::CurrentCost::Message->new(message => '<msg>...</msg>');
print 'Device: ', $msg->device, ' ', $msg->device_version, "\n";
if ($msg->has_readings) {
  print 'Sensor: ', $msg->sensor, '.', $msg->id, ' (', $msg->type, ")\n";
  print 'Total: ', $msg->value, ' ', $msg->units, "\n";
  foreach my $phase (1..3) {
    print 'Phase ', $phase, ': ',
      $msg->value($phase)+0, " ", $msg->units, "\n";
  }
}

use Data::Dumper;
print Data::Dumper->Dump([$msg->history]) if ($msg->has_history);

# or
print $msg->summary, "\n";

DESCRIPTION

METHODS

new(%parameters)

This constructor returns a new Current Cost message object. The supported parameters are:

message

The message data. Usually a string like '<msg>...</msg>'. This parameter is required.

device_type()

Returns the type of the device that created the message.

device()

Returns the name of the device that created the message.

device_version()

Returns the version of the device that created the message.

message()

Returns the raw data of the message.

dsb()

Returns the days since boot field of the message.

days_since_boot()

Returns the days since boot field of the message.

time()

Returns the time field of the message in HH:MM:SS format.

time_in_seconds()

Returns the time field of the message in seconds.

boot_time()

Returns the time since boot reported by the message in seconds.

sensor()

Returns the sensor number field of the message. A classic monitor supports only one sensor so 0 is returned.

id()

Returns the id field of the message.

type()

Returns the sensor type field of the message.

tmpr()

Returns the tmpr/temperature field of the message.

temperature()

Returns the temperature field of the message.

has_history()

Returns true if the message contains history data.

has_readings()

Returns true if the message contains current data.

units()

Returns the units of the current data readings in the message.

value( [$channel] )

Returns the value of the current data reading for the given channel (phase) in the message. If no channel is given then the total of all the current data readings for all channels is returned.

summary( [$prefix] )

Returns the string summary of the data in the message. Each line of the string is prefixed by the given prefix or the empty string if the prefix is not supplied.

history()

Returns a data structure contain any history data from the message.

AUTHOR

Mark Hindess <soft-cpan@temporalanomaly.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Mark Hindess.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.