mirror of https://github.com/arendst/Tasmota.git
Fix JSON bug with setOption108 0
- Fix duplicate code - Fix serial bug when used GPIO13 as TX in - Don't display ID on web interface if not found
This commit is contained in:
parent
b3ea5a353c
commit
8777e33457
|
@ -240,16 +240,6 @@ void DataCallback(struct _ValueList * me, uint8_t flags)
|
|||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TIC: Power %s, now %d"), me->value, (int) Energy.active_power[0]);
|
||||
}
|
||||
|
||||
// Wh total base index (legacy)
|
||||
else if ( ilabel == LABEL_BASE)
|
||||
{
|
||||
uint32_t total = atoi(me->value);
|
||||
if (!Settings.flag4.teleinfo_rawdata) {
|
||||
EnergyUpdateTotal(total/1000.0f, true);
|
||||
}
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TIC: Base:%uWh"), total);
|
||||
}
|
||||
|
||||
// Wh indexes (legacy)
|
||||
else if ( ilabel == LABEL_HCHC || ilabel == LABEL_HCHP || ilabel == LABEL_BASE)
|
||||
{
|
||||
|
@ -261,7 +251,7 @@ void DataCallback(struct _ValueList * me, uint8_t flags)
|
|||
// Base, un seul index
|
||||
if (ilabel == LABEL_BASE) {
|
||||
total = atoi(me->value);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TIC: Total:%u"), total);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TIC: Base:%u"), total);
|
||||
// Heures creuses/pleines calculer total
|
||||
} else {
|
||||
// Heures creuses get heures pleines
|
||||
|
@ -351,15 +341,14 @@ void DataCallback(struct _ValueList * me, uint8_t flags)
|
|||
/* ======================================================================
|
||||
Function: responseDumpTInfo
|
||||
Purpose : add teleinfo values into JSON response
|
||||
Input : -
|
||||
Input : 1st separator space if begining of JSON, else comma
|
||||
Output : -
|
||||
Comments: -
|
||||
====================================================================== */
|
||||
void ResponseAppendTInfo()
|
||||
void ResponseAppendTInfo(char sep)
|
||||
{
|
||||
struct _ValueList * me = tinfo.getList();
|
||||
|
||||
char sep = ' '; // First JSON value separator
|
||||
char * p ;
|
||||
boolean isNumber ;
|
||||
|
||||
|
@ -416,7 +405,7 @@ void NewFrameCallback(struct _ValueList * me)
|
|||
// see setOption108
|
||||
if (Settings.flag4.teleinfo_rawdata) {
|
||||
Response_P(PSTR("{"));
|
||||
ResponseAppendTInfo();
|
||||
ResponseAppendTInfo(' ');
|
||||
ResponseJsonEnd();
|
||||
// Publish adding ADCO serial number into the topic
|
||||
// Need setOption4 to be enabled
|
||||
|
@ -449,8 +438,6 @@ void TInfoInit(void)
|
|||
{
|
||||
int baudrate;
|
||||
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("TIC: inferface saved settings %d bps"), Settings.flag4.teleinfo_baudrate );
|
||||
|
||||
// SetOption102 - Set Baud rate for Teleinfo serial communication (0 = 1200 or 1 = 9600)
|
||||
if (Settings.flag4.teleinfo_baudrate) {
|
||||
baudrate = 9600;
|
||||
|
@ -496,8 +483,9 @@ void TInfoInit(void)
|
|||
// This is a hack, looks like begin does not take into account
|
||||
// the TS_SERIAL_7E1 configuration so on ESP8266 this is
|
||||
// working only on Serial RX pin (Hardware Serial) for now
|
||||
SetSerialConfig(TS_SERIAL_7E1);
|
||||
TInfoSerial->setTimeout(TINFO_READ_TIMEOUT);
|
||||
|
||||
//SetSerialConfig(TS_SERIAL_7E1);
|
||||
//TInfoSerial->setTimeout(TINFO_READ_TIMEOUT);
|
||||
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("TIC: using hardware serial"));
|
||||
} else {
|
||||
|
@ -542,7 +530,7 @@ void TInfoEvery250ms(void)
|
|||
// get char
|
||||
c = TInfoSerial->read();
|
||||
// data processing
|
||||
tinfo.process(c);
|
||||
tinfo.process(c & 0x7F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -580,7 +568,7 @@ void TInfoShow(bool json)
|
|||
|
||||
// add teleinfo full frame only if no teleinfo raw data setup
|
||||
if (!Settings.flag4.teleinfo_rawdata) {
|
||||
ResponseAppendTInfo();
|
||||
ResponseAppendTInfo(',');
|
||||
}
|
||||
|
||||
|
||||
|
@ -635,8 +623,10 @@ void TInfoShow(bool json)
|
|||
}
|
||||
}
|
||||
|
||||
// Serial number ADCO or ADSC
|
||||
WSContentSend_PD(HTTP_ENERGY_ID_TELEINFO, serialNumber);
|
||||
// Serial number ADCO or ADSC if found
|
||||
if (*serialNumber) {
|
||||
WSContentSend_PD(HTTP_ENERGY_ID_TELEINFO, serialNumber);
|
||||
}
|
||||
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue