mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-02-17 12:12:11 +01:00
Persist the disco configuration in MQTT
This commit is contained in:
parent
da551f3385
commit
0e91539457
4 changed files with 19 additions and 1 deletions
19
Somfy.cpp
19
Somfy.cpp
|
|
@ -1484,7 +1484,17 @@ void SomfyShade::publishDisco() {
|
||||||
}
|
}
|
||||||
|
|
||||||
obj["enabled_by_default"] = true;
|
obj["enabled_by_default"] = true;
|
||||||
mqtt.publishDisco(topic, obj);
|
mqtt.publishDisco(topic, obj, true);
|
||||||
|
}
|
||||||
|
void SomfyShade::unpublishDisco() {
|
||||||
|
if(!mqtt.connected() || !settings.MQTT.pubDisco) return;
|
||||||
|
char topic[128] = "";
|
||||||
|
if(this->shadeType != shade_types::drycontact && this->shadeType != shade_types::drycontact2) {
|
||||||
|
snprintf(topic, sizeof(topic), "%s/cover/%d/config", settings.MQTT.discoTopic, this->shadeId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
snprintf(topic, sizeof(topic), "%s/switch/%d/config", settings.MQTT.discoTopic, this->shadeId);
|
||||||
|
mqtt.unpublish(topic);
|
||||||
}
|
}
|
||||||
void SomfyShade::publish() {
|
void SomfyShade::publish() {
|
||||||
if(mqtt.connected()) {
|
if(mqtt.connected()) {
|
||||||
|
|
@ -1549,6 +1559,13 @@ void SomfyShade::unpublish(uint8_t id) {
|
||||||
SomfyShade::unpublish(id, "tiltTarget");
|
SomfyShade::unpublish(id, "tiltTarget");
|
||||||
SomfyShade::unpublish(id, "windy");
|
SomfyShade::unpublish(id, "windy");
|
||||||
SomfyShade::unpublish(id, "sunny");
|
SomfyShade::unpublish(id, "sunny");
|
||||||
|
if(settings.MQTT.pubDisco) {
|
||||||
|
char topic[128] = "";
|
||||||
|
snprintf(topic, sizeof(topic), "%s/cover/%d/config", settings.MQTT.discoTopic, id);
|
||||||
|
mqtt.unpublish(topic);
|
||||||
|
snprintf(topic, sizeof(topic), "%s/switch/%d/config", settings.MQTT.discoTopic, id);
|
||||||
|
mqtt.unpublish(topic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void SomfyGroup::unpublish(uint8_t id) {
|
void SomfyGroup::unpublish(uint8_t id) {
|
||||||
|
|
|
||||||
1
Somfy.h
1
Somfy.h
|
|
@ -351,6 +351,7 @@ class SomfyShade : public SomfyRemote {
|
||||||
bool publish(const char *topic, uint16_t val, bool retain = false);
|
bool publish(const char *topic, uint16_t val, bool retain = false);
|
||||||
bool publish(const char *topic, bool val, bool retain = false);
|
bool publish(const char *topic, bool val, bool retain = false);
|
||||||
void publishDisco();
|
void publishDisco();
|
||||||
|
void unpublishDisco();
|
||||||
};
|
};
|
||||||
class SomfyGroup : public SomfyRemote {
|
class SomfyGroup : public SomfyRemote {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue