publish MQTT shower info when connected

This commit is contained in:
Paul
2019-10-13 19:00:57 +02:00
parent c8845a1734
commit 1e85934b38
2 changed files with 5 additions and 3 deletions

View File

@@ -396,14 +396,14 @@ void MyESP::mqttUnsubscribe(const char * topic) {
// returns true if all good // returns true if all good
bool MyESP::mqttPublish(const char * topic, const char * payload) { bool MyESP::mqttPublish(const char * topic, const char * payload) {
if (mqttClient.connected() && (strlen(topic) > 0)) { 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); uint16_t packet_id = mqttClient.publish(_mqttTopic(topic), _mqtt_qos, _mqtt_retain, payload);
if (packet_id) { if (packet_id) {
_addMQTTLog(topic, payload, 1); // add to the log, using type of 1 for Publish _addMQTTLog(topic, payload, 1); // add to the log, using type of 1 for Publish
return true; return true;
} else { } 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; return false;
} }
} }

View File

@@ -1529,6 +1529,9 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
// for receiving shower_Timer and shower_alert switches // for receiving shower_Timer and shower_alert switches
myESP.mqttSubscribe(TOPIC_SHOWER_DATA); myESP.mqttSubscribe(TOPIC_SHOWER_DATA);
// send Shower Alert and Timer switch settings
do_publishShowerData();
return; return;
} }
@@ -2056,7 +2059,6 @@ void loop() {
if (ems_getEmsRefreshed() && (scanThermostat_count == 0)) { if (ems_getEmsRefreshed() && (scanThermostat_count == 0)) {
publishValues(false); publishValues(false);
do_publishSensorValues(); do_publishSensorValues();
do_publishShowerData();
ems_setEmsRefreshed(false); // reset ems_setEmsRefreshed(false); // reset
} }