line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Device::WallyHome::Place; |
2
|
1
|
|
|
1
|
|
4
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
3
|
1
|
|
|
1
|
|
5794
|
use MooseX::AttributeShortcuts; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
4
|
1
|
|
|
1
|
|
2704
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
69
|
use List::Util qw(first); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
452
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.21.2'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'Device::WallyHome::Role::Creator'; |
11
|
|
|
|
|
|
|
with 'Device::WallyHome::Role::REST'; |
12
|
|
|
|
|
|
|
with 'Device::WallyHome::Role::Validator'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#== ATTRIBUTES ================================================================= |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has 'id' => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => 'Str', |
20
|
|
|
|
|
|
|
required => 1, |
21
|
|
|
|
|
|
|
writer => '_id', |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has 'accountId' => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
isa => 'Str', |
27
|
|
|
|
|
|
|
required => 1, |
28
|
|
|
|
|
|
|
writer => '_accountId', |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has 'label' => ( |
32
|
|
|
|
|
|
|
is => 'ro', |
33
|
|
|
|
|
|
|
isa => 'Maybe[Str]', |
34
|
|
|
|
|
|
|
required => 1, |
35
|
|
|
|
|
|
|
writer => '_label', |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has 'fullAddress' => ( |
39
|
|
|
|
|
|
|
is => 'ro', |
40
|
|
|
|
|
|
|
isa => 'Maybe[HashRef]', |
41
|
|
|
|
|
|
|
required => 1, |
42
|
|
|
|
|
|
|
writer => '_fullAddress', |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
has 'address' => ( |
46
|
|
|
|
|
|
|
is => 'ro', |
47
|
|
|
|
|
|
|
isa => 'Maybe[Str]', |
48
|
|
|
|
|
|
|
required => 1, |
49
|
|
|
|
|
|
|
writer => '_address', |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
has 'suspended' => ( |
53
|
|
|
|
|
|
|
is => 'ro', |
54
|
|
|
|
|
|
|
isa => 'Int', |
55
|
|
|
|
|
|
|
required => 1, |
56
|
|
|
|
|
|
|
writer => '_suspended', |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
has 'buzzerEnabled' => ( |
60
|
|
|
|
|
|
|
is => 'ro', |
61
|
|
|
|
|
|
|
isa => 'Int', |
62
|
|
|
|
|
|
|
required => 1, |
63
|
|
|
|
|
|
|
writer => '_buzzerEnabled', |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
has 'sensorIds' => ( |
67
|
|
|
|
|
|
|
is => 'ro', |
68
|
|
|
|
|
|
|
isa => 'ArrayRef', |
69
|
|
|
|
|
|
|
required => 1, |
70
|
|
|
|
|
|
|
writer => '_sensorIds', |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
has 'nestAdjustments' => ( |
74
|
|
|
|
|
|
|
is => 'ro', |
75
|
|
|
|
|
|
|
isa => 'HashRef', |
76
|
|
|
|
|
|
|
required => 1, |
77
|
|
|
|
|
|
|
writer => '_nestAdjustments', |
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
has 'nestEnabled' => ( |
81
|
|
|
|
|
|
|
is => 'ro', |
82
|
|
|
|
|
|
|
isa => 'Int', |
83
|
|
|
|
|
|
|
required => 1, |
84
|
|
|
|
|
|
|
writer => '_nestEnabled', |
85
|
|
|
|
|
|
|
); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
has 'rapidResponseSupport' => ( |
88
|
|
|
|
|
|
|
is => 'ro', |
89
|
|
|
|
|
|
|
isa => 'ArrayRef', |
90
|
|
|
|
|
|
|
required => 1, |
91
|
|
|
|
|
|
|
writer => '_rapidResponseSupport', |
92
|
|
|
|
|
|
|
); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
has 'sensors' => ( |
95
|
|
|
|
|
|
|
is => 'lazy', |
96
|
|
|
|
|
|
|
); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
#== ATTRIBUTE BUILDERS ========================================================= |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub _build_sensors { |
102
|
1
|
|
|
1
|
|
2
|
my ($self) = @_; |
103
|
|
|
|
|
|
|
|
104
|
1
|
|
|
|
|
2
|
my $newSensorIds = []; |
105
|
1
|
|
|
|
|
1
|
my $sensorObjectList = []; |
106
|
|
|
|
|
|
|
|
107
|
1
|
|
|
|
|
30
|
my $sensorList = $self->request({ |
108
|
|
|
|
|
|
|
uri => 'places/' . $self->id() . '/sensors' |
109
|
|
|
|
|
|
|
}); |
110
|
|
|
|
|
|
|
|
111
|
1
|
|
|
|
|
4
|
foreach my $sensorData (@$sensorList) { |
112
|
1
|
|
|
|
|
6
|
my $sensor = $self->loadSensorFromApiResponseData($sensorData); |
113
|
|
|
|
|
|
|
|
114
|
1
|
|
|
|
|
3
|
push @$sensorObjectList, $sensor; |
115
|
|
|
|
|
|
|
|
116
|
1
|
|
|
|
|
39
|
push @$newSensorIds, $sensor->snid(); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
1
|
|
|
|
|
36
|
$self->_sensorIds($newSensorIds); |
120
|
|
|
|
|
|
|
|
121
|
1
|
|
|
|
|
43
|
return $sensorObjectList; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
#== PUBLIC METHODS ============================================================= |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub getSensorBySnid { |
128
|
1
|
|
|
1
|
1
|
625
|
my ($self, $snid) = @_; |
129
|
|
|
|
|
|
|
|
130
|
1
|
|
|
|
|
5
|
$self->_checkRequiredScalarParam($snid, 'snid'); |
131
|
|
|
|
|
|
|
|
132
|
1
|
|
|
1
|
|
4
|
return first { $_->snid() eq $snid } @{ $self->sensors() }; |
|
1
|
|
|
|
|
29
|
|
|
1
|
|
|
|
|
43
|
|
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
__END__ |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=pod |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=encoding utf8 |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 NAME |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Device::WallyHome::Place - WallyHome REST API Interface - Place |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 SYNOPSIS |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# A Device::WallyHome::Place will always be instantiated from a base Device::WallyHome object. |
153
|
|
|
|
|
|
|
use Device::WallyHome; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
my $wally = Device::WallyHome->new( |
156
|
|
|
|
|
|
|
token => 'f4379e51-222f-4def-8ee1-edf0b15be3b8', |
157
|
|
|
|
|
|
|
); |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
my $place = $wally->getPlaceById('qyWIClYakQX8TQxtFv1ypN6c'); |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# Get a list (ArrayRef) of all sensors |
162
|
|
|
|
|
|
|
my $sensors = $place->sensors(); |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
# Get a single Device::WallyHome::Sensor object by Sensor ID (snid) |
165
|
|
|
|
|
|
|
my $sensor = $place->getSensorBySnid(); |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 DESCRIPTION |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
B<Device::WallyHome::Place> represents a child class of the L<Device::WallyHome> |
170
|
|
|
|
|
|
|
Perl5 interface for the WallyHome REST API. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Device::WallyHome::Place objects are returned from various methods via |
173
|
|
|
|
|
|
|
a parent L<Device::WallyHome> object and are not intended to be instantiated |
174
|
|
|
|
|
|
|
directly. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head2 Methods |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=over |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item B<sensors> |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
my $sensors = $place->sensors(); |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Returns a list of all sensors associated with the given place. Each |
186
|
|
|
|
|
|
|
sensor returned is a L<Device::WallyHome::Sensor> object. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=item B<getSensorBySnid> |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
my $sensor = $place->getSensorById('90-7a-f1-ff-ff-ff'); |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Returns a single L<Device::WallyHome::Sensor> object matching the passed |
193
|
|
|
|
|
|
|
sensor identifier (snid). If no matching sensor is found, C<undef> will |
194
|
|
|
|
|
|
|
be returned. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=back |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head1 EXAMPLES |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
# Iterate through a list of sensors, printing the identifier and current temperature for each |
202
|
|
|
|
|
|
|
foreach my $sensor (@$sensors) { |
203
|
|
|
|
|
|
|
printf("%s - %0.2f\n", $sensor->snid(), $sensor->state('TEMP')->value()); |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head1 AUTHOR |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Chris Hamilton |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Chris Hamilton. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under the |
217
|
|
|
|
|
|
|
same terms as the Perl 5 programming language system itself. |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head1 BUG REPORTING, ENHANCEMENT/FEATURE REQUESTS |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
Please report bugs or enhancement requests on GitHub directly at |
223
|
|
|
|
|
|
|
L<https://github.com/cjhamil/Device-WallyHome/issues> |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=cut |