line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
307829
|
use 5.014; |
|
3
|
|
|
|
|
40
|
|
2
|
3
|
|
|
3
|
|
1939
|
use utf8; |
|
3
|
|
|
|
|
46
|
|
|
3
|
|
|
|
|
18
|
|
3
|
3
|
|
|
3
|
|
99
|
use warnings; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
199
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Device::Inverter::KOSTAL::PIKO::Status; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
1491
|
use Mouse; |
|
3
|
|
|
|
|
87331
|
|
|
3
|
|
|
|
|
13
|
|
10
|
3
|
|
|
3
|
|
1280
|
use Mouse::Util::TypeConstraints; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
12
|
|
11
|
3
|
|
|
3
|
|
1888
|
use namespace::clean -except => 'meta'; |
|
3
|
|
|
|
|
49410
|
|
|
3
|
|
|
|
|
22
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _declare_attr { |
14
|
48
|
|
|
48
|
|
6609
|
my ( $name, $type ) = @_; |
15
|
48
|
|
|
|
|
122
|
has $_, coerce => 1, is => 'ro', required => 1, isa => $type; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
for (qw(Int Num)) { |
19
|
|
|
|
|
|
|
subtype "Maybe_$_" => as "Maybe[$_]"; |
20
|
|
|
|
|
|
|
coerce "Maybe_$_" => from Str => via { |
21
|
|
|
|
|
|
|
if ( $_ eq 'x x x ' ) { undef } |
22
|
|
|
|
|
|
|
else { $_ } |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
_declare_attr $_, 'Str' for qw(html status); |
27
|
|
|
|
|
|
|
_declare_attr $_, 'Maybe_Int' |
28
|
|
|
|
|
|
|
for qw(ac_power_current total_energy), |
29
|
|
|
|
|
|
|
map( ( "power_l$_", "voltage_l$_" ), 1 .. 3 ), |
30
|
|
|
|
|
|
|
map "voltage_string_$_", 1, 2; |
31
|
|
|
|
|
|
|
_declare_attr $_, 'Maybe_Num' |
32
|
|
|
|
|
|
|
for qw(ac_power_current daily_energy), |
33
|
|
|
|
|
|
|
map "current_string_$_", 1, 2; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
around BUILDARGS => sub { |
36
|
|
|
|
|
|
|
my $orig = shift; |
37
|
|
|
|
|
|
|
my $class = shift; |
38
|
|
|
|
|
|
|
my %args = @_ == 1 && !ref $_[0] ? ( html => @_ ) : @_; |
39
|
|
|
|
|
|
|
( my $html = $args{html} ) =~ y/\cM//d; |
40
|
|
|
|
|
|
|
state $RE_Int = qr/\d+|x x x /; |
41
|
|
|
|
|
|
|
state $RE_Num = qr/\d+\.\d\d|x x x /; |
42
|
|
|
|
|
|
|
$html =~ m{ |
43
|
|
|
|
|
|
|
<table cellspacing="0" cellpadding="0" width="770"> |
44
|
|
|
|
|
|
|
<tr><td></td></tr> |
45
|
|
|
|
|
|
|
<tr> |
46
|
|
|
|
|
|
|
<td width="190"></td> |
47
|
|
|
|
|
|
|
<td colspan="2"> |
48
|
|
|
|
|
|
|
<b>AC(?: power|-Leistung)</b></td> |
49
|
|
|
|
|
|
|
<td> </td> |
50
|
|
|
|
|
|
|
<td> |
51
|
|
|
|
|
|
|
<b>(?:energy|Energie)</b></td></tr> |
52
|
|
|
|
|
|
|
<tr><td height="10"></td></tr> |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
<tr> |
55
|
|
|
|
|
|
|
<td width="190"></td> |
56
|
|
|
|
|
|
|
<td width="100"> |
57
|
|
|
|
|
|
|
(?:aktuell|current)</td> |
58
|
|
|
|
|
|
|
<td width="70" align="right" bgcolor="#FFFFFF"> |
59
|
|
|
|
|
|
|
(?<ac_power_current>$RE_Int)</td> |
60
|
|
|
|
|
|
|
<td width="140">  W</td> |
61
|
|
|
|
|
|
|
<td width="100"> |
62
|
|
|
|
|
|
|
(?:total energy|Gesamtenergie)</td> |
63
|
|
|
|
|
|
|
<td width="70" align="right" bgcolor="#FFFFFF"> |
64
|
|
|
|
|
|
|
(?<total_energy>$RE_Int)</td> |
65
|
|
|
|
|
|
|
<td width="50">  kWh</td> |
66
|
|
|
|
|
|
|
<td> </td></tr> |
67
|
|
|
|
|
|
|
<tr height="2"><td></td></tr> |
68
|
|
|
|
|
|
|
<tr> |
69
|
|
|
|
|
|
|
<td width="190"></td> |
70
|
|
|
|
|
|
|
<td width="100"> |
71
|
|
|
|
|
|
|
 </td> |
72
|
|
|
|
|
|
|
<td width="70" align="right"> |
73
|
|
|
|
|
|
|
 </td> |
74
|
|
|
|
|
|
|
<td width="140"> </td> |
75
|
|
|
|
|
|
|
<td width="100"> |
76
|
|
|
|
|
|
|
(?:daily energy|Tagesenergie)</td> |
77
|
|
|
|
|
|
|
<td width="70" align="right" bgcolor="#FFFFFF"> |
78
|
|
|
|
|
|
|
(?<daily_energy>$RE_Num)</td> |
79
|
|
|
|
|
|
|
<td width="50">  kWh</td> |
80
|
|
|
|
|
|
|
<td> </td></tr> |
81
|
|
|
|
|
|
|
<tr height="5"><td></td></tr> |
82
|
|
|
|
|
|
|
<tr> |
83
|
|
|
|
|
|
|
<td width="190"></td> |
84
|
|
|
|
|
|
|
<td width="100"> |
85
|
|
|
|
|
|
|
(?:status|Status)</td> |
86
|
|
|
|
|
|
|
<td colspan="4"> |
87
|
|
|
|
|
|
|
(?<status>[\w ]+)</td> |
88
|
|
|
|
|
|
|
<td> </td></tr> |
89
|
|
|
|
|
|
|
<tr height="8"><td></td></tr> |
90
|
|
|
|
|
|
|
<tr><td colspan="7"> |
91
|
|
|
|
|
|
|
<table align="top" width="100%"><tr> |
92
|
|
|
|
|
|
|
<td width="182"></td> |
93
|
|
|
|
|
|
|
<td><hr size="1"></font></td></tr> |
94
|
|
|
|
|
|
|
<tr><td height="5"></td></tr></table> |
95
|
|
|
|
|
|
|
</td></tr> |
96
|
|
|
|
|
|
|
<tr> |
97
|
|
|
|
|
|
|
<td width="190"></td> |
98
|
|
|
|
|
|
|
<td colspan="2"> |
99
|
|
|
|
|
|
|
<b>PV(?: generator|-Generator)</b></td> |
100
|
|
|
|
|
|
|
<td width="140"> </td> |
101
|
|
|
|
|
|
|
<td colspan="2"> |
102
|
|
|
|
|
|
|
<b>(?:output power|Ausgangsleistung)</b></td> |
103
|
|
|
|
|
|
|
<td width="30"> </td> |
104
|
|
|
|
|
|
|
<td> </td></tr> |
105
|
|
|
|
|
|
|
<tr><td height="10"></td></tr> |
106
|
|
|
|
|
|
|
<tr> |
107
|
|
|
|
|
|
|
<td width="190"></td> |
108
|
|
|
|
|
|
|
<td width="100"> |
109
|
|
|
|
|
|
|
<u>String 1</u></td> |
110
|
|
|
|
|
|
|
<td width="70"> </td> |
111
|
|
|
|
|
|
|
<td width="140"> </td> |
112
|
|
|
|
|
|
|
<td width="95"> |
113
|
|
|
|
|
|
|
<u>L1</u></td> |
114
|
|
|
|
|
|
|
<td width="70"> </td> |
115
|
|
|
|
|
|
|
<td width="30"> </td> |
116
|
|
|
|
|
|
|
<td> </td></tr> |
117
|
|
|
|
|
|
|
<tr> |
118
|
|
|
|
|
|
|
<td width="190"></td> |
119
|
|
|
|
|
|
|
<td width="100"> |
120
|
|
|
|
|
|
|
(?:voltage|Spannung)</td> |
121
|
|
|
|
|
|
|
<td width="70" align="right" bgcolor="#FFFFFF"> |
122
|
|
|
|
|
|
|
(?<voltage_string_1>$RE_Int)</td> |
123
|
|
|
|
|
|
|
<td width="140">  V</td> |
124
|
|
|
|
|
|
|
<td width="100"> |
125
|
|
|
|
|
|
|
(?:voltage|Spannung)</td> |
126
|
|
|
|
|
|
|
<td width="70" align="right" bgcolor="#FFFFFF"> |
127
|
|
|
|
|
|
|
(?<voltage_l1>$RE_Int)</td> |
128
|
|
|
|
|
|
|
<td width="30">  V</td> |
129
|
|
|
|
|
|
|
<td> </td></tr> |
130
|
|
|
|
|
|
|
<tr height="2"><td></td></tr> |
131
|
|
|
|
|
|
|
<tr valign="top" align="left"> |
132
|
|
|
|
|
|
|
<td width="190"> </td> |
133
|
|
|
|
|
|
|
<td width="100"> |
134
|
|
|
|
|
|
|
(?:current|Strom)</td> |
135
|
|
|
|
|
|
|
<td width="70" align="right" bgcolor="#FFFFFF"> |
136
|
|
|
|
|
|
|
(?<current_string_1>$RE_Num)</td> |
137
|
|
|
|
|
|
|
<td width="140">  A</td> |
138
|
|
|
|
|
|
|
<td width="100"> |
139
|
|
|
|
|
|
|
(?:power|Leistung)</td> |
140
|
|
|
|
|
|
|
<td width="70" align="right" bgcolor="#FFFFFF"> |
141
|
|
|
|
|
|
|
(?<power_l1>$RE_Int)</td> |
142
|
|
|
|
|
|
|
<td width="30">  W</td> |
143
|
|
|
|
|
|
|
<td> </td></tr> |
144
|
|
|
|
|
|
|
<tr height="22"><td></td></tr> |
145
|
|
|
|
|
|
|
<tr> |
146
|
|
|
|
|
|
|
<td width="190"></td> |
147
|
|
|
|
|
|
|
<td width="100"> |
148
|
|
|
|
|
|
|
<u>String 2</u></td> |
149
|
|
|
|
|
|
|
<td width="70"> </td> |
150
|
|
|
|
|
|
|
<td width="140"> </td> |
151
|
|
|
|
|
|
|
<td width="100"> |
152
|
|
|
|
|
|
|
<u>L2</u></td> |
153
|
|
|
|
|
|
|
<td width="70"> </td> |
154
|
|
|
|
|
|
|
<td width="30"> </td> |
155
|
|
|
|
|
|
|
<td> </td></tr> |
156
|
|
|
|
|
|
|
<tr> |
157
|
|
|
|
|
|
|
<td width="190"></td> |
158
|
|
|
|
|
|
|
<td width="100"> |
159
|
|
|
|
|
|
|
(?:voltage|Spannung)</td> |
160
|
|
|
|
|
|
|
<td width="70" align="right" bgcolor="#FFFFFF"> |
161
|
|
|
|
|
|
|
(?<voltage_string_2>$RE_Int)</td> |
162
|
|
|
|
|
|
|
<td width="140">  V</td> |
163
|
|
|
|
|
|
|
<td width="100"> |
164
|
|
|
|
|
|
|
(?:voltage|Spannung)</td> |
165
|
|
|
|
|
|
|
<td width="70" align="right" bgcolor="#FFFFFF"> |
166
|
|
|
|
|
|
|
(?<voltage_l2>$RE_Int)</td> |
167
|
|
|
|
|
|
|
<td width="30">  V</td> |
168
|
|
|
|
|
|
|
<td> </td></tr> |
169
|
|
|
|
|
|
|
<tr height="2"><td></td></tr> |
170
|
|
|
|
|
|
|
<tr valign="top" align="left"> |
171
|
|
|
|
|
|
|
<td width="190"> </td> |
172
|
|
|
|
|
|
|
<td width="100"> |
173
|
|
|
|
|
|
|
(?:current|Strom)</td> |
174
|
|
|
|
|
|
|
<td width="70" align="right" bgcolor="#FFFFFF"> |
175
|
|
|
|
|
|
|
(?<current_string_2>$RE_Num)</td> |
176
|
|
|
|
|
|
|
<td width="140">  A</td> |
177
|
|
|
|
|
|
|
<td width="100"> |
178
|
|
|
|
|
|
|
(?:power|Leistung)</td> |
179
|
|
|
|
|
|
|
<td width="70" align="right" bgcolor="#FFFFFF"> |
180
|
|
|
|
|
|
|
(?<power_l2>$RE_Int)</td> |
181
|
|
|
|
|
|
|
<td width="30">  W</td> |
182
|
|
|
|
|
|
|
<td> </td></tr> |
183
|
|
|
|
|
|
|
<tr height="22"><td></td></tr> |
184
|
|
|
|
|
|
|
<tr> |
185
|
|
|
|
|
|
|
<td width="190"></td> |
186
|
|
|
|
|
|
|
<td width="100"> |
187
|
|
|
|
|
|
|
<u> </u></td> |
188
|
|
|
|
|
|
|
<td width="70"> </td> |
189
|
|
|
|
|
|
|
<td width="140"> </td> |
190
|
|
|
|
|
|
|
<td width="100"> |
191
|
|
|
|
|
|
|
<u>L3</u></td> |
192
|
|
|
|
|
|
|
<td width="70"> </td> |
193
|
|
|
|
|
|
|
<td width="30"> </td> |
194
|
|
|
|
|
|
|
<td> </td></tr> |
195
|
|
|
|
|
|
|
<tr> |
196
|
|
|
|
|
|
|
<td width="190"></td> |
197
|
|
|
|
|
|
|
<td width="100"> |
198
|
|
|
|
|
|
|
</td> |
199
|
|
|
|
|
|
|
<td width="70" align="right" bgcolor="#EAF7F7"> |
200
|
|
|
|
|
|
|
</td> |
201
|
|
|
|
|
|
|
<td width="140">  |
202
|
|
|
|
|
|
|
</td> |
203
|
|
|
|
|
|
|
<td width="95"> |
204
|
|
|
|
|
|
|
(?:voltage|Spannung)</td> |
205
|
|
|
|
|
|
|
<td width="70" align="right" bgcolor="#FFFFFF"> |
206
|
|
|
|
|
|
|
(?<voltage_l3>$RE_Int)</td> |
207
|
|
|
|
|
|
|
<td width="30">  V</td> |
208
|
|
|
|
|
|
|
<td> </td></tr> |
209
|
|
|
|
|
|
|
<tr height="2"><td></td></tr> |
210
|
|
|
|
|
|
|
<tr valign="top" align="left"> |
211
|
|
|
|
|
|
|
<td width="190"> </td> |
212
|
|
|
|
|
|
|
<td width="95"> |
213
|
|
|
|
|
|
|
</td> |
214
|
|
|
|
|
|
|
<td width="70" align="right" bgcolor="#EAF7F7"> |
215
|
|
|
|
|
|
|
</td> |
216
|
|
|
|
|
|
|
<td width="140">  |
217
|
|
|
|
|
|
|
</td> |
218
|
|
|
|
|
|
|
<td width="95"> |
219
|
|
|
|
|
|
|
(?:power|Leistung)</td> |
220
|
|
|
|
|
|
|
<td width="70" align="right" bgcolor="#FFFFFF"> |
221
|
|
|
|
|
|
|
(?<power_l3>$RE_Int)</td> |
222
|
|
|
|
|
|
|
<td width="30">  W</td> |
223
|
|
|
|
|
|
|
<td> </td></tr> |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
<tr><td height="15"></td></tr> |
226
|
|
|
|
|
|
|
<tr><td colspan="7"> |
227
|
|
|
|
|
|
|
<table align="top" width="100%"> |
228
|
|
|
|
|
|
|
<tr><td width="182"></td> |
229
|
|
|
|
|
|
|
<td><hr size="1"></font></td> |
230
|
|
|
|
|
|
|
</tr><tr><td height="5"></td></tr></table> |
231
|
|
|
|
|
|
|
</td></tr></table> |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
or die "Cannot parse status page:\n$args{html}"; |
234
|
3
|
|
|
3
|
|
4674
|
%args = ( %+, %args ); |
|
3
|
|
|
|
|
1129
|
|
|
3
|
|
|
|
|
274
|
|
235
|
|
|
|
|
|
|
$class->$orig(%args); |
236
|
|
|
|
|
|
|
}; |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
239
|
3
|
|
|
3
|
|
27
|
no Mouse; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
24
|
|
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
1; |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
__END__ |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=encoding UTF-8 |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head1 NAME |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
Device::Inverter::KOSTAL::PIKO::Status - |
250
|
|
|
|
|
|
|
current status of a L<Device::Inverter::KOSTAL::PIKO> device |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head1 SYNOPSIS |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
use Device::Inverter::KOSTAL::PIKO; |
255
|
|
|
|
|
|
|
my $device = Device::Inverter::KOSTALL:PIKO->new; |
256
|
|
|
|
|
|
|
my $status = $device->get_current_status; |
257
|
|
|
|
|
|
|
say $status->ac_power_current; |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=over 4 |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=item html |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
HTML code of the status page which has been returned by the device |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=item ac_power_current |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=item status |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=item total_energy |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=item daily_energy |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=item voltage_string_1 |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=item voltage_string_2 |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=item current_string_1 |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=item current_string_2 |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=item voltage_l1 |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=item voltage_l2 |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
=item voltage_l3 |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
=item power_l1 |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=item power_l2 |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=item power_l3 |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=back |