mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
external sensors minor changes in display settings
This commit is contained in:
@@ -389,10 +389,14 @@ void MyESP::mqttUnsubscribe(const char * topic) {
|
||||
|
||||
// MQTT Publish
|
||||
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
|
||||
mqttClient.publish(_mqttTopic(topic), _mqtt_qos, _mqtt_retain, payload);
|
||||
// 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);
|
||||
|
||||
_addMQTTLog(topic, payload, 1); // add to the log, using type of 1 for Publish
|
||||
if (packet_id) {
|
||||
_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
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef MyESP_h
|
||||
#define MyESP_h
|
||||
|
||||
#define MYESP_VERSION "1.2.6"
|
||||
#define MYESP_VERSION "1.2.7"
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <ArduinoOTA.h>
|
||||
|
||||
@@ -112,6 +112,7 @@ char * DS18::getDeviceString(char * buffer, unsigned char index) {
|
||||
strlcpy(buffer, "Unknown", size);
|
||||
}
|
||||
|
||||
/*
|
||||
char a[30] = {0};
|
||||
snprintf(a,
|
||||
sizeof(a),
|
||||
@@ -127,6 +128,7 @@ char * DS18::getDeviceString(char * buffer, unsigned char index) {
|
||||
_gpio);
|
||||
|
||||
strlcat(buffer, a, size);
|
||||
*/
|
||||
} else {
|
||||
strlcpy(buffer, "invalid", size);
|
||||
}
|
||||
|
||||
@@ -697,17 +697,18 @@ void publishSensorValues() {
|
||||
StaticJsonDocument<200> doc;
|
||||
JsonObject sensors = doc.to<JsonObject>();
|
||||
|
||||
bool hasdata = false;
|
||||
char label[8] = {0};
|
||||
char valuestr[8] = {0}; // for formatting temp
|
||||
bool hasdata = false;
|
||||
char label[8] = {0};
|
||||
// char valuestr[8] = {0}; // for formatting temp
|
||||
|
||||
// see if the sensor values have changed, if so send
|
||||
for (uint8_t i = 0; i < EMSESP_Settings.dallas_sensors; i++) {
|
||||
double sensorValue = ds18.getValue(i);
|
||||
if (sensorValue != DS18_DISCONNECTED && sensorValue != DS18_CRC_ERROR) {
|
||||
sprintf(label, PAYLOAD_EXTERNAL_SENSORS, (i + 1));
|
||||
sensors[label] = _float_to_char(valuestr, sensorValue);
|
||||
hasdata = true;
|
||||
// sensors[label] = _float_to_char(valuestr, sensorValue);
|
||||
sensors[label] = sensorValue; // TODO check if works
|
||||
hasdata = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user