NAME
Device::WallyHome - WallyHome Device/Sensor REST API Interface
SYNOPSIS
use Device::WallyHome;
# Instantiate a new Device::WallyHome object, replace Token with actual Security Token
my $wally = Device::WallyHome->new(
token => 'f4379e51-222f-4def-8ee1-edf0b15be3b8',
);
# Retrieve a list (ArrayRef) of all Places associated with your account
my $places = $wally->places();
# Load a new Place via its unique identifier
my $place = $wally->getPlaceById('qyWIClYakQX8TQxtFv1ypN6c');
# Load a new Place via its friendly label
my $home = $wally->getPlaceByLabel('Home');
# Retrieve a list (ArrayRef) of all Sensors associated with a Place
my $sensors = $home->sensors();
DESCRIPTION
Device::WallyHome is the Perl5 interface into the WallyHome REST API.
WallyHome is a home sensing solution that detects and alerts you of water leaks, changes in temperature and humidity, as well as when doors and windows open. The WallyHome REST API provides an interface into the places and sensors associated with a WallyHome account.
Device::WallyHome provides an object oriented interface wrapped around the WallyHome REST API, designed to simplify integration for any associated scripting needs.
The only information to get started with Device::WallyHome is the Security Token that can be generated from the Account Settings page within your WallyHome account.
Constructor
- new
-
use Device::WallyHome; my $wally = Device::WallyHome->new( token => 'f4379e51-222f-4def-8ee1-edf0b15be3b8', );
- token
-
The Security Token for your WallyHome account can be found or generated from within the Account Settings page. This security token is all that is needed to successfully connect to the WallyHome REST API.
Methods
- places
-
my $places = $wally->places();
Returns a list of all places assoiated with the given WallyHome account. Each place will be returned as a Device::WallyHome::Place object. If no places are found, an empty list will be returned.
- getPlaceById
-
my $place = $device->getPlaceById('qyWIClYakQX8TQxtFv1ypN6c');
Returns a single Device::WallyHome::Place object matching the passed place identifier. If no matching place is found,
undef
will be returned. - getPlaceByLabel
-
my $home = $device->getPlaceByLabel('Home');
Returns a single Device::WallyHome::Place object matching the passed place label. If no matching place is found,
undef
will be returned.
EXAMPLES
Basic Examples
# Iterate through a list of Places, printing the identifier and label for each, typically only a single Place
foreach my $place (@$places) {
printf("%s - %s\n", $place->id(), $place->label());
}
# Iterate through a list of Sensors, printing the identivier (snid) and label for each
foreach my $sensor (@$sensors) {
printf("%s - %s\n", $sensor->snid(), $sensor->location()->room());
}
Checking Sensor Data
# Determine if Relative Humidity is within specified thresholds
my $state = $sensor->state('RH');
my $threshold = $sensor->threshold('RH');
my $currentValue = $state->value();
my $min = $threshold->min() // 0;
my $max = $threshold->max() // 999;
if ($currentValue < $min || $currentValue > $max) {
print "Danger, Will Robinson!\n";
}
AUTHOR
Chris Hamilton
COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Chris Hamilton.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
BUG REPORTING, ENHANCEMENT/FEATURE REQUESTS
Please report bugs or enhancement requests on GitHub directly at https://github.com/cjhamil/Device-WallyHome/issues