external sensors minor changes in display settings

This commit is contained in:
Paul
2019-10-06 17:34:30 +02:00
parent cbd205fce5
commit 3638a50b8e
4 changed files with 16 additions and 9 deletions

View File

@@ -389,10 +389,14 @@ void MyESP::mqttUnsubscribe(const char * topic) {
// MQTT Publish // MQTT Publish
void MyESP::mqttPublish(const char * topic, const char * payload) { void MyESP::mqttPublish(const char * topic, const char * payload) {
// myDebug_P(PSTR("[MQTT] Sending pubish 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
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) {
_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
} else {
myDebug_P(PSTR("[MQTT] Error publishing to %s with payload %s"), _mqttTopic(topic), payload);
}
} }
// MQTT onConnect - when a connect is established // MQTT onConnect - when a connect is established

View File

@@ -9,7 +9,7 @@
#ifndef MyESP_h #ifndef MyESP_h
#define MyESP_h #define MyESP_h
#define MYESP_VERSION "1.2.6" #define MYESP_VERSION "1.2.7"
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include <ArduinoOTA.h> #include <ArduinoOTA.h>

View File

@@ -112,6 +112,7 @@ char * DS18::getDeviceString(char * buffer, unsigned char index) {
strlcpy(buffer, "Unknown", size); strlcpy(buffer, "Unknown", size);
} }
/*
char a[30] = {0}; char a[30] = {0};
snprintf(a, snprintf(a,
sizeof(a), sizeof(a),
@@ -127,6 +128,7 @@ char * DS18::getDeviceString(char * buffer, unsigned char index) {
_gpio); _gpio);
strlcat(buffer, a, size); strlcat(buffer, a, size);
*/
} else { } else {
strlcpy(buffer, "invalid", size); strlcpy(buffer, "invalid", size);
} }

View File

@@ -699,14 +699,15 @@ void publishSensorValues() {
bool hasdata = false; bool hasdata = false;
char label[8] = {0}; char label[8] = {0};
char valuestr[8] = {0}; // for formatting temp // char valuestr[8] = {0}; // for formatting temp
// see if the sensor values have changed, if so send // see if the sensor values have changed, if so send
for (uint8_t i = 0; i < EMSESP_Settings.dallas_sensors; i++) { for (uint8_t i = 0; i < EMSESP_Settings.dallas_sensors; i++) {
double sensorValue = ds18.getValue(i); double sensorValue = ds18.getValue(i);
if (sensorValue != DS18_DISCONNECTED && sensorValue != DS18_CRC_ERROR) { if (sensorValue != DS18_DISCONNECTED && sensorValue != DS18_CRC_ERROR) {
sprintf(label, PAYLOAD_EXTERNAL_SENSORS, (i + 1)); sprintf(label, PAYLOAD_EXTERNAL_SENSORS, (i + 1));
sensors[label] = _float_to_char(valuestr, sensorValue); // sensors[label] = _float_to_char(valuestr, sensorValue);
sensors[label] = sensorValue; // TODO check if works
hasdata = true; hasdata = true;
} }
} }