mirror of
https://github.com/esphome/esphome.git
synced 2026-01-09 11:40:50 -07:00
[whirlpool] support for 14 byte whirlpool IR receiver messages (#12774)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
This commit is contained in:
@@ -163,6 +163,7 @@ bool WhirlpoolClimate::on_receive(remote_base::RemoteReceiveData data) {
|
||||
}
|
||||
|
||||
uint8_t remote_state[WHIRLPOOL_STATE_LENGTH] = {0};
|
||||
bool skip_footer = false;
|
||||
// Read all bytes.
|
||||
for (int i = 0; i < WHIRLPOOL_STATE_LENGTH; i++) {
|
||||
// Read bit
|
||||
@@ -170,6 +171,13 @@ bool WhirlpoolClimate::on_receive(remote_base::RemoteReceiveData data) {
|
||||
if (!data.expect_item(WHIRLPOOL_BIT_MARK, WHIRLPOOL_GAP))
|
||||
return false;
|
||||
}
|
||||
if (i == 14 && !data.is_valid()) {
|
||||
// Remote control only sent 14 bytes, nothing more to read, not even the footer
|
||||
ESP_LOGV(TAG, "Remote control only sent %d bytes", i);
|
||||
skip_footer = true;
|
||||
break;
|
||||
}
|
||||
|
||||
for (int j = 0; j < 8; j++) {
|
||||
if (data.expect_item(WHIRLPOOL_BIT_MARK, WHIRLPOOL_ONE_SPACE)) {
|
||||
remote_state[i] |= 1 << j;
|
||||
@@ -183,7 +191,7 @@ bool WhirlpoolClimate::on_receive(remote_base::RemoteReceiveData data) {
|
||||
ESP_LOGVV(TAG, "Byte %d %02X", i, remote_state[i]);
|
||||
}
|
||||
// Validate footer
|
||||
if (!data.expect_mark(WHIRLPOOL_BIT_MARK)) {
|
||||
if (!data.expect_mark(WHIRLPOOL_BIT_MARK) && !skip_footer) {
|
||||
ESP_LOGV(TAG, "Footer fail");
|
||||
return false;
|
||||
}
|
||||
@@ -196,7 +204,7 @@ bool WhirlpoolClimate::on_receive(remote_base::RemoteReceiveData data) {
|
||||
for (uint8_t i = 14; i < 20; i++)
|
||||
checksum20 ^= remote_state[i];
|
||||
|
||||
if (checksum13 != remote_state[13] || checksum20 != remote_state[20]) {
|
||||
if (checksum13 != remote_state[13] || (!skip_footer && checksum20 != remote_state[20])) {
|
||||
ESP_LOGVV(TAG, "Checksum fail");
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user