From a484307e495e348279c4f4fb31c4515c314a8680 Mon Sep 17 00:00:00 2001 From: MB Date: Fri, 5 Jun 2026 11:45:00 +0200 Subject: [PATCH] Fix RTW decoder: off-by-one in cmd mapping (issue #664) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The RTW protocol decoder used `encKey - 133` to remap the command, but the encoder uses encKey values starting at 133 (My), so the correct offset is 132: - My (encKey=133) → cmd 1 ✓ (previously: 0=Unknown0, unreachable since '> 133') - Up (encKey=134) → cmd 2 ✓ (previously: 1=My) - Down (encKey=136) → cmd 4 ✓ (previously: 3=MyUp) - ... Fixes: linked remote presses now correctly update shade position on RTW motors (Mantion etc.). Tested with ESP32-WROOM-32 + CC1101 V2.0 + 10x Mantion Italian motors. Before: rolling code incremented but position stuck. After: position updates correctly when wall remote is pressed. Refs: #664 --- Somfy.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Somfy.cpp b/Somfy.cpp index bffebd2..b2ea495 100644 --- a/Somfy.cpp +++ b/Somfy.cpp @@ -156,9 +156,9 @@ void somfy_frame_t::decodeFrame(byte* frame) { this->proto = radio_proto::RTV; this->cmd = (somfy_commands)(this->encKey - 148); } - else if(this->encKey > 133) { + else if(this->encKey >= 133) { this->proto = radio_proto::RTW; - this->cmd = (somfy_commands)(this->encKey - 133); + this->cmd = (somfy_commands)(this->encKey - 132); } } else this->proto = radio_proto::RTS;