From 1be1fe4fbad6014310fd42eb795a52df99ee0e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Fri, 2 Jun 2023 11:24:33 +0200 Subject: [PATCH] Somfy: add Sun/Wind auto movement logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Álvaro Fernández Rojas --- Somfy.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Somfy.cpp b/Somfy.cpp index f94192a..5aca6c9 100644 --- a/Somfy.cpp +++ b/Somfy.cpp @@ -1081,10 +1081,28 @@ void SomfyShade::processFrame(somfy_frame_t &frame, bool internal) { // will need to see what the shade does when you press both. switch(frame.cmd) { case somfy_commands::Sensor: - if((frame.rollingCode << 4) & static_cast(somfy_flags_t::Sunny)) this->flags |= static_cast(somfy_flags_t::Sunny); - else this->flags &= ~(static_cast(somfy_flags_t::Sunny)); - if((frame.rollingCode << 4) & static_cast(somfy_flags_t::Windy)) this->flags |= static_cast(somfy_flags_t::Windy); - else this->flags &= ~(static_cast(somfy_flags_t::Windy)); + if ((frame.rollingCode << 4) & static_cast(somfy_flags_t::Sunny)) + this->flags |= static_cast(somfy_flags_t::Sunny); + else + this->flags &= ~(static_cast(somfy_flags_t::Sunny)); + + if ((frame.rollingCode << 4) & static_cast(somfy_flags_t::Windy)) + this->flags |= static_cast(somfy_flags_t::Windy); + else + this->flags &= ~(static_cast(somfy_flags_t::Windy)); + + if (this->flags & static_cast(somfy_flags_t::Windy)) + { + this->target = 0.0f; + } + else if (this->flags & static_cast(somfy_flags_t::SunFlag)) + { + if (this->flags & static_cast(somfy_flags_t::Sunny)) + this->target = 100.0f; + else + this->target = 0.0f; + } + this->emitState(); break;