mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
change dallas single format from {no:value} to {id:value}
This commit is contained in:
@@ -324,9 +324,9 @@ void DallasSensor::publish_values() {
|
||||
char sensorID[10]; // sensor{1-n}
|
||||
snprintf_P(sensorID, 10, PSTR("sensor%d"), sensor_no);
|
||||
if (mqtt_format_ == Mqtt::Format::SINGLE) {
|
||||
// e.g. sensor_data = {"sensor1":23.3,"sensor2":24.0}
|
||||
// e.g. sensor_data = {"28-EA41-9497-0E03":23.3,"28-233D-9497-0C03":24.0}
|
||||
if (Helpers::hasValue(sensor.temperature_c)) {
|
||||
doc[sensorID] = (float)(sensor.temperature_c) / 10;
|
||||
doc[sensor.to_string()] = (float)(sensor.temperature_c) / 10;
|
||||
}
|
||||
} else {
|
||||
// e.g. sensor_data = {"sensor1":{"id":"28-EA41-9497-0E03","temp":23.3},"sensor2":{"id":"28-233D-9497-0C03","temp":24.0}}
|
||||
@@ -379,4 +379,4 @@ void DallasSensor::publish_values() {
|
||||
Mqtt::publish(F("sensor_data"), doc.as<JsonObject>());
|
||||
}
|
||||
|
||||
} // namespace emsesp
|
||||
} // namespace emsesp
|
||||
|
||||
Reference in New Issue
Block a user