From 2671c5aa609a9d24d1ce565c8d51f9963c974ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Fri, 2 Jun 2023 07:38:25 +0200 Subject: [PATCH] Somfy: fix Sensor validity w/o sun/wind MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If there's no sun/win, the rolling code value will be 0. Signed-off-by: Álvaro Fernández Rojas --- Somfy.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Somfy.cpp b/Somfy.cpp index 833c983..9a3840b 100644 --- a/Somfy.cpp +++ b/Somfy.cpp @@ -161,7 +161,9 @@ void somfy_frame_t::decodeFrame(byte* frame) { } this->rollingCode = decoded[3] + (decoded[2] << 8); this->remoteAddress = (decoded[6] + (decoded[5] << 8) + (decoded[4] << 16)); - this->valid = this->checksum == checksum && this->remoteAddress > 0 && this->remoteAddress < 16777215 && this->rollingCode > 0; + this->valid = this->checksum == checksum && this->remoteAddress > 0 && this->remoteAddress < 16777215; + if (this->cmd != somfy_commands::Sensor) + this->valid &= (this->rollingCode > 0); if (this->valid) { // Check for valid command. switch (this->cmd) {