line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
2135
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
100
|
|
2
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
155
|
|
3
|
|
|
|
|
|
|
package Device::RFXCOM::Decoder::Electrisave; |
4
|
|
|
|
|
|
|
$Device::RFXCOM::Decoder::Electrisave::VERSION = '1.163170'; |
5
|
|
|
|
|
|
|
# ABSTRACT: Device::RFXCOM::Decoder::Electrisave decode Electrisave RF messages |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
54
|
use 5.006; |
|
3
|
|
|
|
|
10
|
|
9
|
3
|
|
|
3
|
|
11
|
use constant DEBUG => $ENV{DEVICE_RFXCOM_DECODER_ELECTRISAVE_DEBUG}; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
192
|
|
10
|
3
|
|
|
3
|
|
14
|
use Carp qw/croak/; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
166
|
|
11
|
3
|
|
|
3
|
|
17
|
use base 'Device::RFXCOM::Decoder'; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
305
|
|
12
|
3
|
|
|
3
|
|
16
|
use Device::RFXCOM::Response::Sensor; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
874
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub decode { |
16
|
83
|
|
|
83
|
1
|
156
|
my ($self, $parent, $message, $bytes, $bits, $result) = @_; |
17
|
83
|
100
|
|
|
|
407
|
$bits == 120 or return; |
18
|
|
|
|
|
|
|
|
19
|
8
|
100
|
100
|
|
|
81
|
($bytes->[0]==0xea && $bytes->[9]==0xff && $bytes->[10]==0x5f) or return; |
|
|
|
100
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
11
|
my $device = sprintf "%02x", $bytes->[2]; |
22
|
2
|
|
|
|
|
5
|
my @ct = (); |
23
|
2
|
|
|
|
|
8
|
$ct[1] = ( (($bytes->[3] ) )+(($bytes->[4]&0x3 )<<8) ) / 10; |
24
|
2
|
|
|
|
|
6
|
$ct[2] = ( (($bytes->[4]&0xFC)>>2)+(($bytes->[5]&0xF )<<6) ) / 10; |
25
|
2
|
|
|
|
|
5
|
$ct[3] = ( (($bytes->[5]&0xF0)>>4)+(($bytes->[6]&0x3F)<<4) ) / 10; |
26
|
2
|
|
|
|
|
5
|
$ct[0] = $ct[1] + $ct[2] + $ct[3]; |
27
|
2
|
|
|
|
|
7
|
foreach my $index (0..3) { |
28
|
8
|
100
|
|
|
|
19
|
my $dev = $device.($index ? '.'.$index : ''); |
29
|
8
|
|
|
|
|
7
|
printf "electrisave d=%s current=%.2f\n", $dev, $ct[$index] if DEBUG; |
30
|
8
|
|
|
|
|
8
|
push @{$result->{messages}}, |
|
8
|
|
|
|
|
44
|
|
31
|
|
|
|
|
|
|
Device::RFXCOM::Response::Sensor->new(device => 'electrisave.'.$dev, |
32
|
|
|
|
|
|
|
measurement => 'current', |
33
|
|
|
|
|
|
|
value => $ct[$index]); |
34
|
|
|
|
|
|
|
} |
35
|
2
|
100
|
|
|
|
4
|
push @{$result->{messages}}, |
|
2
|
|
|
|
|
15
|
|
36
|
|
|
|
|
|
|
Device::RFXCOM::Response::Sensor->new(device => 'electrisave.'.$device, |
37
|
|
|
|
|
|
|
measurement => 'battery', |
38
|
|
|
|
|
|
|
value => (($bytes->[1]&0x10) |
39
|
|
|
|
|
|
|
? 10 : 90), |
40
|
|
|
|
|
|
|
units => '%'); |
41
|
2
|
|
|
|
|
10
|
return 1; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |