mirror of https://github.com/arendst/Tasmota.git
commit
82c7ac37e0
|
@ -1915,14 +1915,14 @@ void SML_Immediate_MQTT(const char *mp,uint8_t index,uint8_t mindex) {
|
||||||
|
|
||||||
// web + json interface
|
// web + json interface
|
||||||
void SML_Show(boolean json) {
|
void SML_Show(boolean json) {
|
||||||
int8_t count,mindex,cindex=0;
|
int8_t count, mindex, cindex = 0;
|
||||||
char tpowstr[32];
|
char tpowstr[32];
|
||||||
char name[24];
|
char name[24];
|
||||||
char unit[8];
|
char unit[8];
|
||||||
char jname[24];
|
char jname[24];
|
||||||
int8_t index=0,mid=0;
|
int8_t index=0,mid=0;
|
||||||
char *mp=(char*)meter_p;
|
char *mp=(char*)meter_p;
|
||||||
char *cp,nojson=0;
|
char *cp, nojson = 0;
|
||||||
//char b_mqtt_data[MESSZ];
|
//char b_mqtt_data[MESSZ];
|
||||||
//b_mqtt_data[0]=0;
|
//b_mqtt_data[0]=0;
|
||||||
|
|
||||||
|
@ -1937,9 +1937,9 @@ void SML_Show(boolean json) {
|
||||||
|
|
||||||
if (mindex<0 || mindex>=meters_used) mindex=0;
|
if (mindex<0 || mindex>=meters_used) mindex=0;
|
||||||
if (meter_desc_p[mindex].prefix[0]=='*' && meter_desc_p[mindex].prefix[1]==0) {
|
if (meter_desc_p[mindex].prefix[0]=='*' && meter_desc_p[mindex].prefix[1]==0) {
|
||||||
nojson=1;
|
nojson = 1;
|
||||||
} else {
|
} else {
|
||||||
nojson=0;
|
nojson = 0;
|
||||||
}
|
}
|
||||||
mp+=2;
|
mp+=2;
|
||||||
if (*mp=='=' && *(mp+1)=='h') {
|
if (*mp=='=' && *(mp+1)=='h') {
|
||||||
|
@ -2032,27 +2032,35 @@ void SML_Show(boolean json) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
if (!dvalid[index]) {
|
//if (dvalid[index]) {
|
||||||
nojson = 1;
|
|
||||||
//AddLog(LOG_LEVEL_INFO, PSTR("not yet valid line %d"), index);
|
//AddLog(LOG_LEVEL_INFO, PSTR("not yet valid line %d"), index);
|
||||||
}
|
//}
|
||||||
// json export
|
// json export
|
||||||
if (index==0) {
|
if (index==0) {
|
||||||
//snprintf_P(b_mqtt_data, sizeof(b_mqtt_data), "%s,\"%s\":{\"%s\":%s", b_mqtt_data,meter_desc_p[mindex].prefix,jname,tpowstr);
|
//snprintf_P(b_mqtt_data, sizeof(b_mqtt_data), "%s,\"%s\":{\"%s\":%s", b_mqtt_data,meter_desc_p[mindex].prefix,jname,tpowstr);
|
||||||
if (!nojson) ResponseAppend_P(PSTR(",\"%s\":{\"%s\":%s"),meter_desc_p[mindex].prefix,jname,tpowstr);
|
if (!nojson) {
|
||||||
|
ResponseAppend_P(PSTR(",\"%s\":{\"%s\":%s"),meter_desc_p[mindex].prefix,jname,tpowstr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (lastmind!=mindex) {
|
if (lastmind!=mindex) {
|
||||||
// meter changed, close mqtt
|
// meter changed, close mqtt
|
||||||
//snprintf_P(b_mqtt_data, sizeof(b_mqtt_data), "%s}", b_mqtt_data);
|
//snprintf_P(b_mqtt_data, sizeof(b_mqtt_data), "%s}", b_mqtt_data);
|
||||||
if (!nojson) ResponseAppend_P(PSTR("}"));
|
if (!nojson) {
|
||||||
|
ResponseAppend_P(PSTR("}"));
|
||||||
|
}
|
||||||
// and open new
|
// and open new
|
||||||
//snprintf_P(b_mqtt_data, sizeof(b_mqtt_data), "%s,\"%s\":{\"%s\":%s", b_mqtt_data,meter_desc_p[mindex].prefix,jname,tpowstr);
|
//snprintf_P(b_mqtt_data, sizeof(b_mqtt_data), "%s,\"%s\":{\"%s\":%s", b_mqtt_data,meter_desc_p[mindex].prefix,jname,tpowstr);
|
||||||
if (!nojson) ResponseAppend_P(PSTR(",\"%s\":{\"%s\":%s"),meter_desc_p[mindex].prefix,jname,tpowstr);
|
if (!nojson) {
|
||||||
|
ResponseAppend_P(PSTR(",\"%s\":{\"%s\":%s"),meter_desc_p[mindex].prefix,jname,tpowstr);
|
||||||
|
}
|
||||||
lastmind=mindex;
|
lastmind=mindex;
|
||||||
} else {
|
} else {
|
||||||
//snprintf_P(b_mqtt_data, sizeof(b_mqtt_data), "%s,\"%s\":%s", b_mqtt_data,jname,tpowstr);
|
//snprintf_P(b_mqtt_data, sizeof(b_mqtt_data), "%s,\"%s\":%s", b_mqtt_data,jname,tpowstr);
|
||||||
if (!nojson) ResponseAppend_P(PSTR(",\"%s\":%s"),jname,tpowstr);
|
if (!nojson) {
|
||||||
|
ResponseAppend_P(PSTR(",\"%s\":%s"),jname,tpowstr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2073,7 +2081,9 @@ void SML_Show(boolean json) {
|
||||||
if (json) {
|
if (json) {
|
||||||
//snprintf_P(b_mqtt_data, sizeof(b_mqtt_data), "%s}", b_mqtt_data);
|
//snprintf_P(b_mqtt_data, sizeof(b_mqtt_data), "%s}", b_mqtt_data);
|
||||||
//ResponseAppend_P(PSTR("%s"),b_mqtt_data);
|
//ResponseAppend_P(PSTR("%s"),b_mqtt_data);
|
||||||
if (!nojson) ResponseAppend_P(PSTR("}"));
|
if (!nojson) {
|
||||||
|
ResponseAppend_P(PSTR("}"));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//WSContentSend_PD(PSTR("%s"),b_mqtt_data);
|
//WSContentSend_PD(PSTR("%s"),b_mqtt_data);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue