2020-01-01 16:17:10 +00:00
|
|
|
/*
|
2020-06-27 10:52:44 +01:00
|
|
|
xsns_75_prometheus.ino - Web based information for Tasmota
|
2020-01-01 16:17:10 +00:00
|
|
|
|
2021-01-01 12:44:04 +00:00
|
|
|
Copyright (C) 2021 Theo Arends
|
2020-01-01 16:17:10 +00:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef USE_PROMETHEUS
|
|
|
|
/*********************************************************************************************\
|
|
|
|
* Prometheus support
|
2021-07-11 18:52:23 +01:00
|
|
|
*
|
|
|
|
* The text format for metrics, labels and values is documented at [1]. Only
|
2021-07-19 12:09:55 +01:00
|
|
|
* the UTF-8 text encoding is supported. [2] describes how metrics and labels
|
|
|
|
* should be named.
|
2021-07-11 18:52:23 +01:00
|
|
|
*
|
|
|
|
* [1]
|
|
|
|
* https://github.com/prometheus/docs/blob/master/content/docs/instrumenting/exposition_formats.md
|
2021-07-19 12:09:55 +01:00
|
|
|
* [2]
|
|
|
|
* https://github.com/prometheus/docs/blob/master/content/docs/practices/naming.md
|
2021-07-11 18:52:23 +01:00
|
|
|
*
|
2020-01-01 16:17:10 +00:00
|
|
|
\*********************************************************************************************/
|
|
|
|
|
2020-12-16 22:51:02 +00:00
|
|
|
#define XSNS_75 75
|
2020-12-16 22:39:33 +00:00
|
|
|
|
2021-07-11 18:51:46 +01:00
|
|
|
// Find appropriate unit for measurement type.
|
|
|
|
const char *UnitfromType(const char *type)
|
2020-12-16 22:39:33 +00:00
|
|
|
{
|
2020-12-24 11:37:59 +00:00
|
|
|
if (strcmp(type, "time") == 0) {
|
|
|
|
return "seconds";
|
2020-12-16 22:39:33 +00:00
|
|
|
}
|
2020-12-24 11:37:59 +00:00
|
|
|
if (strcmp(type, "temperature") == 0 || strcmp(type, "dewpoint") == 0) {
|
|
|
|
return "celsius";
|
2020-12-16 22:39:33 +00:00
|
|
|
}
|
2020-12-24 11:37:59 +00:00
|
|
|
if (strcmp(type, "pressure") == 0) {
|
|
|
|
return "hpa";
|
2020-12-16 22:39:33 +00:00
|
|
|
}
|
2020-12-24 11:37:59 +00:00
|
|
|
if (strcmp(type, "voltage") == 0) {
|
|
|
|
return "volts";
|
2020-12-16 22:39:33 +00:00
|
|
|
}
|
2020-12-24 11:37:59 +00:00
|
|
|
if (strcmp(type, "current") == 0) {
|
|
|
|
return "amperes";
|
2020-12-16 22:39:33 +00:00
|
|
|
}
|
2020-12-24 11:37:59 +00:00
|
|
|
if (strcmp(type, "mass") == 0) {
|
|
|
|
return "grams";
|
2020-12-16 22:39:33 +00:00
|
|
|
}
|
2020-12-24 11:37:59 +00:00
|
|
|
if (strcmp(type, "carbondioxide") == 0) {
|
|
|
|
return "ppm";
|
2020-12-16 22:39:33 +00:00
|
|
|
}
|
2020-12-24 11:37:59 +00:00
|
|
|
if (strcmp(type, "humidity") == 0) {
|
|
|
|
return "percentage";
|
2020-12-16 22:39:33 +00:00
|
|
|
}
|
2021-04-28 17:58:19 +01:00
|
|
|
if (strcmp(type, "id") == 0) {
|
|
|
|
return "untyped";
|
|
|
|
}
|
2020-12-16 22:39:33 +00:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2021-07-11 18:51:46 +01:00
|
|
|
// Replace spaces and periods in metric name to match Prometheus metrics
|
|
|
|
// convention.
|
|
|
|
String FormatMetricName(const char *metric) {
|
2020-12-24 11:37:59 +00:00
|
|
|
String formatted = metric;
|
|
|
|
formatted.toLowerCase();
|
|
|
|
formatted.replace(" ", "_");
|
2021-03-18 02:26:24 +00:00
|
|
|
formatted.replace(".", "_");
|
2020-12-24 11:37:59 +00:00
|
|
|
return formatted;
|
2020-12-16 22:39:33 +00:00
|
|
|
}
|
2020-01-01 16:17:10 +00:00
|
|
|
|
2021-07-19 08:58:50 +01:00
|
|
|
const uint8_t
|
2021-08-08 15:57:54 +01:00
|
|
|
kPromMetricGauge = _BV(0),
|
|
|
|
kPromMetricCounter = _BV(1),
|
2021-07-19 08:58:50 +01:00
|
|
|
kPromMetricTypeMask = kPromMetricGauge | kPromMetricCounter;
|
|
|
|
|
|
|
|
// Format and send a Prometheus metric to the client. Use flags to configure
|
|
|
|
// the type. Labels must be supplied in tuples of two character array pointers
|
|
|
|
// and terminated by nullptr.
|
|
|
|
void WritePromMetric(const char *name, uint8_t flags, const char *value, va_list labels) {
|
2021-08-08 15:57:54 +01:00
|
|
|
PGM_P const prefix = PSTR("tasmota_");
|
2021-07-19 08:58:50 +01:00
|
|
|
PGM_P tmp;
|
|
|
|
String lval;
|
|
|
|
|
|
|
|
switch (flags & kPromMetricTypeMask) {
|
|
|
|
case kPromMetricGauge:
|
|
|
|
tmp = PSTR("gauge");
|
|
|
|
break;
|
|
|
|
case kPromMetricCounter:
|
|
|
|
tmp = PSTR("counter");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
tmp = nullptr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tmp != nullptr) {
|
|
|
|
WSContentSend_P(PSTR("# TYPE %s%s %s\n"), prefix, name, tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
WSContentSend_P(PSTR("%s%s{"), prefix, name);
|
|
|
|
|
|
|
|
for (const char *sep = PSTR(""); ; sep = PSTR(",")) {
|
|
|
|
if ((tmp = va_arg(labels, PGM_P)) == nullptr) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// A few label values are stored in PROGMEM. The _P functions, e.g.
|
|
|
|
// snprintf_P, support both program and heap/stack memory with the "%s"
|
|
|
|
// format on ESP8266/ESP32. Casting the pointer to __FlashStringHelper has
|
|
|
|
// the same effect with String::operator=.
|
|
|
|
if (!(lval = va_arg(labels, const __FlashStringHelper *))) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Labels can be any sequence of UTF-8 characters, but backslash,
|
|
|
|
// double-quote and line feed must be escaped.
|
|
|
|
lval.replace("\\", "\\\\");
|
|
|
|
lval.replace("\"", "\\\"");
|
|
|
|
lval.replace("\n", "\\n");
|
|
|
|
|
|
|
|
WSContentSend_P(PSTR("%s%s=\"%s\""), sep, tmp, lval.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
WSContentSend_P(PSTR("} %s\n"), value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WritePromMetricInt32(const char *name, uint8_t flags, const int32_t value, ...) {
|
|
|
|
char str[16];
|
|
|
|
|
|
|
|
snprintf_P(str, sizeof(str), PSTR("%d"), value);
|
|
|
|
|
|
|
|
va_list labels;
|
|
|
|
va_start(labels, value);
|
|
|
|
WritePromMetric(name, flags, str, labels);
|
|
|
|
va_end(labels);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WritePromMetricDec(const char *name, uint8_t flags, double number, unsigned char prec, ...) {
|
|
|
|
char value[FLOATSZ];
|
|
|
|
|
|
|
|
// Prometheus always requires "." as the decimal separator.
|
|
|
|
dtostrfd(number, prec, value);
|
|
|
|
|
|
|
|
va_list labels;
|
|
|
|
va_start(labels, prec);
|
|
|
|
WritePromMetric(name, flags, value, labels);
|
|
|
|
va_end(labels);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WritePromMetricStr(const char *name, uint8_t flags, const char *value, ...) {
|
|
|
|
va_list labels;
|
|
|
|
va_start(labels, value);
|
|
|
|
WritePromMetric(name, flags, value, labels);
|
|
|
|
va_end(labels);
|
2021-07-11 19:15:01 +01:00
|
|
|
}
|
|
|
|
|
2021-07-21 20:10:18 +01:00
|
|
|
// Sentinel value for unknown memory metrics, chosen to unlikely match actual
|
2021-07-19 12:09:55 +01:00
|
|
|
// values.
|
|
|
|
const uint32_t kPromMemoryUnknown = 0xFFFFFFFF - 1;
|
|
|
|
|
|
|
|
// Write metrics providing information about used and available memory.
|
|
|
|
void WritePromMemoryMetrics(const char *type, uint32_t size, uint32_t avail, uint32_t max_alloc) {
|
|
|
|
if (size != kPromMemoryUnknown) {
|
|
|
|
WritePromMetricInt32(PSTR("memory_size_bytes"), kPromMetricGauge, size,
|
|
|
|
PSTR("memory"), type, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
WritePromMetricInt32(PSTR("memory_free_bytes"), kPromMetricGauge, avail,
|
|
|
|
PSTR("memory"), type, nullptr);
|
|
|
|
|
|
|
|
if (max_alloc != kPromMemoryUnknown) {
|
|
|
|
// The largest contiguous free memory block, useful for checking
|
|
|
|
// fragmentation.
|
|
|
|
WritePromMetricInt32(PSTR("memory_max_alloc_bytes"), kPromMetricGauge, max_alloc,
|
|
|
|
PSTR("memory"), type, nullptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-24 11:37:59 +00:00
|
|
|
void HandleMetrics(void) {
|
2020-12-16 22:51:02 +00:00
|
|
|
if (!HttpCheckPriviledgedAccess()) { return; }
|
2020-01-01 16:17:10 +00:00
|
|
|
|
2021-01-23 16:10:06 +00:00
|
|
|
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "Prometheus"));
|
2020-01-01 16:17:10 +00:00
|
|
|
|
|
|
|
WSContentBegin(200, CT_PLAIN);
|
|
|
|
|
2021-07-19 08:58:50 +01:00
|
|
|
char namebuf[64];
|
2020-01-01 16:17:10 +00:00
|
|
|
|
2020-06-27 12:21:11 +01:00
|
|
|
// Pseudo-metric providing metadata about the running firmware version.
|
2021-07-19 08:58:50 +01:00
|
|
|
WritePromMetricInt32(PSTR("info"), kPromMetricGauge, 1,
|
|
|
|
PSTR("version"), TasmotaGlobal.version,
|
|
|
|
PSTR("image"), TasmotaGlobal.image_name,
|
|
|
|
PSTR("build_timestamp"), GetBuildDateAndTime().c_str(),
|
|
|
|
PSTR("devicename"), SettingsText(SET_DEVICENAME),
|
|
|
|
nullptr);
|
2020-06-25 11:06:24 +01:00
|
|
|
|
2021-07-19 08:58:50 +01:00
|
|
|
WritePromMetricInt32(PSTR("uptime_seconds"), kPromMetricGauge, TasmotaGlobal.uptime, nullptr);
|
|
|
|
WritePromMetricInt32(PSTR("boot_count"), kPromMetricCounter, Settings->bootcount, nullptr);
|
|
|
|
WritePromMetricInt32(PSTR("flash_writes_total"), kPromMetricCounter, Settings->save_flag, nullptr);
|
2020-12-16 22:51:02 +00:00
|
|
|
|
2020-06-28 02:43:29 +01:00
|
|
|
// Pseudo-metric providing metadata about the WiFi station.
|
2021-07-19 08:58:50 +01:00
|
|
|
WritePromMetricInt32(PSTR("wifi_station_info"), kPromMetricGauge, 1,
|
|
|
|
PSTR("bssid"), WiFi.BSSIDstr().c_str(),
|
|
|
|
PSTR("ssid"), WiFi.SSID().c_str(),
|
|
|
|
nullptr);
|
2020-06-28 02:43:29 +01:00
|
|
|
|
|
|
|
// Wi-Fi Signal strength
|
2021-07-19 08:58:50 +01:00
|
|
|
WritePromMetricInt32(PSTR("wifi_station_signal_dbm"), kPromMetricGauge, WiFi.RSSI(),
|
|
|
|
PSTR("mac_address"), WiFi.BSSIDstr().c_str(),
|
|
|
|
nullptr);
|
2020-06-28 02:43:29 +01:00
|
|
|
|
2020-12-16 22:51:02 +00:00
|
|
|
if (!isnan(TasmotaGlobal.temperature_celsius)) {
|
2021-07-19 08:58:50 +01:00
|
|
|
WritePromMetricDec(PSTR("global_temperature_celsius"), kPromMetricGauge,
|
|
|
|
TasmotaGlobal.temperature_celsius, Settings->flag2.temperature_resolution,
|
|
|
|
nullptr);
|
2020-01-01 16:17:10 +00:00
|
|
|
}
|
2021-07-19 08:58:50 +01:00
|
|
|
|
2020-12-16 22:51:02 +00:00
|
|
|
if (TasmotaGlobal.humidity != 0) {
|
2021-07-19 08:58:50 +01:00
|
|
|
WritePromMetricDec(PSTR("global_humidity_percentage"), kPromMetricGauge,
|
|
|
|
TasmotaGlobal.humidity, Settings->flag2.humidity_resolution,
|
|
|
|
nullptr);
|
2020-01-01 16:17:10 +00:00
|
|
|
}
|
2021-07-19 08:58:50 +01:00
|
|
|
|
2020-12-16 22:51:02 +00:00
|
|
|
if (TasmotaGlobal.pressure_hpa != 0) {
|
2021-07-19 08:58:50 +01:00
|
|
|
WritePromMetricDec(PSTR("global_pressure_hpa"), kPromMetricGauge,
|
|
|
|
TasmotaGlobal.pressure_hpa, Settings->flag2.pressure_resolution,
|
|
|
|
nullptr);
|
2020-01-01 16:17:10 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 12:09:55 +01:00
|
|
|
WritePromMemoryMetrics(PSTR("heap"),
|
2021-07-19 08:58:50 +01:00
|
|
|
#ifdef ESP32
|
2021-07-19 12:09:55 +01:00
|
|
|
ESP.getHeapSize(),
|
|
|
|
#else
|
|
|
|
kPromMemoryUnknown,
|
|
|
|
#endif
|
|
|
|
ESP_getFreeHeap(),
|
|
|
|
#ifdef ESP32
|
|
|
|
ESP_getMaxAllocHeap()
|
|
|
|
#else
|
|
|
|
kPromMemoryUnknown
|
|
|
|
#endif
|
|
|
|
);
|
2021-07-19 08:58:50 +01:00
|
|
|
|
2021-07-19 12:09:55 +01:00
|
|
|
#ifdef ESP32
|
2021-07-19 08:58:50 +01:00
|
|
|
if (UsePSRAM()) {
|
2021-07-19 12:09:55 +01:00
|
|
|
WritePromMemoryMetrics(PSTR("psram"), ESP.getPsramSize(),
|
|
|
|
ESP.getFreePsram(), ESP.getMaxAllocPsram());
|
2021-07-19 08:58:50 +01:00
|
|
|
}
|
2021-07-19 12:09:55 +01:00
|
|
|
#endif
|
2021-04-29 09:20:05 +01:00
|
|
|
|
2020-01-01 16:17:10 +00:00
|
|
|
#ifdef USE_ENERGY_SENSOR
|
2021-07-19 08:58:50 +01:00
|
|
|
WritePromMetricDec(PSTR("energy_voltage_volts"),
|
2021-08-08 15:57:54 +01:00
|
|
|
kPromMetricGauge,
|
2021-07-19 08:58:50 +01:00
|
|
|
Energy.voltage[0], Settings->flag2.voltage_resolution, nullptr);
|
|
|
|
WritePromMetricDec(PSTR("energy_current_amperes"),
|
2021-08-08 15:57:54 +01:00
|
|
|
kPromMetricGauge,
|
2021-07-19 08:58:50 +01:00
|
|
|
Energy.current[0], Settings->flag2.current_resolution, nullptr);
|
|
|
|
WritePromMetricDec(PSTR("energy_power_active_watts"),
|
2021-08-08 15:57:54 +01:00
|
|
|
kPromMetricGauge,
|
2021-07-19 08:58:50 +01:00
|
|
|
Energy.active_power[0], Settings->flag2.wattage_resolution, nullptr);
|
|
|
|
WritePromMetricDec(PSTR("energy_power_kilowatts_daily"),
|
2021-08-08 15:57:54 +01:00
|
|
|
kPromMetricCounter,
|
2021-09-29 14:33:58 +01:00
|
|
|
Energy.daily_sum, Settings->flag2.energy_resolution, nullptr);
|
2021-07-19 08:58:50 +01:00
|
|
|
WritePromMetricDec(PSTR("energy_power_kilowatts_total"),
|
2021-08-08 15:57:54 +01:00
|
|
|
kPromMetricCounter,
|
2021-09-29 14:33:58 +01:00
|
|
|
Energy.total_sum, Settings->flag2.energy_resolution, nullptr);
|
2020-01-01 16:17:10 +00:00
|
|
|
#endif
|
|
|
|
|
2020-12-16 22:51:02 +00:00
|
|
|
for (uint32_t device = 0; device < TasmotaGlobal.devices_present; device++) {
|
2020-12-12 09:35:57 +00:00
|
|
|
power_t mask = 1 << device;
|
2021-07-19 08:58:50 +01:00
|
|
|
snprintf_P(namebuf, sizeof(namebuf), PSTR("relay%d_state"), device + 1);
|
2021-08-08 15:57:54 +01:00
|
|
|
WritePromMetricInt32(namebuf, kPromMetricGauge,
|
2021-07-19 08:58:50 +01:00
|
|
|
(TasmotaGlobal.power & mask), nullptr);
|
2020-12-12 09:35:57 +00:00
|
|
|
}
|
|
|
|
|
2020-10-30 11:29:48 +00:00
|
|
|
ResponseClear();
|
2020-12-16 22:58:11 +00:00
|
|
|
MqttShowSensor(); //Pull sensor data
|
2021-08-15 16:26:32 +01:00
|
|
|
String jsonStr = ResponseData();
|
2020-12-16 22:39:33 +00:00
|
|
|
JsonParser parser((char *)jsonStr.c_str());
|
|
|
|
JsonParserObject root = parser.getRootObject();
|
2021-07-11 18:51:46 +01:00
|
|
|
if (root) { // did JSON parsing succeed?
|
2020-12-24 11:37:59 +00:00
|
|
|
for (auto key1 : root) {
|
2020-12-16 22:39:33 +00:00
|
|
|
JsonParserToken value1 = key1.getValue();
|
2020-12-24 11:37:59 +00:00
|
|
|
if (value1.isObject()) {
|
2020-12-16 22:39:33 +00:00
|
|
|
JsonParserObject Object2 = value1.getObject();
|
2020-12-24 11:37:59 +00:00
|
|
|
for (auto key2 : Object2) {
|
2020-12-16 22:39:33 +00:00
|
|
|
JsonParserToken value2 = key2.getValue();
|
2020-12-24 11:37:59 +00:00
|
|
|
if (value2.isObject()) {
|
2020-12-16 22:39:33 +00:00
|
|
|
JsonParserObject Object3 = value2.getObject();
|
2020-12-24 11:37:59 +00:00
|
|
|
for (auto key3 : Object3) {
|
2020-12-16 22:39:33 +00:00
|
|
|
const char *value = key3.getValue().getStr(nullptr);
|
2020-12-24 11:37:59 +00:00
|
|
|
if (value != nullptr && isdigit(value[0])) {
|
|
|
|
String sensor = FormatMetricName(key2.getStr());
|
|
|
|
String type = FormatMetricName(key3.getStr());
|
2021-07-19 08:58:50 +01:00
|
|
|
|
|
|
|
snprintf_P(namebuf, sizeof(namebuf), PSTR("sensors_%s_%s"),
|
|
|
|
type.c_str(), UnitfromType(type.c_str()));
|
|
|
|
WritePromMetricStr(namebuf, kPromMetricGauge, value,
|
|
|
|
PSTR("sensor"), sensor.c_str(),
|
|
|
|
nullptr);
|
2020-12-16 22:39:33 +00:00
|
|
|
}
|
|
|
|
}
|
2020-12-24 11:37:59 +00:00
|
|
|
} else {
|
2020-12-16 22:39:33 +00:00
|
|
|
const char *value = value2.getStr(nullptr);
|
2020-12-24 11:37:59 +00:00
|
|
|
if (value != nullptr && isdigit(value[0])) {
|
|
|
|
String sensor = FormatMetricName(key1.getStr());
|
|
|
|
String type = FormatMetricName(key2.getStr());
|
2021-07-11 18:51:46 +01:00
|
|
|
if (strcmp(type.c_str(), "totalstarttime") != 0) { // this metric causes Prometheus of fail
|
2021-07-19 08:58:50 +01:00
|
|
|
snprintf_P(namebuf, sizeof(namebuf), PSTR("sensors_%s_%s"),
|
|
|
|
type.c_str(), UnitfromType(type.c_str()));
|
|
|
|
|
2021-04-28 17:58:19 +01:00
|
|
|
if (strcmp(type.c_str(), "id") == 0) { // this metric is NaN, so convert it to a label, see Wi-Fi metrics above
|
2021-07-19 08:58:50 +01:00
|
|
|
WritePromMetricInt32(namebuf, kPromMetricGauge, 1,
|
|
|
|
PSTR("sensor"), sensor.c_str(),
|
|
|
|
PSTR("id"), value,
|
|
|
|
nullptr);
|
2021-04-28 17:58:19 +01:00
|
|
|
} else {
|
2021-07-19 08:58:50 +01:00
|
|
|
WritePromMetricStr(namebuf, kPromMetricGauge, value,
|
|
|
|
PSTR("sensor"), sensor.c_str(),
|
|
|
|
nullptr);
|
2021-04-28 17:58:19 +01:00
|
|
|
}
|
2020-12-24 11:37:59 +00:00
|
|
|
}
|
2020-12-16 22:39:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-12-24 11:37:59 +00:00
|
|
|
} else {
|
2020-12-16 22:39:33 +00:00
|
|
|
const char *value = value1.getStr(nullptr);
|
2020-12-24 11:37:59 +00:00
|
|
|
String sensor = FormatMetricName(key1.getStr());
|
2021-07-19 08:58:50 +01:00
|
|
|
|
2020-12-24 11:37:59 +00:00
|
|
|
if (value != nullptr && isdigit(value[0] && strcmp(sensor.c_str(), "time") != 0)) { //remove false 'time' metric
|
2021-07-19 08:58:50 +01:00
|
|
|
WritePromMetricStr(PSTR("sensors"), kPromMetricGauge, value,
|
|
|
|
PSTR("sensor"), sensor.c_str(),
|
|
|
|
nullptr);
|
2020-12-16 22:39:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-02 13:17:49 +00:00
|
|
|
|
2020-01-01 16:17:10 +00:00
|
|
|
WSContentEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************************\
|
|
|
|
* Interface
|
|
|
|
\*********************************************************************************************/
|
|
|
|
|
2020-12-24 11:37:59 +00:00
|
|
|
bool Xsns75(uint8_t function) {
|
2020-01-01 16:17:10 +00:00
|
|
|
bool result = false;
|
|
|
|
|
2020-12-16 22:51:02 +00:00
|
|
|
switch (function) {
|
2020-12-16 22:58:11 +00:00
|
|
|
case FUNC_WEB_ADD_HANDLER:
|
|
|
|
WebServer_on(PSTR("/metrics"), HandleMetrics);
|
|
|
|
break;
|
2020-01-01 16:17:10 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-12-16 22:51:02 +00:00
|
|
|
#endif // USE_PROMETHEUS
|