mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
publish MQTT shower info when connected
This commit is contained in:
@@ -396,14 +396,14 @@ void MyESP::mqttUnsubscribe(const char * topic) {
|
||||
// returns true if all good
|
||||
bool MyESP::mqttPublish(const char * topic, const char * payload) {
|
||||
if (mqttClient.connected() && (strlen(topic) > 0)) {
|
||||
// myDebug_P(PSTR("[MQTT] Sending publish to %s with payload %s"), _mqttTopic(topic), payload); // for debugging
|
||||
//myDebug_P(PSTR("[MQTT] Sending publish to %s with payload %s"), _mqttTopic(topic), payload); // for debugging
|
||||
uint16_t packet_id = mqttClient.publish(_mqttTopic(topic), _mqtt_qos, _mqtt_retain, payload);
|
||||
|
||||
if (packet_id) {
|
||||
_addMQTTLog(topic, payload, 1); // add to the log, using type of 1 for Publish
|
||||
return true;
|
||||
} else {
|
||||
myDebug_P(PSTR("[MQTT] Error publishing to %s with payload %s, error %d"), _mqttTopic(topic), payload, packet_id);
|
||||
myDebug_P(PSTR("[MQTT] Error publishing to %s with payload %s [error %d]"), _mqttTopic(topic), payload, packet_id);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1529,6 +1529,9 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
|
||||
// for receiving shower_Timer and shower_alert switches
|
||||
myESP.mqttSubscribe(TOPIC_SHOWER_DATA);
|
||||
|
||||
// send Shower Alert and Timer switch settings
|
||||
do_publishShowerData();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2056,7 +2059,6 @@ void loop() {
|
||||
if (ems_getEmsRefreshed() && (scanThermostat_count == 0)) {
|
||||
publishValues(false);
|
||||
do_publishSensorValues();
|
||||
do_publishShowerData();
|
||||
ems_setEmsRefreshed(false); // reset
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user