| 1 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | package Device::RFXCOM::Decoder::Digimax; | ||||||||||
| 4 | 3 | $Device::RFXCOM::Decoder::Digimax::VERSION = '1.142010'; | |||||||||
| 5 | # ABSTRACT: Device::RFXCOM::Decoder::Digimax decode Digimax RF messages | ||||||||||
| 6 | |||||||||||
| 7 | |||||||||||
| 8 | 3 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 3 | ▶ | use constant DEBUG => $ENV{DEVICE_RFXCOM_DECODER_DIGIMAX_DEBUG}; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 3 | ▶ | use Carp qw/croak/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 3 | ▶ | use base 'Device::RFXCOM::Decoder'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 3 | ▶ | use Device::RFXCOM::Response::Thermostat; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 3 | ▶ | use Device::RFXCOM::Decoder qw/hi_nibble lo_nibble nibble_sum/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | |||||||||||
| 16 | sub decode { | ||||||||||
| 17 | 86 | ▶ | my ($self, $parent, $message, $bytes, $bits, $result) = @_; | ||||||||
|
Subroutine
decode: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||
| 18 | 86 | ▶ | return unless ($bits == 44); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 5 | my $p = | |||||||||
| 20 | hi_nibble($bytes->[0]) + lo_nibble($bytes->[0]) + | ||||||||||
| 21 | hi_nibble($bytes->[1]) + lo_nibble($bytes->[1]) + | ||||||||||
| 22 | hi_nibble($bytes->[2]) + lo_nibble($bytes->[2]); | ||||||||||
| 23 | 5 | $p &= 0xf; | |||||||||
| 24 | 5 | ▶ | return unless ($p == 0xf); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | |||||||||||
| 26 | 4 | $p = | |||||||||
| 27 | hi_nibble($bytes->[3]) + lo_nibble($bytes->[3]) + | ||||||||||
| 28 | hi_nibble($bytes->[4]) + lo_nibble($bytes->[4]) + | ||||||||||
| 29 | hi_nibble($bytes->[5]); | ||||||||||
| 30 | 4 | $p &= 0xf; | |||||||||
| 31 | 4 | ▶ | return unless ($p == 0xf); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | |||||||||||
| 33 | 3 | my $state = | |||||||||
| 34 | [ | ||||||||||
| 35 | 'undef', 'demand', 'satisfied', 'init' | ||||||||||
| 36 | ]->[hi_nibble($bytes->[2])&0x3]; | ||||||||||
| 37 | |||||||||||
| 38 | 3 | my $temp = $bytes->[3]; | |||||||||
| 39 | 3 | my $set = $bytes->[4]&0x3f; | |||||||||
| 40 | 3 | ▶ | my $mode = $bytes->[4]&0x40 ? 'cool' : 'heat'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 3 | my $device = sprintf 'digimax.%02x%02x', $bytes->[0], $bytes->[1]; | |||||||||
| 42 | 3 | printf STDERR "Thermostat: $device $state $temp $set $mode\n" if DEBUG; | |||||||||
| 43 | 3 | push @{$result->{messages}}, | |||||||||
| 44 | Device::RFXCOM::Response::Thermostat->new(device => $device, | ||||||||||
| 45 | temp => $temp, | ||||||||||
| 46 | set => $set, | ||||||||||
| 47 | mode => $mode, | ||||||||||
| 48 | state => $state); | ||||||||||
| 49 | 3 | return 1; | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 3 | 1; | |||||||||
| 53 | |||||||||||
| 54 | __END__ | ||||||||||