mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2025-12-13 11:02:12 +01:00
Disconnect from MQTT and reconnect when changing settings
This commit is contained in:
parent
07255fc7f0
commit
d91535c9ac
6 changed files with 52 additions and 7 deletions
23
Somfy.cpp
23
Somfy.cpp
|
|
@ -971,7 +971,9 @@ void SomfyShade::publish() {
|
|||
snprintf(topic, sizeof(topic), "shades/%u/lastRollingCode", this->shadeId);
|
||||
mqtt.publish(topic, this->lastRollingCode);
|
||||
snprintf(topic, sizeof(topic), "shades/%u/mypos", this->shadeId);
|
||||
mqtt.publish(topic, static_cast<uint8_t>(floor(this->myPos)));
|
||||
mqtt.publish(topic, static_cast<int8_t>(floor(this->myPos)));
|
||||
snprintf(topic, sizeof(topic), "shades/%u/myTiltPos", this->shadeId);
|
||||
mqtt.publish(topic, static_cast<int8_t>(floor(this->myTiltPos)));
|
||||
snprintf(topic, sizeof(topic), "shades/%u/shadeType", this->shadeId);
|
||||
mqtt.publish(topic, static_cast<uint8_t>(this->shadeType));
|
||||
snprintf(topic, sizeof(topic), "shades/%u/tiltType", this->shadeId);
|
||||
|
|
@ -987,6 +989,18 @@ void SomfyShade::publish() {
|
|||
snprintf(topic, sizeof(topic), "shades/%u/tiltTarget", this->shadeId);
|
||||
mqtt.publish(topic, static_cast<uint8_t>(floor(this->tiltTarget)));
|
||||
}
|
||||
else if (this->shadeType == shade_types::awning) {
|
||||
const uint8_t sunFlag = !!(this->flags & static_cast<uint8_t>(somfy_flags_t::SunFlag));
|
||||
const uint8_t isSunny = !!(this->flags & static_cast<uint8_t>(somfy_flags_t::Sunny));
|
||||
const uint8_t isWindy = !!(this->flags & static_cast<uint8_t>(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
void SomfyShade::emitState(const char *evt) { this->emitState(255, evt); }
|
||||
|
|
@ -1898,6 +1912,13 @@ bool SomfyShadeController::deleteShade(uint8_t shadeId) {
|
|||
if(this->shades[i].getShadeId() == shadeId) {
|
||||
shades[i].emitState("shadeRemoved");
|
||||
this->shades[i].setShadeId(255);
|
||||
this->shades[i].currentPos = 0;
|
||||
this->shades[i].currentTiltPos = 0;
|
||||
this->shades[i].myPos = -1.0f;
|
||||
this->shades[i].myTiltPos = -1.0f;
|
||||
this->shades[i].shadeType = shade_types::roller;
|
||||
this->shades[i].tiltType = tilt_types::none;
|
||||
this->shades[i].flags = 0;
|
||||
}
|
||||
}
|
||||
if(this->useNVS()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue