From c74935aa010a89406767b29c12f585de4eff8c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Sat, 3 Jun 2023 17:37:53 +0200 Subject: [PATCH] Somfy: publish SunFlag, Sunny and Windy states MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Álvaro Fernández Rojas --- Somfy.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Somfy.cpp b/Somfy.cpp index 3c1e4f6..4a12fb1 100644 --- a/Somfy.cpp +++ b/Somfy.cpp @@ -1010,7 +1010,6 @@ void SomfyShade::emitState(uint8_t num, const char *evt) { mqtt.publish(topic, static_cast(floor(this->myPos))); snprintf(topic, sizeof(topic), "shades/%u/tiltType", this->shadeId); mqtt.publish(topic, static_cast(this->tiltType)); - snprintf(topic, sizeof(topic), "shades/%u/flags", this->flags); if(this->tiltType != tilt_types::none) { snprintf(topic, sizeof(topic), "shades/%u/myTiltPos", this->shadeId); mqtt.publish(topic, static_cast(floor(this->myTiltPos))); @@ -1019,6 +1018,18 @@ void SomfyShade::emitState(uint8_t num, const char *evt) { snprintf(topic, sizeof(topic), "shades/%u/tiltTarget", this->shadeId); mqtt.publish(topic, static_cast(floor(this->tiltTarget))); } + else if (this->shadeType == shade_types::awning) { + const uint8_t sunFlag = !!(this->flags & static_cast(somfy_flags_t::SunFlag)); + const uint8_t isSunny = !!(this->flags & static_cast(somfy_flags_t::Sunny)); + const uint8_t isWindy = !!(this->flags & static_cast(somfy_flags_t::Windy)); + + snprintf(topic, sizeof(topic), "shades/%u/sunFlag", this->shadeId); + mqtt.publish(topic, sunFlag); + snprintf(topic, sizeof(topic), "shades/%u/sunny", this->shadeId); + mqtt.publish(topic, isSunny); + snprintf(topic, sizeof(topic), "shades/%u/windy", this->shadeId); + mqtt.publish(topic, isWindy); + } } } bool SomfyShade::isIdle() { return this->direction == 0 && this->tiltDirection == 0; }