diff --git a/ConfigSettings.h b/ConfigSettings.h index 7ec90a2..c8f72b5 100644 --- a/ConfigSettings.h +++ b/ConfigSettings.h @@ -3,7 +3,7 @@ #ifndef configsettings_h #define configsettings_h -#define FW_VERSION "v1.6.2" +#define FW_VERSION "v1.7.0" enum DeviceStatus { DS_OK = 0, DS_ERROR = 1, diff --git a/MQTT.cpp b/MQTT.cpp index 59095ee..d1adb27 100644 --- a/MQTT.cpp +++ b/MQTT.cpp @@ -78,6 +78,10 @@ void MQTTClass::receive(const char *topic, byte*payload, uint32_t length) { if(val >= 0 && val <= 100) shade->moveToTarget(atoi(value)); } + if(strncmp(command, "tiltTarget", sizeof(command)) == 0) { + if(val >= 0 && val <= 100) + shade->moveToTiltTarget(atoi(value)); + } else if(strncmp(command, "direction", sizeof(command)) == 0) { if(val < 0) shade->sendCommand(somfy_commands::Up); @@ -90,6 +94,10 @@ void MQTTClass::receive(const char *topic, byte*payload, uint32_t length) { if(val >= 0 && val <= 100) shade->setMyPosition(val); } + else if(strncmp(command, "sunFlag", sizeof(command)) == 0) { + if(val >= 0) shade->sendCommand(somfy_commands::SunFlag); + else shade->sendCommand(somfy_commands::Flag); + } } } bool MQTTClass::connect() { @@ -110,8 +118,10 @@ bool MQTTClass::connect() { Serial.println(this->clientId); somfy.publish(); this->subscribe("shades/+/target/set"); + this->subscribe("shades/+/tiltTarget/set"); this->subscribe("shades/+/direction/set"); this->subscribe("shades/+/mypos/set"); + this->subscribe("shades/+/sunFlag/set"); mqttClient.setCallback(MQTTClass::receive); this->lastConnect = millis(); return true; @@ -132,6 +142,9 @@ bool MQTTClass::disconnect() { if(mqttClient.connected()) { this->unsubscribe("shades/+/target/set"); this->unsubscribe("shades/+/direction/set"); + this->unsubscribe("shades/+/tiltTarget/set"); + this->unsubscribe("shades/+/mypos/set"); + this->unsubscribe("shades/+/sunFlag/set"); mqttClient.disconnect(); } return true; diff --git a/Somfy.cpp b/Somfy.cpp index 4a12fb1..754831a 100644 --- a/Somfy.cpp +++ b/Somfy.cpp @@ -630,7 +630,7 @@ void SomfyShade::checkMovement() { && this->sunStart && (curTime - this->sunStart) >= SOMFY_SUN_TIMEOUT) { - this->target = 100.0f; + this->target = this->myPos >= 0 ? this->myPos : 100.0f; this->sunDone = true; Serial.printf("[%u] Sun -> done\r\n", this->shadeId); @@ -1240,7 +1240,7 @@ void SomfyShade::processFrame(somfy_frame_t &frame, bool internal) { const bool isSunny = this->flags & static_cast(somfy_flags_t::Sunny); if (isSunny && this->sunDone) - this->target = 100.0f; + this->target = this->myPos >= 0 ? this->myPos : 100.0f; else if (!isSunny && this->noSunDone) this->target = 0.0f; } diff --git a/SomfyController.ino.esp32.bin b/SomfyController.ino.esp32.bin index 4636f35..7faeae2 100644 Binary files a/SomfyController.ino.esp32.bin and b/SomfyController.ino.esp32.bin differ diff --git a/SomfyController.littlefs.bin b/SomfyController.littlefs.bin index 240d795..445d8f2 100644 Binary files a/SomfyController.littlefs.bin and b/SomfyController.littlefs.bin differ diff --git a/data/appversion b/data/appversion index 308b6fa..9dbb0c0 100644 --- a/data/appversion +++ b/data/appversion @@ -1 +1 @@ -1.6.2 \ No newline at end of file +1.7.0 \ No newline at end of file diff --git a/data/index.html b/data/index.html index 4fa1201..2e218b1 100644 --- a/data/index.html +++ b/data/index.html @@ -3,10 +3,10 @@ - - + + - +
diff --git a/data/index.js b/data/index.js index 575223a..18d6234 100644 --- a/data/index.js +++ b/data/index.js @@ -378,7 +378,7 @@ async function reopenSocket() { await initSockets(); } class General { - appVersion = 'v1.6.2'; + appVersion = 'v1.7.0'; reloadApp = false; async init() { this.setAppVersion();