Coding for sun and wind flag processing v1.7.0

* Added MQTT control for sunFlag and tiltTarget.
* Move my position if it is set per sun sensor instructions.
* Add sun/wind states to persistence.
* Bump restore file version
This commit is contained in:
Robert Strouse 2023-06-04 13:04:57 -07:00
parent 883dd63d3f
commit 2ecc0de36e
8 changed files with 21 additions and 8 deletions

View file

@ -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,

View file

@ -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;

View file

@ -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<uint8_t>(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;
}

Binary file not shown.

Binary file not shown.

View file

@ -1 +1 @@
1.6.2
1.7.0

View file

@ -3,10 +3,10 @@
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<link rel="stylesheet" href="main.css?v=1.6.2" type="text/css" />
<link rel="stylesheet" href="icons.css?v=1.6.2" type="text/css" />
<link rel="stylesheet" href="main.css?v=1.7.0" type="text/css" />
<link rel="stylesheet" href="icons.css?v=1.7.0" type="text/css" />
<link rel="icon" type="image/png" href="favicon.png" />
<script type="text/javascript" src="index.js?v=1.6.2"></script>
<script type="text/javascript" src="index.js?v=1.7.0"></script>
</head>
<body>
<div id="divContainer" class="container" style="user-select:none;position:relative;border-radius:27px;">

View file

@ -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();