line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
7752
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
136
|
|
2
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
214
|
|
3
|
|
|
|
|
|
|
package Device::RFXCOM::Decoder::HomeEasy; |
4
|
|
|
|
|
|
|
$Device::RFXCOM::Decoder::HomeEasy::VERSION = '1.142010'; |
5
|
|
|
|
|
|
|
# ABSTRACT: Device::RFXCOM::Decoder::HomeEasy decode HomeEasy RF messages |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
103
|
use 5.006; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
155
|
|
9
|
3
|
|
|
3
|
|
24
|
use constant DEBUG => $ENV{DEVICE_RFXCOM_DECODER_HOMEEASY_DEBUG}; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
247
|
|
10
|
3
|
|
|
3
|
|
19
|
use Carp qw/croak/; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
218
|
|
11
|
3
|
|
|
3
|
|
38
|
use base 'Device::RFXCOM::Decoder'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
2140
|
|
12
|
3
|
|
|
3
|
|
2138
|
use Device::RFXCOM::Response::HomeEasy; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
1471
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub decode { |
16
|
81
|
|
|
81
|
1
|
1948
|
my ($self, $parent, $message, $bytes, $bits, $result) = @_; |
17
|
|
|
|
|
|
|
|
18
|
81
|
100
|
100
|
|
|
1421
|
$bits == 34 or $bits == 38 or return; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# HomeEasy devices seem to send duplicates with different byte[4] high nibble |
21
|
4
|
|
|
|
|
6
|
my @b = @{$bytes}; |
|
4
|
|
|
|
|
10
|
|
22
|
4
|
|
|
|
|
7
|
my $b4 = $b[4]; |
23
|
4
|
|
|
|
|
5
|
$b[4] &= 0xf; |
24
|
4
|
100
|
|
|
|
17
|
if ($b[4] != $b4) { |
25
|
3
|
|
|
|
|
13
|
$result->{key} = $bits.'!'.(pack "C*", @b); |
26
|
3
|
|
|
|
|
11
|
my $entry = $parent->_cache_get($result); |
27
|
3
|
100
|
|
|
|
10
|
if ($entry) { |
28
|
1
|
|
|
|
|
4
|
$result->{messages} = $entry->{result}->{messages}; |
29
|
1
|
|
|
|
|
13
|
$result->{duplicate} = $parent->_cache_is_duplicate($entry); |
30
|
1
|
|
|
|
|
6
|
return 1; |
31
|
|
|
|
|
|
|
} |
32
|
2
|
|
|
|
|
4
|
$b[4] = $b4; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
3
|
|
|
|
|
10
|
my $res = from_rf($bits, $bytes); |
36
|
|
|
|
|
|
|
|
37
|
3
|
|
|
|
|
5
|
printf "homeeasy c=%s u=%s a=%x\n", |
38
|
|
|
|
|
|
|
$res->{command}, $res->{unit}, $res->{address} if DEBUG; |
39
|
3
|
|
|
|
|
21
|
my %body = ( |
40
|
|
|
|
|
|
|
address => (sprintf "%#x",$res->{address}), |
41
|
|
|
|
|
|
|
unit => $res->{unit}, |
42
|
|
|
|
|
|
|
command => $res->{command}, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
3
|
100
|
|
|
|
10
|
$body{level} = $res->{level} if ($res->{command} eq 'preset'); |
46
|
|
|
|
|
|
|
|
47
|
3
|
|
|
|
|
4
|
push @{$result->{messages}}, Device::RFXCOM::Response::HomeEasy->new(%body); |
|
3
|
|
|
|
|
28
|
|
48
|
3
|
|
|
|
|
19
|
return 1; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub from_rf { |
53
|
3
|
|
|
3
|
1
|
6
|
my $length = shift; |
54
|
3
|
|
|
|
|
5
|
my $bytes = shift; |
55
|
3
|
|
|
|
|
6
|
my %p = (); |
56
|
3
|
|
|
|
|
16
|
$p{address} = ($bytes->[0] << 18) + ($bytes->[1] << 10) + |
57
|
|
|
|
|
|
|
($bytes->[2] << 2) + ($bytes->[3] >> 6); |
58
|
3
|
|
|
|
|
8
|
my $command = ($bytes->[3] >> 4) & 0x3; |
59
|
3
|
100
|
|
|
|
11
|
$p{unit} = ($command & 0x2) ? 'group' : ($bytes->[3] & 0xf); |
60
|
3
|
100
|
|
|
|
8
|
if ($length == 38) { |
61
|
1
|
|
|
|
|
4
|
$p{command} = 'preset'; |
62
|
1
|
|
|
|
|
3
|
$p{level} = $bytes->[4] >> 4; |
63
|
|
|
|
|
|
|
} else { |
64
|
2
|
100
|
|
|
|
11
|
$p{command} = ($command & 0x1) ? 'on' : 'off'; |
65
|
|
|
|
|
|
|
} |
66
|
3
|
|
|
|
|
8
|
return \%p; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |