mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-02-09 02:55:45 +00:00
add dht to tas json
This commit is contained in:
@ -290,6 +290,26 @@ static int http_tasmota_json_SENSOR(void* request, jsonCb_t printer) {
|
||||
// close ENERGY block
|
||||
printer(request, "},");
|
||||
}
|
||||
for (int i = 0; i < PLATFORM_GPIO_MAX; i++) {
|
||||
int role = PIN_GetPinRoleForPinIndex(i);
|
||||
if (role != IOR_DHT11 && role != IOR_DHT12 && role != IOR_DHT21 && role != IOR_DHT22)
|
||||
continue;
|
||||
channel_1 = g_cfg.pins.channels[i];
|
||||
channel_2 = g_cfg.pins.channels2[i];
|
||||
|
||||
chan_val1 = CHANNEL_GetFloat(channel_1) / 10.0f;
|
||||
chan_val2 = CHANNEL_GetFloat(channel_2);
|
||||
|
||||
// writer header
|
||||
// TODO - index?
|
||||
printer(request, "\"DHT\":");
|
||||
// following check will clear NaN values
|
||||
printer(request, "{");
|
||||
printer(request, "\"Temperature\": %.1f,", chan_val1);
|
||||
printer(request, "\"Humidity\": %.0f", chan_val2);
|
||||
// close ENERGY block
|
||||
printer(request, "},");
|
||||
}
|
||||
if (DRV_IsRunning("SGP")) {
|
||||
g_pin_1 = PIN_FindPinIndexForRole(IOR_SGP_DAT, g_pin_1);
|
||||
channel_1 = g_cfg.pins.channels[g_pin_1];
|
||||
@ -340,7 +360,15 @@ static int http_tasmota_json_status_SNS(void* request, jsonCb_t printer, bool bA
|
||||
printer(request, "\"ENERGY\":");
|
||||
http_tasmota_json_ENERGY(request, printer);
|
||||
}
|
||||
if (DRV_IsSensor()) {
|
||||
bool bHasAnyDHT = false;
|
||||
for (int i = 0; i < PLATFORM_GPIO_MAX; i++) {
|
||||
int role = PIN_GetPinRoleForPinIndex(i);
|
||||
if (role != IOR_DHT11 && role != IOR_DHT12 && role != IOR_DHT21 && role != IOR_DHT22)
|
||||
continue;
|
||||
bHasAnyDHT = true;
|
||||
break;
|
||||
}
|
||||
if (DRV_IsSensor() || bHasAnyDHT) {
|
||||
http_tasmota_json_SENSOR(request, printer);
|
||||
JSON_PrintKeyValue_String(request, printer, "TempUnit", "C", false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user