TPLink/SmartHome.pm

filter: Statementstmt 74.3% 29 / 39 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 44.4% 4 / 9 Podpod 80.0% 4 / 5 totaltotal 69.8% 37 / 53 CC 1 SCAR 4.4
CC
1
Cov
74%
on
2.0
off
2.0
getSystemInfo
2.0
CRAP 1.6
« TPLink/Kasa.pm ↑ Summary TPLink/SmartHome/Kasa.pm »
1 package Device::TPLink::SmartHome;
2  
3 1 ▶use 5.008003;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 Device::TPLink::SmartHome - Base class for TPLink Smart Home devices
11  
12 =head1 VERSION
13  
14 Version 0.02
15  
16 =cut
17  
18 1 our $VERSION = '0.02';
19  
20 1 has 'fwVer' => ( #"1.1.0 Build 160521 Rel.085826"
21 is => 'rw',
22 isa => 'Str',
23 );
24  
25 1 has 'deviceName' => ( #"Wi-Fi Smart Light Switch"
26 is => 'rw',
27 isa => 'Str',
28 );
29  
30 1 has 'status' => ( #1
31 is => 'rw',
32 isa => 'Bool',
33 );
34  
35 1 has 'alias' => ( #"Downstairs Hall Light"
36 is => 'rw',
37 isa => 'Str',
38 );
39  
40 1 has 'deviceType' => ( #"IOT.SMARTPLUGSWITCH"
41 is => 'rw',
42 isa => 'Str',
43 );
44  
45 1 has 'appServerUrl' => ( #"https://use1-wap.tplinkcloud.com"
46 is => 'rw',
47 isa => 'Str',
48 );
49  
50 1 has 'deviceModel' => ( #"HS200(US)"
51 is => 'rw',
52 isa => 'Str',
53 );
54  
55 1 has 'deviceMac' => ( #"50C7BFDAA810"
56 is => 'rw',
57 isa => 'Str',
58 );
59  
60 1 has 'role' => ( #0
61 is => 'rw',
62 isa => 'Int',
63 );
64  
65 1 has 'isSameRegion' => ( #true
66 is => 'rw',
67 # isa => 'Str',
68 );
69  
70 1 has 'hwId' => ( #"A0E3CC8F5C1166B27A16D56BE262A6D3"
71 is => 'rw',
72 isa => 'Str',
73 );
74  
75 1 has 'fwId' => ( #"DB4F3246CD85AA59CAE738A63E7B9C34"
76 is => 'rw',
77 isa => 'Str',
78 );
79  
80 1 has 'oemId' => ( #"4AFE44A41F868FD2340E6D1308D8551D"
81 is => 'rw',
82 isa => 'Str',
83 );
84  
85 1 has 'deviceId' => ( #"80067C57DCE0C1677948ADA728421F6418BFC029"
86 is => 'rw',
87 isa => 'Str',
88 );
89  
90 1 has 'deviceHwVer' => ( #"1.0"
91 is => 'rw',
92 isa => 'Str',
93 );
94  
95  
96 =head1 SYNOPSIS
97  
98 You're probably in the wrong place. This module is extended by Device::TPLink::SmartHome::Kasa and Device::TPLink::SmartHome::Direct to communicate with smart home devices and issue commands.
99  
100 =head1 SUBROUTINES/METHODS
101  
102 =head2 on
103  
104 Turns the device on.
105  
106 =cut
107  
108 0 ▶sub on { # Turn on or off the light...
Subroutine on: not called CC=1 SCAR=6.9
Pod documented
109 0 my $requestData = { system => { set_relay_state => { state => 1 }}};
110 0 return $requestData;
111 }
112  
113 =head2 off
114  
115 Turns the device off.
116 =cut
117  
118 0 ▶sub off {
Subroutine off: not called CC=1 SCAR=6.9
Pod documented
119 0 my $requestData = { system => { set_relay_state => { state => 0 }}};
120 0 return $requestData;
121 }
122  
123 =head2 getSystemInfo
124  
125 Returns an object containing information about the current state of the device. TODO: Use returned info to populate device object.
126 =cut
127  
128 0 ▶sub getSystemInfo {# Get relay state?
Subroutine getSystemInfo: not called CC=1 SCAR=6.9
Pod documented
129 0 my $requestData = { system => { get_sysinfo => {}}};
130 0 return $requestData;
131 }
132  
133 =head2 reboot
134  
135 Reboots the device with a 1 second delay.
136  
137 =cut
138  
139 0 ▶sub reboot {
Subroutine reboot: not called CC=1 SCAR=6.9
Pod documented
140 0 my $requestData = { system => { reboot => { delay => 1 }}};
141 0 return $requestData;
142 }
143  
144 0 ▶sub TO_JSON { return { %{ shift() } }; }
Subroutine TO_JSON: not called CC=1 SCAR=6.9
Pod undocumented
145  
146  
147  
148 =head1 AUTHOR
149  
150 Verlin Henderson, C<< <verlin at gmail.com> >>
151  
152 =head1 BUGS / SUPPORT
153  
154 To report any bugs or feature requests, please use the github issue tracker: L<https://github.com/verlin/Device-TPLink/issues>
155  
156 =head1 ACKNOWLEDGEMENTS
157  
158  
159 =head1 LICENSE AND COPYRIGHT
160  
161 Copyright 2018 Verlin Henderson.
162  
163 This program is free software; you can redistribute it and/or modify it
164 under the terms of the the Artistic License (2.0). You may obtain a
165 copy of the full license at:
166  
167 L<http://www.perlfoundation.org/artistic_license_2_0>
168  
169 Any use, modification, and distribution of the Standard or Modified
170 Versions is governed by this Artistic License. By using, modifying or
171 distributing the Package, you accept this license. Do not use, modify,
172 or distribute the Package, if you do not accept this license.
173  
174 If your Modified Version has been derived from a Modified Version made
175 by someone other than you, you are nevertheless required to ensure that
176 your Modified Version complies with the requirements of this license.
177  
178 This license does not grant you the right to use any trademark, service
179 mark, tradename, or logo of the Copyright Holder.
180  
181 This license includes the non-exclusive, worldwide, free-of-charge
182 patent license to make, have made, use, offer to sell, sell, import and
183 otherwise transfer the Package with respect to any patent claims
184 licensable by the Copyright Holder that are necessarily infringed by the
185 Package. If you institute patent litigation (including a cross-claim or
186 counterclaim) against any party alleging that the Package constitutes
187 direct or contributory patent infringement, then this Artistic License
188 to you shall terminate on the date that such litigation is filed.
189  
190 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
191 AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
192 THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
193 PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
194 YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
195 CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
196 CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
197 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
198  
199  
200 =cut
201  
202 1 __PACKAGE__->meta->make_immutable;
203  
204 1 1; # End of Device::TPLink::SmartHome
« TPLink/Kasa.pm ↑ Summary TPLink/SmartHome/Kasa.pm »