Skip to content

Commit 4a7a3fd

Browse files
authored
fix timing polarity
fix: correct IR timings polarity – spaces must be negative (HA 2026.fix: correct IR timings polarity – spaces must be negative (HA 2026.5)
1 parent 7fcfb1b commit 4a7a3fd

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

custom_components/rav311_remote/pioneer.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
PIONEER_FREQUENCY_HZ = 40_000
55

6-
_HEADER_HIGH = 9000
7-
_HEADER_LOW = 4500
8-
_BIT_HIGH = 560
9-
_ONE_LOW = 1690
10-
_ZERO_LOW = 560
11-
_TRAILER_HIGH = 560
6+
_HEADER_HIGH = 9000
7+
_HEADER_LOW = 4500
8+
_BIT_HIGH = 560
9+
_ONE_LOW = 1690
10+
_ZERO_LOW = 560
11+
_TRAILER_HIGH = 560
1212
_TRAILER_LOW = 25500
1313

1414

@@ -21,10 +21,11 @@ def _reverse_bits(b: int) -> int:
2121

2222

2323
def _encode_uint16_lsb(value: int) -> list[int]:
24+
"""Encode 16 bits LSB-first as alternating +mark / -space integers."""
2425
result = []
2526
for _ in range(16):
26-
result.append(_BIT_HIGH)
27-
result.append(_ONE_LOW if (value & 1) else _ZERO_LOW)
27+
result.append(_BIT_HIGH) # positive = pulse
28+
result.append(-(_ONE_LOW if (value & 1) else _ZERO_LOW)) # negative = space
2829
value >>= 1
2930
return result
3031

@@ -44,10 +45,12 @@ def get_raw_timings(self) -> list[int]:
4445
address = ((~rev_high & 0xFF) << 8) | rev_high
4546
command = ((~low_byte & 0xFF) << 8) | low_byte
4647

47-
frame: list[int] = [_HEADER_HIGH, _HEADER_LOW]
48+
frame: list[int] = [
49+
_HEADER_HIGH, -_HEADER_LOW, # header: +pulse / -space
50+
]
4851
frame.extend(_encode_uint16_lsb(address))
4952
frame.extend(_encode_uint16_lsb(command))
50-
frame.extend([_TRAILER_HIGH, _TRAILER_LOW])
53+
frame.append(_TRAILER_HIGH) # trailing pulse only
5154

5255
timings: list[int] = []
5356
for _ in range(self._repeat):

0 commit comments

Comments
 (0)