mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-02-12 11:15:35 +00:00
add missing json variables for power metering
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
#include <time.h>
|
||||
#include "../driver/drv_ntp.h"
|
||||
#include "../driver/drv_local.h"
|
||||
#include "../driver/drv_bl_shared.h"
|
||||
|
||||
void JSON_PrintKeyValue_String(void* request, jsonCb_t printer, const char *key, const char *value, bool bComma) {
|
||||
printer(request, "\"%s\":\"%s\"", key, value);
|
||||
@ -223,10 +224,11 @@ static int http_tasmota_json_ENERGY(void* request, jsonCb_t printer) {
|
||||
if (OBK_IS_NAN(energy_hour)) {
|
||||
energy_hour = 0;
|
||||
}
|
||||
|
||||
printer(request, "{");
|
||||
printer(request, "\"Power\": %f,", power);
|
||||
printer(request, "\"ApparentPower\": 0,");
|
||||
printer(request, "\"ReactivePower\": 0,");
|
||||
printer(request, "\"ApparentPower\": $f,", g_apparentPower);
|
||||
printer(request, "\"ReactivePower\": %f,", g_reactivePower);
|
||||
printer(request, "\"Factor\":%f,", factor);
|
||||
printer(request, "\"Voltage\":%f,", voltage);
|
||||
printer(request, "\"Current\":%f,", current);
|
||||
@ -298,7 +300,11 @@ static int http_tasmota_json_SENSOR(void* request, jsonCb_t printer) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Test command: http://192.168.0.159/cm?cmnd=STATUS%208
|
||||
// For a device without sensors, it returns (on Tasmota):
|
||||
/*
|
||||
{"StatusSNS":{"Time":"2023-04-10T10:19:55"}}
|
||||
*/
|
||||
static int http_tasmota_json_status_SNS(void* request, jsonCb_t printer, bool bAppendHeader) {
|
||||
char buff[20];
|
||||
|
||||
@ -439,11 +445,13 @@ static int http_tasmota_json_status_TIM(void* request, jsonCb_t printer) {
|
||||
printer(request, "}");
|
||||
return 0;
|
||||
}
|
||||
// Test command: http://192.168.0.159/cm?cmnd=STATUS%202
|
||||
static int http_tasmota_json_status_FWR(void* request, jsonCb_t printer) {
|
||||
|
||||
printer(request, "\"StatusFWR\":{");
|
||||
JSON_PrintKeyValue_String(request, printer, "Version", DEVICENAME_PREFIX_FULL"_"USER_SW_VER, true);
|
||||
JSON_PrintKeyValue_String(request, printer, "BuildDateTime", __DATE__" "__TIME__, true);
|
||||
// NOTE: what is this value? It's not a reboot count
|
||||
JSON_PrintKeyValue_Int(request, printer, "Boot", 7, true);
|
||||
JSON_PrintKeyValue_String(request, printer, "Core", "0.0", true);
|
||||
JSON_PrintKeyValue_String(request, printer, "SDK", "obk", true);
|
||||
@ -453,6 +461,7 @@ static int http_tasmota_json_status_FWR(void* request, jsonCb_t printer) {
|
||||
printer(request, "}");
|
||||
return 0;
|
||||
}
|
||||
// Test command: http://192.168.0.159/cm?cmnd=STATUS%204
|
||||
static int http_tasmota_json_status_MEM(void* request, jsonCb_t printer) {
|
||||
printer(request, "\"StatusMEM\":{");
|
||||
JSON_PrintKeyValue_Int(request, printer, "ProgramSize", 616, true);
|
||||
@ -479,7 +488,10 @@ static int http_tasmota_json_status_MEM(void* request, jsonCb_t printer) {
|
||||
printer(request, "}");
|
||||
return 0;
|
||||
}
|
||||
// Test command: http://192.168.0.159/cm?cmnd=STATUS%205
|
||||
static int http_tasmota_json_status_NET(void* request, jsonCb_t printer) {
|
||||
char tmpMac[16];
|
||||
HAL_GetMACStr(tmpMac);
|
||||
|
||||
printer(request, "\"StatusNET\":{");
|
||||
JSON_PrintKeyValue_String(request, printer, "Hostname", CFG_GetShortDeviceName(), true);
|
||||
@ -488,7 +500,7 @@ static int http_tasmota_json_status_NET(void* request, jsonCb_t printer) {
|
||||
JSON_PrintKeyValue_String(request, printer, "Subnetmask", "255.255.255.0", true);
|
||||
JSON_PrintKeyValue_String(request, printer, "DNSServer1", "192.168.0.1", true);
|
||||
JSON_PrintKeyValue_String(request, printer, "DNSServer2", "0.0.0.0", true);
|
||||
JSON_PrintKeyValue_String(request, printer, "Mac", "10:52:1C:D7:9E:2C", true);
|
||||
JSON_PrintKeyValue_String(request, printer, "Mac", tmpMac, true);
|
||||
JSON_PrintKeyValue_Int(request, printer, "Webserver", 2, true);
|
||||
JSON_PrintKeyValue_Int(request, printer, "HTTP_API", 1, true);
|
||||
JSON_PrintKeyValue_Int(request, printer, "WifiConfig", 4, true);
|
||||
@ -496,6 +508,7 @@ static int http_tasmota_json_status_NET(void* request, jsonCb_t printer) {
|
||||
printer(request, "}");
|
||||
return 0;
|
||||
}
|
||||
// Test command: http://192.168.0.159/cm?cmnd=STATUS%206
|
||||
static int http_tasmota_json_status_MQT(void* request, jsonCb_t printer) {
|
||||
|
||||
printer(request, "\"StatusMQT\":{");
|
||||
@ -631,7 +644,7 @@ static int http_tasmota_json_status_generic(void* request, jsonCb_t printer) {
|
||||
printer(request, ",");
|
||||
|
||||
|
||||
|
||||
// Test command: http://192.168.0.159/cm?cmnd=STATUS%203
|
||||
printer(request, "\"StatusLOG\":{");
|
||||
printer(request, "\"SerialLog\":2,");
|
||||
printer(request, "\"WebLog\":2,");
|
||||
|
||||
Reference in New Issue
Block a user