mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-25 07:17:16 +00:00
Merge pull request #11991 from hallard/teleinfo
Teleinfo fixes and improvements
This commit is contained in:
commit
49201b6acd
@ -17,6 +17,7 @@
|
|||||||
// V2.00 2020-06-11 - Integration into Tasmota
|
// V2.00 2020-06-11 - Integration into Tasmota
|
||||||
// V2.01 2020-08-11 - Merged LibTeleinfo official and Tasmota version
|
// V2.01 2020-08-11 - Merged LibTeleinfo official and Tasmota version
|
||||||
// Added support for new standard mode of linky smart meter
|
// Added support for new standard mode of linky smart meter
|
||||||
|
// V2.02 2021-04-20 - Add label field to overload callback (ADPS)
|
||||||
//
|
//
|
||||||
// All text above must be included in any redistribution.
|
// All text above must be included in any redistribution.
|
||||||
//
|
//
|
||||||
@ -84,7 +85,7 @@ Input : callback function
|
|||||||
Output : -
|
Output : -
|
||||||
Comments: -
|
Comments: -
|
||||||
====================================================================== */
|
====================================================================== */
|
||||||
void TInfo::attachADPS(void (*fn_ADPS)(uint8_t phase))
|
void TInfo::attachADPS(void (*fn_ADPS)(uint8_t phase, char * label))
|
||||||
{
|
{
|
||||||
// indicate the user callback
|
// indicate the user callback
|
||||||
_fn_ADPS = fn_ADPS;
|
_fn_ADPS = fn_ADPS;
|
||||||
@ -759,7 +760,7 @@ void TInfo::customLabel( char * plabel, char * pvalue, uint8_t * pflags)
|
|||||||
|
|
||||||
// Traitement de l'ADPS demandé par le sketch
|
// Traitement de l'ADPS demandé par le sketch
|
||||||
if (_fn_ADPS)
|
if (_fn_ADPS)
|
||||||
_fn_ADPS(phase);
|
_fn_ADPS(phase, plabel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -891,10 +892,14 @@ ValueList * TInfo::checkLine(char * pline)
|
|||||||
// this frame will for sure be updated
|
// this frame will for sure be updated
|
||||||
_frame_updated = true;
|
_frame_updated = true;
|
||||||
|
|
||||||
// Do we need to advertise user callback
|
|
||||||
if (_fn_data)
|
|
||||||
_fn_data(me, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tasmota need to to calulation on Energy Module
|
||||||
|
// So always pass data value even if it's the same than previous value
|
||||||
|
// Do we need to advertise user callback
|
||||||
|
if (_fn_data)
|
||||||
|
_fn_data(me, flags);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -129,7 +129,7 @@ enum _State_e {
|
|||||||
#define TINFO_SGR '\n' // start of group
|
#define TINFO_SGR '\n' // start of group
|
||||||
#define TINFO_EGR '\r' // End of group
|
#define TINFO_EGR '\r' // End of group
|
||||||
|
|
||||||
typedef void (*_fn_ADPS) (uint8_t);
|
typedef void (*_fn_ADPS) (uint8_t, char *);
|
||||||
typedef void (*_fn_data) (ValueList *, uint8_t);
|
typedef void (*_fn_data) (ValueList *, uint8_t);
|
||||||
typedef void (*_fn_new_frame) (ValueList *);
|
typedef void (*_fn_new_frame) (ValueList *);
|
||||||
typedef void (*_fn_updated_frame) (ValueList *);
|
typedef void (*_fn_updated_frame) (ValueList *);
|
||||||
@ -140,7 +140,7 @@ class TInfo
|
|||||||
TInfo();
|
TInfo();
|
||||||
void init(_Mode_e mode); // mode MUST be specified
|
void init(_Mode_e mode); // mode MUST be specified
|
||||||
_State_e process (char c);
|
_State_e process (char c);
|
||||||
void attachADPS(void (*_fn_ADPS)(uint8_t phase));
|
void attachADPS(void (*_fn_ADPS)(uint8_t phase, char * label));
|
||||||
void attachData(void (*_fn_data)(ValueList * valueslist, uint8_t state));
|
void attachData(void (*_fn_data)(ValueList * valueslist, uint8_t state));
|
||||||
void attachNewFrame(void (*_fn_new_frame)(ValueList * valueslist));
|
void attachNewFrame(void (*_fn_new_frame)(ValueList * valueslist));
|
||||||
void attachUpdatedFrame(void (*_fn_updated_frame)(ValueList * valueslist));
|
void attachUpdatedFrame(void (*_fn_updated_frame)(ValueList * valueslist));
|
||||||
@ -169,7 +169,7 @@ class TInfo
|
|||||||
char _separator;
|
char _separator;
|
||||||
uint8_t _recv_idx; // index in receive buffer
|
uint8_t _recv_idx; // index in receive buffer
|
||||||
boolean _frame_updated; // Data on the frame has been updated
|
boolean _frame_updated; // Data on the frame has been updated
|
||||||
void (*_fn_ADPS)(uint8_t phase);
|
void (*_fn_ADPS)(uint8_t phase, char * label);
|
||||||
void (*_fn_data)(ValueList * valueslist, uint8_t state);
|
void (*_fn_data)(ValueList * valueslist, uint8_t state);
|
||||||
void (*_fn_new_frame)(ValueList * valueslist);
|
void (*_fn_new_frame)(ValueList * valueslist);
|
||||||
void (*_fn_updated_frame)(ValueList * valueslist);
|
void (*_fn_updated_frame)(ValueList * valueslist);
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
*
|
*
|
||||||
* Denky ESP32 Teleinfo Template
|
* Denky ESP32 Teleinfo Template
|
||||||
* {"NAME":"Denky (Teleinfo)","GPIO":[1,1,1,1,5664,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1376,1,1,0,0,0,0,1,5632,1,1,1,0,0,1],"FLAG":0,"BASE":1}
|
* {"NAME":"Denky (Teleinfo)","GPIO":[1,1,1,1,5664,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1376,1,1,0,0,0,0,1,5632,1,1,1,0,0,1],"FLAG":0,"BASE":1}
|
||||||
|
* Denky D4 ESP Pico V3 Teleinfo Template
|
||||||
|
* {"NAME":"DenkyD4","GPIO":[32,0,0,0,1,0,0,0,0,1,0,1,0,0,0,0,0,640,608,0,0,450,449,448,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1}
|
||||||
*
|
*
|
||||||
* Denky (aka WifInfo) ESP8266 Teleinfo Template
|
* Denky (aka WifInfo) ESP8266 Teleinfo Template
|
||||||
* {"NAME":"WifInfo v1.0a","GPIO":[17,255,255,255,6,5,255,255,7,210,255,255,255],"FLAG":15,"BASE":18}
|
* {"NAME":"WifInfo v1.0a","GPIO":[17,255,255,255,6,5,255,255,7,210,255,255,255],"FLAG":15,"BASE":18}
|
||||||
@ -120,8 +122,9 @@ enum TInfoLabel{
|
|||||||
LABEL_ADCO, LABEL_ADSC,
|
LABEL_ADCO, LABEL_ADSC,
|
||||||
LABEL_HCHC, LABEL_HCHP, LABEL_EAST, LABEL_EASF01, LABEL_EASF02,
|
LABEL_HCHC, LABEL_HCHP, LABEL_EAST, LABEL_EASF01, LABEL_EASF02,
|
||||||
LABEL_OPTARIF, LABEL_NGTF, LABEL_ISOUSC, LABEL_PREF, LABEL_PTEC, LABEL_LTARF, LABEL_NTARF,
|
LABEL_OPTARIF, LABEL_NGTF, LABEL_ISOUSC, LABEL_PREF, LABEL_PTEC, LABEL_LTARF, LABEL_NTARF,
|
||||||
LABEL_PAPP, LABEL_SINSTS, LABEL_IINST, LABEL_IRMS1, LABEL_TENSION, LABEL_URMS1,
|
LABEL_PAPP, LABEL_SINSTS, LABEL_IINST, LABEL_IINST1, LABEL_IINST2, LABEL_IINST3, LABEL_IRMS1, LABEL_IRMS2, LABEL_IRMS3,
|
||||||
LABEL_IMAX, LABEL_PMAX, LABEL_SMAXSN,
|
LABEL_TENSION, LABEL_URMS1, LABEL_URMS2, LABEL_URMS3,
|
||||||
|
LABEL_IMAX, LABEL_IMAX1, LABEL_IMAX2, LABEL_IMAX3, LABEL_PMAX, LABEL_SMAXSN,
|
||||||
LABEL_DEMAIN,
|
LABEL_DEMAIN,
|
||||||
LABEL_END
|
LABEL_END
|
||||||
};
|
};
|
||||||
@ -130,11 +133,25 @@ const char kLabel[] PROGMEM =
|
|||||||
"|BASE|ADCO|ADSC"
|
"|BASE|ADCO|ADSC"
|
||||||
"|HCHC|HCHP|EAST|EASF01|EASF02"
|
"|HCHC|HCHP|EAST|EASF01|EASF02"
|
||||||
"|OPTARIF|NGTF|ISOUSC|PREF|PTEC|LTARF|NTARF"
|
"|OPTARIF|NGTF|ISOUSC|PREF|PTEC|LTARF|NTARF"
|
||||||
"|PAPP|SINSTS|IINST|IRMS1|TENSION|URMS1"
|
"|PAPP|SINSTS|IINST|IINST1|IINST2|IINST3|IRMS1|IRMS2|IRMS3"
|
||||||
"|IMAX|PMAX|SMAXSN"
|
"|TENSION|URMS1|URMS2|URMS3"
|
||||||
|
"|IMAX|IMAX1|IMAX2|IMAX3|PMAX|SMAXSN"
|
||||||
"|DEMAIN"
|
"|DEMAIN"
|
||||||
;
|
;
|
||||||
|
|
||||||
|
// Blacklisted label from telemetry
|
||||||
|
// Each label shoud be enclosed by pipe
|
||||||
|
const char kLabelBlacklist[]
|
||||||
|
// declared as progmem for ESP8266 just crash and reset on strstr()
|
||||||
|
#ifndef ESP8266
|
||||||
|
PROGMEM
|
||||||
|
#endif
|
||||||
|
=
|
||||||
|
"|PJOURF+1"
|
||||||
|
"|MSG1"
|
||||||
|
"|"
|
||||||
|
;
|
||||||
|
|
||||||
#define TELEINFO_SERIAL_BUFFER_STANDARD 512 // Receive buffer size for Standard mode
|
#define TELEINFO_SERIAL_BUFFER_STANDARD 512 // Receive buffer size for Standard mode
|
||||||
#define TELEINFO_SERIAL_BUFFER_HISTORIQUE 512 // Receive buffer size for Legacy mode
|
#define TELEINFO_SERIAL_BUFFER_HISTORIQUE 512 // Receive buffer size for Legacy mode
|
||||||
#define TELEINFO_PROCESS_BUFFER 32 // Local processing buffer
|
#define TELEINFO_PROCESS_BUFFER 32 // Local processing buffer
|
||||||
@ -142,8 +159,10 @@ const char kLabel[] PROGMEM =
|
|||||||
TInfo tinfo; // Teleinfo object
|
TInfo tinfo; // Teleinfo object
|
||||||
TasmotaSerial *TInfoSerial = nullptr;
|
TasmotaSerial *TInfoSerial = nullptr;
|
||||||
_Mode_e tinfo_mode = TINFO_MODE_HISTORIQUE;
|
_Mode_e tinfo_mode = TINFO_MODE_HISTORIQUE;
|
||||||
|
uint8_t tic_rx_pin = NOT_A_PIN;
|
||||||
char serialNumber[13] = ""; // Serial number is 12 char long
|
char serialNumber[13] = ""; // Serial number is 12 char long
|
||||||
bool tinfo_found = false;
|
bool tinfo_found = false;
|
||||||
|
int serial_buffer_size;
|
||||||
int contrat;
|
int contrat;
|
||||||
int tarif;
|
int tarif;
|
||||||
int isousc;
|
int isousc;
|
||||||
@ -175,11 +194,12 @@ Input : phase number
|
|||||||
1 for ADIR1 triphase
|
1 for ADIR1 triphase
|
||||||
2 for ADIR2 triphase
|
2 for ADIR2 triphase
|
||||||
3 for ADIR3 triphase
|
3 for ADIR3 triphase
|
||||||
|
label (different on Normal, 3 phases, historique or standard)
|
||||||
Output : -
|
Output : -
|
||||||
Comments: should have been initialised with a
|
Comments: should have been initialised with a
|
||||||
tinfo.attachADPSCallback(ADPSCallback())
|
tinfo.attachADPSCallback(ADPSCallback())
|
||||||
====================================================================== */
|
====================================================================== */
|
||||||
void ADPSCallback(uint8_t phase)
|
void ADPSCallback(uint8_t phase, char * label)
|
||||||
{
|
{
|
||||||
// n = phase number 1 to 3
|
// n = phase number 1 to 3
|
||||||
if (phase == 0){
|
if (phase == 0){
|
||||||
@ -187,11 +207,11 @@ void ADPSCallback(uint8_t phase)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Response_P(PSTR("{"));
|
Response_P(PSTR("{"));
|
||||||
ResponseAppend_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("{\"%s\":{\"ADPS\":%i}}"), serialNumber, phase );
|
ResponseAppend_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("\"TIC\":{\"%s\":%i}"), label, phase );
|
||||||
ResponseJsonEnd();
|
ResponseJsonEnd();
|
||||||
|
|
||||||
// Publish adding ADCO serial number into the topic
|
// Publish adding ADCO serial number into the topic
|
||||||
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, serialNumber, false);
|
MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR), false);
|
||||||
|
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("ADPS on phase %d"), phase);
|
AddLog(LOG_LEVEL_INFO, PSTR("ADPS on phase %d"), phase);
|
||||||
}
|
}
|
||||||
@ -209,22 +229,68 @@ void DataCallback(struct _ValueList * me, uint8_t flags)
|
|||||||
char c = ' ';
|
char c = ' ';
|
||||||
int ilabel ;
|
int ilabel ;
|
||||||
|
|
||||||
// Does this value is new or changed?
|
char labelName[17];
|
||||||
if (flags & (TINFO_FLAGS_ADDED | TINFO_FLAGS_UPDATED) ) {
|
// Find the label index
|
||||||
char labelName[16];
|
for ( ilabel = 1 ; ilabel < LABEL_END ; ilabel++) {
|
||||||
// Find the label index
|
GetTextIndexed(labelName, sizeof(labelName), ilabel, kLabel);
|
||||||
for ( ilabel = 1 ; ilabel < LABEL_END ; ilabel++) {
|
if (!strcmp(labelName, me->name)) {
|
||||||
GetTextIndexed(labelName, sizeof(labelName), ilabel, kLabel);
|
break;
|
||||||
if (!strcmp(labelName, me->name)) {
|
}
|
||||||
break;
|
}
|
||||||
|
|
||||||
|
// We found valid label
|
||||||
|
if (ilabel<LABEL_END) {
|
||||||
|
|
||||||
|
// First values that needs to have energy object updated (in all case)
|
||||||
|
// Voltage V (not present on all Smart Meter)
|
||||||
|
if ( ilabel == LABEL_TENSION || ilabel == LABEL_URMS1 || ilabel == LABEL_URMS2 || ilabel == LABEL_URMS3)
|
||||||
|
{
|
||||||
|
Energy.voltage_available = true;
|
||||||
|
float volt = (float) atoi(me->value);
|
||||||
|
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Voltage %s=%s, now %d"), me->name, me->value, (int) volt);
|
||||||
|
|
||||||
|
if ( ilabel == LABEL_URMS2) {
|
||||||
|
Energy.voltage[1] = volt;
|
||||||
|
} else if ( ilabel == LABEL_URMS3) {
|
||||||
|
Energy.voltage[2] = volt;
|
||||||
|
} else {
|
||||||
|
Energy.voltage[0] = volt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & TINFO_FLAGS_ADDED) { c = '#'; }
|
// Current I phase 1 to 3
|
||||||
if (flags & TINFO_FLAGS_UPDATED) { c = '*'; }
|
else if (ilabel == LABEL_IINST
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: [%d]%c %s=%s"), ilabel, c , me->name, me->value);
|
|| ilabel == LABEL_IINST1 || ilabel == LABEL_IRMS1
|
||||||
|
|| ilabel == LABEL_IINST2 || ilabel == LABEL_IRMS2
|
||||||
|
|| ilabel == LABEL_IINST3 || ilabel == LABEL_IRMS3 )
|
||||||
|
{
|
||||||
|
Energy.current_available = true;
|
||||||
|
float current = (float) atoi(me->value);
|
||||||
|
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Current %s=%s, now %d"), me->name, me->value, (int) current);
|
||||||
|
|
||||||
if (ilabel<LABEL_END) {
|
if (ilabel == LABEL_IINST2 || ilabel == LABEL_IRMS2) {
|
||||||
|
Energy.current[1] = current;
|
||||||
|
} else if (ilabel == LABEL_IINST3 || ilabel == LABEL_IRMS3) {
|
||||||
|
Energy.phase_count = 3;
|
||||||
|
Energy.current[2] = current;
|
||||||
|
} else {
|
||||||
|
Energy.current[0] = current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Power P
|
||||||
|
else if (ilabel == LABEL_PAPP || ilabel == LABEL_SINSTS)
|
||||||
|
{
|
||||||
|
Energy.active_power[0] = (float) atoi(me->value);;
|
||||||
|
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Power %s, now %d"), me->value, (int) Energy.active_power[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ok now not so real time values Does this value is new or changed?
|
||||||
|
else if (flags & (TINFO_FLAGS_ADDED | TINFO_FLAGS_UPDATED) ) {
|
||||||
|
|
||||||
|
if (flags & TINFO_FLAGS_ADDED) { c = '#'; }
|
||||||
|
if (flags & TINFO_FLAGS_UPDATED) { c = '*'; }
|
||||||
|
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: [%d]%c %s=%s"), ilabel, c , me->name, me->value);
|
||||||
|
|
||||||
// Current tariff (legacy)
|
// Current tariff (legacy)
|
||||||
if (ilabel == LABEL_PTEC)
|
if (ilabel == LABEL_PTEC)
|
||||||
@ -243,11 +309,11 @@ void DataCallback(struct _ValueList * me, uint8_t flags)
|
|||||||
// Current tariff (standard)
|
// Current tariff (standard)
|
||||||
else if (ilabel == LABEL_LTARF)
|
else if (ilabel == LABEL_LTARF)
|
||||||
{
|
{
|
||||||
if (!strcmp_P(TELEINFO_STD_TARIFF_BASE, me->value)) {
|
if (!strcmp_P(me->value, TELEINFO_STD_TARIFF_BASE)) {
|
||||||
tarif = TARIF_TH;
|
tarif = TARIF_TH;
|
||||||
} else if (!strcmp_P(TELEINFO_STD_TARIFF_HC, me->value)) {
|
} else if (!strcmp_P(me->value, TELEINFO_STD_TARIFF_HC)) {
|
||||||
tarif = TARIF_HC;
|
tarif = TARIF_HC;
|
||||||
} else if (!strcmp_P(TELEINFO_STD_TARIFF_HP, me->value)) {
|
} else if (!strcmp_P(me->value, TELEINFO_STD_TARIFF_HP)) {
|
||||||
tarif = TARIF_HP;
|
tarif = TARIF_HP;
|
||||||
}
|
}
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Tariff name changed, now '%s'"), me->value);
|
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Tariff name changed, now '%s'"), me->value);
|
||||||
@ -260,29 +326,6 @@ void DataCallback(struct _ValueList * me, uint8_t flags)
|
|||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Tariff index changed, now '%d'"), index);
|
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Tariff index changed, now '%d'"), index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Voltage V (not present on all Smart Meter)
|
|
||||||
else if ( ilabel == LABEL_TENSION || ilabel == LABEL_URMS1)
|
|
||||||
{
|
|
||||||
Energy.voltage_available = true;
|
|
||||||
Energy.voltage[0] = (float) atoi(me->value);
|
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Voltage %s, now %d"), me->value, (int) Energy.voltage[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Current I
|
|
||||||
else if (ilabel == LABEL_IINST || ilabel == LABEL_IRMS1)
|
|
||||||
{
|
|
||||||
Energy.current_available = true;
|
|
||||||
Energy.current[0] = (float) atoi(me->value);
|
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Current %s, now %d"), me->value, (int) Energy.current[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Power P
|
|
||||||
else if (ilabel == LABEL_PAPP || ilabel == LABEL_SINSTS)
|
|
||||||
{
|
|
||||||
Energy.active_power[0] = (float) atoi(me->value);;
|
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Power %s, now %d"), me->value, (int) Energy.active_power[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wh indexes (legacy)
|
// Wh indexes (legacy)
|
||||||
else if ( ilabel == LABEL_HCHC || ilabel == LABEL_HCHP || ilabel == LABEL_BASE)
|
else if ( ilabel == LABEL_HCHC || ilabel == LABEL_HCHP || ilabel == LABEL_BASE)
|
||||||
{
|
{
|
||||||
@ -357,9 +400,9 @@ void DataCallback(struct _ValueList * me, uint8_t flags)
|
|||||||
// Contract subscribed (standard is in clear text in value)
|
// Contract subscribed (standard is in clear text in value)
|
||||||
else if (ilabel == LABEL_NGTF)
|
else if (ilabel == LABEL_NGTF)
|
||||||
{
|
{
|
||||||
if (!strcmp_P(TELEINFO_STD_CONTRACT_BASE, me->value)) {
|
if (!strcmp_P(me->value, TELEINFO_STD_CONTRACT_BASE)) {
|
||||||
contrat = CONTRAT_BAS;
|
contrat = CONTRAT_BAS;
|
||||||
} else if (!strcmp_P(TELEINFO_STD_CONTRACT_HCHP, me->value)) {
|
} else if (!strcmp_P(me->value, TELEINFO_STD_CONTRACT_HCHP)) {
|
||||||
contrat = CONTRAT_HC;
|
contrat = CONTRAT_HC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,11 +422,30 @@ void DataCallback(struct _ValueList * me, uint8_t flags)
|
|||||||
strcpy(serialNumber, me->value);
|
strcpy(serialNumber, me->value);
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: %s set to %s"), me->name, serialNumber);
|
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: %s set to %s"), me->name, serialNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ======================================================================
|
||||||
|
Function: isBlacklistedLabel
|
||||||
|
Purpose : check is a label is blacklisted for telemetry data
|
||||||
|
Input : label name
|
||||||
|
Output : true if blacklisted
|
||||||
|
Comments: -
|
||||||
|
====================================================================== */
|
||||||
|
bool isBlacklistedLabel(char * name)
|
||||||
|
{
|
||||||
|
bool bl = false;
|
||||||
|
// return strstr( kLabelBlacklist, name)==nullptr ? false : true;
|
||||||
|
if ( strstr(kLabelBlacklist, name) ) {
|
||||||
|
//if ( strstr("|PJOURF+1|MSG1|ADCO|", name) ) {
|
||||||
|
bl = true;
|
||||||
|
AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: %s is blacklisted"), name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bl;
|
||||||
|
}
|
||||||
|
|
||||||
/* ======================================================================
|
/* ======================================================================
|
||||||
Function: responseDumpTInfo
|
Function: responseDumpTInfo
|
||||||
Purpose : add teleinfo values into JSON response
|
Purpose : add teleinfo values into JSON response
|
||||||
@ -408,39 +470,49 @@ bool ResponseAppendTInfo(char sep, bool all)
|
|||||||
|
|
||||||
if (me->name && me->value && *me->name && *me->value) {
|
if (me->name && me->value && *me->name && *me->value) {
|
||||||
|
|
||||||
// Add values only if we want all data or if data has changed
|
// Does this label blacklisted ?
|
||||||
if (all || ( Settings.teleinfo.raw_report_changed && (me->flags & (TINFO_FLAGS_UPDATED | TINFO_FLAGS_ADDED | TINFO_FLAGS_ALERT) ) ) ) {
|
if (!isBlacklistedLabel(me->name)) {
|
||||||
|
|
||||||
isNumber = true;
|
// Add values only if we want all data or if data has changed
|
||||||
hasValue = true;
|
if (all || ( Settings.teleinfo.raw_report_changed && (me->flags & (TINFO_FLAGS_UPDATED | TINFO_FLAGS_ADDED | TINFO_FLAGS_ALERT) ) ) ) {
|
||||||
p = me->value;
|
|
||||||
|
|
||||||
// Specific treatment serial number don't convert to number later
|
isNumber = true;
|
||||||
if (strcmp(me->name, "ADCO")==0 || strcmp(me->name, "ADSC")==0) {
|
hasValue = true;
|
||||||
isNumber = false;
|
p = me->value;
|
||||||
} else {
|
|
||||||
// check if value is number
|
// Specific treatment serial number don't convert to number later
|
||||||
while (*p && isNumber) {
|
if (strcmp(me->name, "ADCO")==0 || strcmp(me->name, "ADSC")==0) {
|
||||||
if ( *p < '0' || *p > '9' ) {
|
isNumber = false;
|
||||||
isNumber = false;
|
} else {
|
||||||
|
// check if value is number
|
||||||
|
while (*p && isNumber) {
|
||||||
|
if ( *p < '0' || *p > '9' ) {
|
||||||
|
isNumber = false;
|
||||||
|
}
|
||||||
|
p++;
|
||||||
}
|
}
|
||||||
p++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Avoid unneeded space
|
||||||
|
if (sep == ' ') {
|
||||||
|
ResponseAppend_P( PSTR("\"%s\":"), me->name );
|
||||||
|
} else {
|
||||||
|
ResponseAppend_P( PSTR("%c\"%s\":"), sep, me->name );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isNumber) {
|
||||||
|
ResponseAppend_P( PSTR("\"%s\""), me->value );
|
||||||
|
} else {
|
||||||
|
ResponseAppend_P( PSTR("%d"), atoi(me->value));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now JSON separator is needed
|
||||||
|
sep =',';
|
||||||
}
|
}
|
||||||
|
|
||||||
ResponseAppend_P( PSTR("%c\"%s\":"), sep, me->name );
|
|
||||||
|
|
||||||
if (!isNumber) {
|
|
||||||
ResponseAppend_P( PSTR("\"%s\""), me->value );
|
|
||||||
} else {
|
|
||||||
ResponseAppend_P( PSTR("%d"), atoi(me->value));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now JSON separator is needed
|
|
||||||
sep =',';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return hasValue;
|
return hasValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,16 +533,16 @@ void NewFrameCallback(struct _ValueList * me)
|
|||||||
if (Settings.teleinfo.raw_send) {
|
if (Settings.teleinfo.raw_send) {
|
||||||
// Do we need to skip this frame
|
// Do we need to skip this frame
|
||||||
if (raw_skip == 0 ) {
|
if (raw_skip == 0 ) {
|
||||||
Response_P(PSTR("{"));
|
Response_P(PSTR("{\"TIC\":{"));
|
||||||
// send teleinfo full frame or only changed data
|
// send teleinfo full frame or only changed data
|
||||||
bool hasData = ResponseAppendTInfo(' ', Settings.teleinfo.raw_report_changed ? false : true );
|
bool hasData = ResponseAppendTInfo(' ', Settings.teleinfo.raw_report_changed ? false : true );
|
||||||
ResponseJsonEnd();
|
ResponseJsonEndEnd();
|
||||||
|
|
||||||
// Publish adding ADCO serial number into the topic
|
// Publish adding ADCO serial number into the topic
|
||||||
// Need setOption4 to be enabled
|
// Need setOption4 to be enabled
|
||||||
// No need to send empty payload
|
// No need to send empty payload
|
||||||
if (hasData) {
|
if (hasData) {
|
||||||
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, serialNumber, false);
|
MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset frame skip counter (if 0 it's disabled)
|
// Reset frame skip counter (if 0 it's disabled)
|
||||||
@ -490,10 +562,25 @@ Output : -
|
|||||||
Comments: -
|
Comments: -
|
||||||
====================================================================== */
|
====================================================================== */
|
||||||
void TInfoDrvInit(void) {
|
void TInfoDrvInit(void) {
|
||||||
if (PinUsed(GPIO_TELEINFO_RX)) {
|
// If one TInfo RX pin declared use it
|
||||||
TasmotaGlobal.energy_driver = XNRG_15;
|
if (PinUsed(GPIO_TELEINFO_RX)) {
|
||||||
Energy.voltage_available = false;
|
tic_rx_pin = Pin(GPIO_TELEINFO_RX);
|
||||||
}
|
} else {
|
||||||
|
// Case we are on denky V4 board without any TInfo RX pin selected
|
||||||
|
#ifdef ARDUINO_DENKY_PICOV3
|
||||||
|
tic_rx_pin = 8;
|
||||||
|
AddLog(LOG_LEVEL_INFO, PSTR("TIC: Denky D4 board, RX on GPIO%d"), tic_rx_pin);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable teleinfo
|
||||||
|
if (tic_rx_pin != NOT_A_PIN) {
|
||||||
|
TasmotaGlobal.energy_driver = XNRG_15;
|
||||||
|
Energy.voltage_available = false;
|
||||||
|
Energy.phase_count = 1;
|
||||||
|
} else {
|
||||||
|
AddLog(LOG_LEVEL_ERROR, PSTR("TIC: Device has no RX pin"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ======================================================================
|
/* ======================================================================
|
||||||
@ -506,7 +593,6 @@ Comments: -
|
|||||||
void TInfoInit(void)
|
void TInfoInit(void)
|
||||||
{
|
{
|
||||||
int baudrate;
|
int baudrate;
|
||||||
int serial_buffer_size;
|
|
||||||
|
|
||||||
// Deprecated SetOption102 - Set Baud rate for Teleinfo serial communication (0 = 1200 or 1 = 9600)
|
// Deprecated SetOption102 - Set Baud rate for Teleinfo serial communication (0 = 1200 or 1 = 9600)
|
||||||
// now set in bit field TeleinfoCfg
|
// now set in bit field TeleinfoCfg
|
||||||
@ -520,74 +606,70 @@ void TInfoInit(void)
|
|||||||
serial_buffer_size = TELEINFO_SERIAL_BUFFER_HISTORIQUE;
|
serial_buffer_size = TELEINFO_SERIAL_BUFFER_HISTORIQUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AddLog(LOG_LEVEL_INFO, PSTR("TIC: RX on GPIO%d, baudrate %d"), tic_rx_pin, baudrate);
|
||||||
|
|
||||||
if (PinUsed(GPIO_TELEINFO_RX)) {
|
// Enable Teleinfo pin used, control it
|
||||||
int8_t rx_pin = Pin(GPIO_TELEINFO_RX);
|
if (PinUsed(GPIO_TELEINFO_ENABLE)) {
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("TIC: RX on GPIO%d, baudrate %d"), rx_pin, baudrate);
|
int8_t en_pin = Pin(GPIO_TELEINFO_ENABLE);
|
||||||
|
pinMode(en_pin, OUTPUT);
|
||||||
// Enable Teleinfo pin used, control it
|
digitalWrite(en_pin, HIGH);
|
||||||
if (PinUsed(GPIO_TELEINFO_ENABLE)) {
|
AddLog(LOG_LEVEL_INFO, PSTR("TIC: Enable with GPIO%d"), en_pin);
|
||||||
int8_t en_pin = Pin(GPIO_TELEINFO_ENABLE);
|
} else {
|
||||||
pinMode(en_pin, OUTPUT);
|
AddLog(LOG_LEVEL_INFO, PSTR("TIC: always enabled"));
|
||||||
digitalWrite(en_pin, HIGH);
|
}
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("TIC: Enable with GPIO%d"), en_pin);
|
|
||||||
} else {
|
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("TIC: always enabled"));
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
// Allow GPIO3 AND GPIO13 with hardware fallback to 2
|
// Allow GPIO3 AND GPIO13 with hardware fallback to 2
|
||||||
// Set buffer to nnn char to support 250ms loop at 9600 baud
|
// Set buffer to nnn char to support 250ms loop at 9600 baud
|
||||||
TInfoSerial = new TasmotaSerial(rx_pin, -1, 2, 0, serial_buffer_size);
|
TInfoSerial = new TasmotaSerial(tic_rx_pin, -1, 2, 0, serial_buffer_size);
|
||||||
//pinMode(rx_pin, INPUT_PULLUP);
|
//pinMode(rx_pin, INPUT_PULLUP);
|
||||||
#endif // ESP8266
|
#endif // ESP8266
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
// Set buffer to nnn char to support 250ms loop at 9600 baud
|
// Set buffer to nnn char to support 250ms loop at 9600 baud
|
||||||
TInfoSerial = new TasmotaSerial(rx_pin, -1, 1, 0, serial_buffer_size);
|
TInfoSerial = new TasmotaSerial(tic_rx_pin, -1, 1, 0, serial_buffer_size);
|
||||||
#endif // ESP32
|
#endif // ESP32
|
||||||
|
|
||||||
// Trick here even using SERIAL_7E1 or TS_SERIAL_7E1
|
// Trick here even using SERIAL_7E1 or TS_SERIAL_7E1
|
||||||
// this is not working, need to call SetSerialConfig after
|
// this is not working, need to call SetSerialConfig after
|
||||||
if (TInfoSerial->begin(baudrate)) {
|
if (TInfoSerial->begin(baudrate)) {
|
||||||
|
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
if (TInfoSerial->hardwareSerial() ) {
|
if (TInfoSerial->hardwareSerial() ) {
|
||||||
ClaimSerial();
|
ClaimSerial();
|
||||||
|
|
||||||
// This is a hack, looks like begin does not take into account
|
// This is a hack, looks like begin does not take into account
|
||||||
// the TS_SERIAL_7E1 configuration so on ESP8266 this is
|
// the TS_SERIAL_7E1 configuration so on ESP8266 this is
|
||||||
// working only on Serial RX pin (Hardware Serial) for now
|
// working only on Serial RX pin (Hardware Serial) for now
|
||||||
|
|
||||||
//SetSerialConfig(TS_SERIAL_7E1);
|
//SetSerialConfig(TS_SERIAL_7E1);
|
||||||
//TInfoSerial->setTimeout(TINFO_READ_TIMEOUT);
|
//TInfoSerial->setTimeout(TINFO_READ_TIMEOUT);
|
||||||
|
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("TIC: using hardware serial"));
|
AddLog(LOG_LEVEL_INFO, PSTR("TIC: using hardware serial"));
|
||||||
} else {
|
} else {
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("TIC: using software serial"));
|
AddLog(LOG_LEVEL_INFO, PSTR("TIC: using software serial"));
|
||||||
}
|
}
|
||||||
#endif // ESP8266
|
#endif // ESP8266
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
SetSerialConfig(TS_SERIAL_7E1);
|
SetSerialConfig(TS_SERIAL_7E1);
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("TIC: using ESP32 hardware serial"));
|
AddLog(LOG_LEVEL_INFO, PSTR("TIC: using ESP32 hardware serial"));
|
||||||
#endif // ESP32
|
#endif // ESP32
|
||||||
// Init teleinfo
|
// Init teleinfo
|
||||||
tinfo.init(tinfo_mode);
|
tinfo.init(tinfo_mode);
|
||||||
// Attach needed callbacks
|
// Attach needed callbacks
|
||||||
tinfo.attachADPS(ADPSCallback);
|
tinfo.attachADPS(ADPSCallback);
|
||||||
tinfo.attachData(DataCallback);
|
tinfo.attachData(DataCallback);
|
||||||
tinfo.attachNewFrame(NewFrameCallback);
|
tinfo.attachNewFrame(NewFrameCallback);
|
||||||
tinfo_found = true;
|
tinfo_found = true;
|
||||||
|
|
||||||
if (Settings.teleinfo.raw_send) {
|
if (Settings.teleinfo.raw_send) {
|
||||||
raw_skip = Settings.teleinfo.raw_skip;
|
raw_skip = Settings.teleinfo.raw_skip;
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("TIC: Raw mode enabled"));
|
AddLog(LOG_LEVEL_INFO, PSTR("TIC: Raw mode enabled"));
|
||||||
if (raw_skip) {
|
if (raw_skip) {
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("TIC: Sending only one frame over %d "), raw_skip+1);
|
AddLog(LOG_LEVEL_INFO, PSTR("TIC: Sending only one frame over %d "), raw_skip+1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("TIC: Ready"));
|
|
||||||
}
|
}
|
||||||
|
AddLog(LOG_LEVEL_INFO, PSTR("TIC: Ready"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -761,7 +843,6 @@ Output : -
|
|||||||
Comments: -
|
Comments: -
|
||||||
====================================================================== */
|
====================================================================== */
|
||||||
//#define MEASURE_PERF // Define to enable performance measurments
|
//#define MEASURE_PERF // Define to enable performance measurments
|
||||||
|
|
||||||
void TInfoProcess(void)
|
void TInfoProcess(void)
|
||||||
{
|
{
|
||||||
static char buff[TELEINFO_PROCESS_BUFFER];
|
static char buff[TELEINFO_PROCESS_BUFFER];
|
||||||
@ -808,12 +889,18 @@ Comments: -
|
|||||||
const char HTTP_ENERGY_ID_TELEINFO[] PROGMEM = "{s}ID{m}%s{e}" ;
|
const char HTTP_ENERGY_ID_TELEINFO[] PROGMEM = "{s}ID{m}%s{e}" ;
|
||||||
const char HTTP_ENERGY_INDEX_TELEINFO[] PROGMEM = "{s}%s{m}%s " D_UNIT_WATTHOUR "{e}" ;
|
const char HTTP_ENERGY_INDEX_TELEINFO[] PROGMEM = "{s}%s{m}%s " D_UNIT_WATTHOUR "{e}" ;
|
||||||
const char HTTP_ENERGY_PAPP_TELEINFO[] PROGMEM = "{s}" D_POWERUSAGE "{m}%d " D_UNIT_WATT "{e}" ;
|
const char HTTP_ENERGY_PAPP_TELEINFO[] PROGMEM = "{s}" D_POWERUSAGE "{m}%d " D_UNIT_WATT "{e}" ;
|
||||||
const char HTTP_ENERGY_IINST_TELEINFO[] PROGMEM = "{s}" D_CURRENT "{m}%d " D_UNIT_AMPERE "{e}" ;
|
//const char HTTP_ENERGY_IINST_TELEINFO[] PROGMEM = "{s}" D_CURRENT "%s{m}%d " D_UNIT_AMPERE "{e}" ;
|
||||||
const char HTTP_ENERGY_TARIF_TELEINFO[] PROGMEM = "{s}" D_CURRENT_TARIFF "{m}Heures %s{e}" ;
|
const char HTTP_ENERGY_TARIF_TELEINFO[] PROGMEM = "{s}" D_CURRENT_TARIFF "{m}Heures %s{e}" ;
|
||||||
const char HTTP_ENERGY_CONTRAT_TELEINFO[] PROGMEM = "{s}" D_CONTRACT "{m}%s %d" D_UNIT_AMPERE "{e}" ;
|
const char HTTP_ENERGY_CONTRAT_TELEINFO[] PROGMEM = "{s}" D_CONTRACT "{m}%s %d" D_UNIT_AMPERE "{e}" ;
|
||||||
const char HTTP_ENERGY_LOAD_TELEINFO[] PROGMEM = "{s}" D_POWER_LOAD "{m}%d" D_UNIT_PERCENT "{e}" ;
|
const char HTTP_ENERGY_LOAD_TELEINFO[] PROGMEM = "{s}" D_POWER_LOAD "{m}%d" D_UNIT_PERCENT "{e}" ;
|
||||||
const char HTTP_ENERGY_IMAX_TELEINFO[] PROGMEM = "{s}" D_MAX_CURRENT "{m}%d" D_UNIT_AMPERE "{e}" ;
|
const char HTTP_ENERGY_IMAX_TELEINFO[] PROGMEM = "{s}" D_MAX_CURRENT "{m}%d" D_UNIT_AMPERE "{e}" ;
|
||||||
|
const char HTTP_ENERGY_IMAX3_TELEINFO[] PROGMEM = "{s}" D_MAX_CURRENT "{m}%d / %d / %d " D_UNIT_AMPERE "{e}" ;
|
||||||
const char HTTP_ENERGY_PMAX_TELEINFO[] PROGMEM = "{s}" D_MAX_POWER "{m}%d" D_UNIT_WATT "{e}" ;
|
const char HTTP_ENERGY_PMAX_TELEINFO[] PROGMEM = "{s}" D_MAX_POWER "{m}%d" D_UNIT_WATT "{e}" ;
|
||||||
|
const char HTTP_ENERGY_PMAX3_TELEINFO[] PROGMEM = "{s}" D_MAX_POWER "{m}%d / %d / %d " D_UNIT_WATT "{e}" ;
|
||||||
|
const char HTTP_ENERGY_LOAD_BAR[] PROGMEM = "<tr><div style='margin:4px;padding:0px;background-color:#ddd;border-radius:4px;'>"
|
||||||
|
"<div style='font-size:0.75rem;font-weight:bold;padding:0px;text-align:center;border:1px solid #bbb;border-radius:4px;color:#444;background-color:%s;width:%d%%;'>"
|
||||||
|
"%d%%</div>"
|
||||||
|
"</div></tr>";
|
||||||
#endif // USE_WEBSERVER
|
#endif // USE_WEBSERVER
|
||||||
|
|
||||||
void TInfoShow(bool json)
|
void TInfoShow(bool json)
|
||||||
@ -823,7 +910,7 @@ void TInfoShow(bool json)
|
|||||||
// Just add the raw label/values of the teleinfo frame
|
// Just add the raw label/values of the teleinfo frame
|
||||||
if (json)
|
if (json)
|
||||||
{
|
{
|
||||||
// Calculated values
|
// Add new value (not part of TIC JSON Object)
|
||||||
if (isousc) {
|
if (isousc) {
|
||||||
ResponseAppend_P(PSTR(",\"Load\":%d"),(int) ((Energy.current[0]*100.0f) / isousc));
|
ResponseAppend_P(PSTR(",\"Load\":%d"),(int) ((Energy.current[0]*100.0f) / isousc));
|
||||||
}
|
}
|
||||||
@ -836,70 +923,100 @@ void TInfoShow(bool json)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
char name[33];
|
char name[33];
|
||||||
char value[33];
|
char value[33];
|
||||||
|
int percent;
|
||||||
|
|
||||||
|
if (isousc) {
|
||||||
|
uint8_t hue;
|
||||||
|
uint8_t red, green, blue;
|
||||||
|
char phase_color[8];
|
||||||
|
|
||||||
|
for (int i=0; i<Energy.phase_count ; i++ ) {
|
||||||
|
percent = (int) ((Energy.current[i]*100.0f) / isousc) ;
|
||||||
|
if (percent > 100) {
|
||||||
|
percent = 100;
|
||||||
|
}
|
||||||
|
// Gradiant from green (low load), yellow, orange and ending red (high load)
|
||||||
|
// Hue from 128 (green) to 0 (red) so reversed from percent
|
||||||
|
hue = changeUIntScale(100-percent, 0, 100, 0, 128);
|
||||||
|
HsToRgb(hue, 128, &red, &green, &blue);
|
||||||
|
snprintf_P(phase_color, sizeof(phase_color), PSTR("#%02X%02X%02X"), red, green, blue);
|
||||||
|
WSContentSend_P(HTTP_ENERGY_LOAD_BAR, phase_color, percent, percent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (tinfo_mode==TINFO_MODE_HISTORIQUE ) {
|
if (tinfo_mode==TINFO_MODE_HISTORIQUE ) {
|
||||||
if (getValueFromLabelIndex(LABEL_BASE, value) ) {
|
if (getValueFromLabelIndex(LABEL_BASE, value) ) {
|
||||||
GetTextIndexed(name, sizeof(name), LABEL_BASE, kLabel);
|
GetTextIndexed(name, sizeof(name), LABEL_BASE, kLabel);
|
||||||
WSContentSend_PD(HTTP_ENERGY_INDEX_TELEINFO, name, value);
|
WSContentSend_P(HTTP_ENERGY_INDEX_TELEINFO, name, value);
|
||||||
}
|
}
|
||||||
if (getValueFromLabelIndex(LABEL_HCHC, value) ) {
|
if (getValueFromLabelIndex(LABEL_HCHC, value) ) {
|
||||||
GetTextIndexed(name, sizeof(name), LABEL_HCHC, kLabel);
|
GetTextIndexed(name, sizeof(name), LABEL_HCHC, kLabel);
|
||||||
WSContentSend_PD(HTTP_ENERGY_INDEX_TELEINFO, name, value);
|
WSContentSend_P(HTTP_ENERGY_INDEX_TELEINFO, name, value);
|
||||||
}
|
}
|
||||||
if (getValueFromLabelIndex(LABEL_HCHP, value) ) {
|
if (getValueFromLabelIndex(LABEL_HCHP, value) ) {
|
||||||
GetTextIndexed(name, sizeof(name), LABEL_HCHP, kLabel);
|
GetTextIndexed(name, sizeof(name), LABEL_HCHP, kLabel);
|
||||||
WSContentSend_PD(HTTP_ENERGY_INDEX_TELEINFO, name, value);
|
WSContentSend_P(HTTP_ENERGY_INDEX_TELEINFO, name, value);
|
||||||
}
|
}
|
||||||
if (getValueFromLabelIndex(LABEL_IMAX, value) ) {
|
if (Energy.phase_count==3) {
|
||||||
WSContentSend_PD(HTTP_ENERGY_IMAX_TELEINFO, atoi(value));
|
int imax[3];
|
||||||
|
for (int i=LABEL_IMAX1; i<=LABEL_IMAX3; i++) {
|
||||||
|
if (getValueFromLabelIndex(i, value) ) {
|
||||||
|
imax[i-LABEL_IMAX1] = atoi(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WSContentSend_P(HTTP_ENERGY_IMAX3_TELEINFO, imax[0], imax[1], imax[2]);
|
||||||
|
} else {
|
||||||
|
if (getValueFromLabelIndex(LABEL_IMAX, value) ) {
|
||||||
|
WSContentSend_P(HTTP_ENERGY_IMAX_TELEINFO, atoi(value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (getValueFromLabelIndex(LABEL_PMAX, value) ) {
|
if (getValueFromLabelIndex(LABEL_PMAX, value) ) {
|
||||||
WSContentSend_PD(HTTP_ENERGY_PMAX_TELEINFO, atoi(value));
|
WSContentSend_P(HTTP_ENERGY_PMAX_TELEINFO, atoi(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tarif) {
|
if (tarif) {
|
||||||
GetTextIndexed(name, sizeof(name), tarif-1, kTarifName);
|
GetTextIndexed(name, sizeof(name), tarif-1, kTarifName);
|
||||||
WSContentSend_PD(HTTP_ENERGY_TARIF_TELEINFO, name);
|
WSContentSend_P(HTTP_ENERGY_TARIF_TELEINFO, name);
|
||||||
}
|
}
|
||||||
if (contrat && isousc) {
|
if (contrat && isousc) {
|
||||||
int percent = (int) ((Energy.current[0]*100.0f) / isousc) ;
|
int percent = (int) ((Energy.current[0]*100.0f) / isousc) ;
|
||||||
GetTextIndexed(name, sizeof(name), contrat, kContratName);
|
GetTextIndexed(name, sizeof(name), contrat, kContratName);
|
||||||
WSContentSend_PD(HTTP_ENERGY_CONTRAT_TELEINFO, name, isousc);
|
WSContentSend_P(HTTP_ENERGY_CONTRAT_TELEINFO, name, isousc);
|
||||||
WSContentSend_PD(HTTP_ENERGY_LOAD_TELEINFO, percent);
|
//WSContentSend_P(HTTP_ENERGY_LOAD_TELEINFO, percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (tinfo_mode==TINFO_MODE_STANDARD ) {
|
} else if (tinfo_mode==TINFO_MODE_STANDARD ) {
|
||||||
if (getValueFromLabelIndex(LABEL_EAST, value) ) {
|
if (getValueFromLabelIndex(LABEL_EAST, value) ) {
|
||||||
GetTextIndexed(name, sizeof(name), LABEL_EAST, kLabel);
|
GetTextIndexed(name, sizeof(name), LABEL_EAST, kLabel);
|
||||||
WSContentSend_PD(HTTP_ENERGY_INDEX_TELEINFO, name, value);
|
WSContentSend_P(HTTP_ENERGY_INDEX_TELEINFO, name, value);
|
||||||
}
|
}
|
||||||
if (getValueFromLabelIndex(LABEL_EASF01, value) ) {
|
if (getValueFromLabelIndex(LABEL_EASF01, value) ) {
|
||||||
GetTextIndexed(name, sizeof(name), LABEL_EASF01, kLabel);
|
GetTextIndexed(name, sizeof(name), LABEL_EASF01, kLabel);
|
||||||
WSContentSend_PD(HTTP_ENERGY_INDEX_TELEINFO, name, value);
|
WSContentSend_P(HTTP_ENERGY_INDEX_TELEINFO, name, value);
|
||||||
}
|
}
|
||||||
if (getValueFromLabelIndex(LABEL_EASF02, value) ) {
|
if (getValueFromLabelIndex(LABEL_EASF02, value) ) {
|
||||||
GetTextIndexed(name, sizeof(name), LABEL_EASF02, kLabel);
|
GetTextIndexed(name, sizeof(name), LABEL_EASF02, kLabel);
|
||||||
WSContentSend_PD(HTTP_ENERGY_INDEX_TELEINFO, name, value);
|
WSContentSend_P(HTTP_ENERGY_INDEX_TELEINFO, name, value);
|
||||||
}
|
}
|
||||||
if (getValueFromLabelIndex(LABEL_SMAXSN, value) ) {
|
if (getValueFromLabelIndex(LABEL_SMAXSN, value) ) {
|
||||||
WSContentSend_PD(HTTP_ENERGY_PMAX_TELEINFO, atoi(value));
|
WSContentSend_P(HTTP_ENERGY_PMAX_TELEINFO, atoi(value));
|
||||||
}
|
}
|
||||||
if (getValueFromLabelIndex(LABEL_LTARF, value) ) {
|
if (getValueFromLabelIndex(LABEL_LTARF, value) ) {
|
||||||
WSContentSend_PD(HTTP_ENERGY_TARIF_TELEINFO, value);
|
WSContentSend_P(HTTP_ENERGY_TARIF_TELEINFO, value);
|
||||||
}
|
}
|
||||||
if (getValueFromLabelIndex(LABEL_NGTF, value) ) {
|
if (getValueFromLabelIndex(LABEL_NGTF, value) ) {
|
||||||
if (isousc) {
|
if (isousc) {
|
||||||
int percent = (int) ((Energy.current[0]*100.0f) / isousc) ;
|
WSContentSend_P(HTTP_ENERGY_CONTRAT_TELEINFO, value, isousc);
|
||||||
WSContentSend_PD(HTTP_ENERGY_CONTRAT_TELEINFO, value, isousc);
|
|
||||||
WSContentSend_PD(HTTP_ENERGY_LOAD_TELEINFO, percent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serial number ADCO or ADSC if found
|
// Serial number ADCO or ADSC if found
|
||||||
if (*serialNumber) {
|
if (*serialNumber) {
|
||||||
WSContentSend_PD(HTTP_ENERGY_ID_TELEINFO, serialNumber);
|
WSContentSend_P(HTTP_ENERGY_ID_TELEINFO, serialNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // USE_WEBSERVER
|
#endif // USE_WEBSERVER
|
||||||
@ -940,4 +1057,4 @@ bool Xnrg15(uint8_t function)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // USE_TELEINFO
|
#endif // USE_TELEINFO
|
||||||
#endif // USE_ENERGY_SENSOR
|
#endif // USE_ENERGY_SENSOR
|
Loading…
x
Reference in New Issue
Block a user