Merge remote-tracking branch 'upstream/development' into teleinfo

This commit is contained in:
Charles 2021-04-09 14:28:35 +02:00
commit a10dfbc7c6
15 changed files with 70 additions and 50 deletions

View File

@ -26,6 +26,7 @@ All notable changes to this project will be documented in this file.
- Limit number of relay/button columns in GUI to 8 (#11546)
- ADC range result from int to float using command ``FreqRes`` for decimal resolution selection (#11545)
- Teleinfo, if raw mode selected also return telemety values in SENSOR data
- Removed overtemp detection on external energy monitoring devices (#11628)
### Fixed
- HC-SR04 on ESP32 release serial interface if not used (#11507)

View File

@ -115,6 +115,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota
- DeepSleep announcement topic [#11223](https://github.com/arendst/Tasmota/issues/11223)
- Limit number of relay/button columns in GUI to 8 [#11546](https://github.com/arendst/Tasmota/issues/11546)
- ADC range result from int to float using command ``FreqRes`` for decimal resolution selection [#11545](https://github.com/arendst/Tasmota/issues/11545)
- Removed overtemp detection on external energy monitoring devices [#11628](https://github.com/arendst/Tasmota/issues/11628)
### Fixed
- PN532 on ESP32 Serial flush both Tx and Rx buffers [#10910](https://github.com/arendst/Tasmota/issues/10910)

View File

@ -421,6 +421,7 @@
#define D_CMND_VOLTAGESET "VoltageSet"
#define D_CMND_CURRENTSET "CurrentSet"
#define D_CMND_FREQUENCYSET "FrequencySet"
#define D_CMND_ENERGYCONFIG "EnergyConfig"
#define D_CMND_MAXPOWER "MaxPower"
#define D_CMND_MAXPOWERHOLD "MaxPowerHold"
#define D_CMND_MAXPOWERWINDOW "MaxPowerWindow"

View File

@ -411,7 +411,7 @@ void BacklogLoop(void) {
}
void SleepDelay(uint32_t mseconds) {
if (mseconds) {
if (!TasmotaGlobal.backlog_nodelay && mseconds) {
uint32_t wait = millis() + mseconds;
while (!TimeReached(wait) && !Serial.available()) { // We need to service serial buffer ASAP as otherwise we get uart buffer overrun
delay(1);

View File

@ -1505,16 +1505,16 @@ uint16_t WebGetGpioArg(uint32_t i) {
void TemplateSaveSettings(void) {
char tmp[TOPSZ]; // WebGetArg NAME and GPIO/BASE/FLAG byte value
char svalue[300]; // Template command string
char command[300]; // Template command string
WebGetArg(PSTR("s1"), tmp, sizeof(tmp)); // NAME
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_TEMPLATE " {\"" D_JSON_NAME "\":\"%s\",\"" D_JSON_GPIO "\":["), tmp);
snprintf_P(command, sizeof(command), PSTR(D_CMND_TEMPLATE " {\"" D_JSON_NAME "\":\"%s\",\"" D_JSON_GPIO "\":["), tmp);
uint32_t j = 0;
for (uint32_t i = 0; i < nitems(Settings.user_template.gp.io); i++) {
if (6 == i) { j = 9; }
if (8 == i) { j = 12; }
snprintf_P(svalue, sizeof(svalue), PSTR("%s%s%d"), svalue, (i>0)?",":"", WebGetGpioArg(j));
snprintf_P(command, sizeof(command), PSTR("%s%s%d"), command, (i>0)?",":"", WebGetGpioArg(j));
j++;
}
@ -1528,8 +1528,8 @@ void TemplateSaveSettings(void) {
WebGetArg(PSTR("g99"), tmp, sizeof(tmp)); // BASE
uint32_t base = atoi(tmp) +1;
snprintf_P(svalue, sizeof(svalue), PSTR("%s],\"" D_JSON_FLAG "\":%d,\"" D_JSON_BASE "\":%d}"), svalue, flag, base);
ExecuteWebCommand(svalue);
snprintf_P(command, sizeof(command), PSTR("%s],\"" D_JSON_FLAG "\":%d,\"" D_JSON_BASE "\":%d}"), command, flag, base);
ExecuteWebCommand(command);
}
/*-------------------------------------------------------------------------------------------*/
@ -1878,7 +1878,7 @@ void LoggingSaveSettings(void) {
char tmp7[CMDSZ];
WebGetArg(PSTR("lt"), tmp7, sizeof(tmp7)); // Teleperiod
char command[200];
snprintf_P(command, sizeof(command),PSTR(D_CMND_BACKLOG "0 " D_CMND_SERIALLOG " %s;" D_CMND_WEBLOG " %s;" D_CMND_MQTTLOG " %s;" D_CMND_SYSLOG " %s;" D_CMND_LOGHOST " %s;" D_CMND_LOGPORT " %s;" D_CMND_TELEPERIOD " %s"),
snprintf_P(command, sizeof(command), PSTR(D_CMND_BACKLOG "0 " D_CMND_SERIALLOG " %s;" D_CMND_WEBLOG " %s;" D_CMND_MQTTLOG " %s;" D_CMND_SYSLOG " %s;" D_CMND_LOGHOST " %s;" D_CMND_LOGPORT " %s;" D_CMND_TELEPERIOD " %s"),
(!strlen(tmp1)) ? STR(SERIAL_LOG_LEVEL) : tmp1,
(!strlen(tmp2)) ? STR(WEB_LOG_LEVEL) : tmp2,
(!strlen(tmp3)) ? STR(MQTT_LOG_LEVEL) : tmp3,
@ -1958,8 +1958,8 @@ void OtherSaveSettings(void) {
WebGetArg(PSTR("dn"), tmp1, sizeof(tmp1)); // Device name
char tmp2[100];
WebGetArg(PSTR("wp"), tmp2, sizeof(tmp2)); // Web password
char command[600];
snprintf_P(command, sizeof(command),PSTR(D_CMND_BACKLOG "0 " D_CMND_WEBPASSWORD "2 %s;" D_CMND_SO "3 %d;" D_CMND_DEVICENAME " %s"),
char command[500];
snprintf_P(command, sizeof(command), PSTR(D_CMND_BACKLOG "0 " D_CMND_WEBPASSWORD "2 %s;" D_CMND_SO "3 %d;" D_CMND_DEVICENAME " %s"),
(!strlen(tmp2)) ? "\"" : (strlen(tmp2) < 5) ? "" : tmp2,
Webserver->hasArg(F("b1")), // SetOption3 - Enable MQTT
(!strlen(tmp1)) ? "\"" : tmp1);

View File

@ -43,11 +43,11 @@
enum EnergyCommands {
CMND_POWERCAL, CMND_VOLTAGECAL, CMND_CURRENTCAL, CMND_FREQUENCYCAL,
CMND_POWERSET, CMND_VOLTAGESET, CMND_CURRENTSET, CMND_FREQUENCYSET, CMND_MODULEADDRESS };
CMND_POWERSET, CMND_VOLTAGESET, CMND_CURRENTSET, CMND_FREQUENCYSET, CMND_MODULEADDRESS, CMND_ENERGYCONFIG };
const char kEnergyCommands[] PROGMEM = "|" // No prefix
D_CMND_POWERCAL "|" D_CMND_VOLTAGECAL "|" D_CMND_CURRENTCAL "|" D_CMND_FREQUENCYCAL "|"
D_CMND_POWERSET "|" D_CMND_VOLTAGESET "|" D_CMND_CURRENTSET "|" D_CMND_FREQUENCYSET "|" D_CMND_MODULEADDRESS "|"
D_CMND_POWERSET "|" D_CMND_VOLTAGESET "|" D_CMND_CURRENTSET "|" D_CMND_FREQUENCYSET "|" D_CMND_MODULEADDRESS "|" D_CMND_ENERGYCONFIG "|"
#ifdef USE_ENERGY_MARGIN_DETECTION
D_CMND_POWERDELTA "|" D_CMND_POWERLOW "|" D_CMND_POWERHIGH "|" D_CMND_VOLTAGELOW "|" D_CMND_VOLTAGEHIGH "|" D_CMND_CURRENTLOW "|" D_CMND_CURRENTHIGH "|"
#ifdef USE_ENERGY_POWER_LIMIT
@ -56,11 +56,11 @@ const char kEnergyCommands[] PROGMEM = "|" // No prefix
D_CMND_SAFEPOWER "|" D_CMND_SAFEPOWERHOLD "|" D_CMND_SAFEPOWERWINDOW "|"
#endif // USE_ENERGY_POWER_LIMIT
#endif // USE_ENERGY_MARGIN_DETECTION
D_CMND_ENERGYRESET "|" D_CMND_TARIFF ;
D_CMND_ENERGYRESET "|" D_CMND_TARIFF;
void (* const EnergyCommand[])(void) PROGMEM = {
&CmndPowerCal, &CmndVoltageCal, &CmndCurrentCal, &CmndFrequencyCal,
&CmndPowerSet, &CmndVoltageSet, &CmndCurrentSet, &CmndFrequencySet, &CmndModuleAddress,
&CmndPowerSet, &CmndVoltageSet, &CmndCurrentSet, &CmndFrequencySet, &CmndModuleAddress, &CmndEnergyConfig,
#ifdef USE_ENERGY_MARGIN_DETECTION
&CmndPowerDelta, &CmndPowerLow, &CmndPowerHigh, &CmndVoltageLow, &CmndVoltageHigh, &CmndCurrentLow, &CmndCurrentHigh,
#ifdef USE_ENERGY_POWER_LIMIT
@ -69,7 +69,7 @@ void (* const EnergyCommand[])(void) PROGMEM = {
&CmndSafePower, &CmndSafePowerHold, &CmndSafePowerWindow,
#endif // USE_ENERGY_POWER_LIMIT
#endif // USE_ENERGY_MARGIN_DETECTION
&CmndEnergyReset, &CmndTariff };
&CmndEnergyReset, &CmndTariff};
const char kEnergyPhases[] PROGMEM = "|%s / %s|%s / %s / %s||[%s,%s]|[%s,%s,%s]";
@ -102,6 +102,7 @@ struct ENERGY {
uint8_t phase_count; // Number of phases active
bool voltage_common; // Use single voltage
bool frequency_common; // Use single frequency
bool use_overtemp; // Use global temperature as overtemp trigger on internal energy monitor hardware
bool kWhtoday_offset_init;
bool voltage_available; // Enable if voltage is measured
@ -501,7 +502,7 @@ void EnergyMqttShow(void)
void EnergyEverySecond(void)
{
// Overtemp check
if (TasmotaGlobal.global_update) {
if (Energy.use_overtemp && TasmotaGlobal.global_update) {
if (TasmotaGlobal.power && !isnan(TasmotaGlobal.temperature_celsius) && (TasmotaGlobal.temperature_celsius > (float)Settings.param[P_OVER_TEMP])) { // SetOption42 Device overtemp, turn off relays
AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: Temperature %1_f"), &TasmotaGlobal.temperature_celsius);
@ -761,6 +762,13 @@ void CmndModuleAddress(void) {
}
}
void CmndEnergyConfig(void) {
Energy.command_code = CMND_ENERGYCONFIG;
if (XnrgCall(FUNC_COMMAND)) {
ResponseCmndDone();
}
}
#ifdef USE_ENERGY_MARGIN_DETECTION
void CmndPowerDelta(void) {
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= ENERGY_MAX_PHASES)) {

View File

@ -602,36 +602,31 @@ void HandleDomoticzConfiguration(void) {
}
void DomoticzSaveSettings(void) {
char stemp[20];
char ssensor_indices[6 * MAX_DOMOTICZ_SNS_IDX];
char tmp[100];
for (uint32_t i = 0; i < MAX_DOMOTICZ_IDX; i++) {
snprintf_P(stemp, sizeof(stemp), PSTR("r%d"), i);
WebGetArg(stemp, tmp, sizeof(tmp));
Settings.domoticz_relay_idx[i] = (!strlen(tmp)) ? 0 : atoi(tmp);
snprintf_P(stemp, sizeof(stemp), PSTR("k%d"), i);
WebGetArg(stemp, tmp, sizeof(tmp));
Settings.domoticz_key_idx[i] = (!strlen(tmp)) ? 0 : atoi(tmp);
snprintf_P(stemp, sizeof(stemp), PSTR("s%d"), i);
WebGetArg(stemp, tmp, sizeof(tmp));
Settings.domoticz_switch_idx[i] = (!strlen(tmp)) ? 0 : atoi(tmp);
char tmp1[CMDSZ];
WebGetArg(PSTR("ut"), tmp1, sizeof(tmp1));
char command[500];
snprintf_P(command, sizeof(command), PSTR(D_CMND_BACKLOG "0 " D_PRFX_DOMOTICZ D_CMND_UPDATETIMER " %s"),
(!strlen(tmp1)) ? STR(DOMOTICZ_UPDATE_TIMER) : tmp1);
char arg_idx[8];
char tmp2[CMDSZ];
char tmp3[CMDSZ];
for (uint32_t i = 1; i <= MAX_DOMOTICZ_IDX; i++) {
snprintf_P(arg_idx, sizeof(arg_idx), PSTR("r%d"), i -1);
WebGetArg(arg_idx, tmp1, sizeof(tmp1));
arg_idx[0] = 'k';
WebGetArg(arg_idx, tmp2, sizeof(tmp2));
arg_idx[0] = 's';
WebGetArg(arg_idx, tmp3, sizeof(tmp3));
snprintf_P(command, sizeof(command),PSTR("%s;" D_PRFX_DOMOTICZ D_CMND_IDX "%d %s;" D_PRFX_DOMOTICZ D_CMND_KEYIDX "%d %s;" D_PRFX_DOMOTICZ D_CMND_SWITCHIDX "%d %s"),
command, i, (!strlen(tmp1)) ? "0" : tmp1, i, (!strlen(tmp2)) ? "0" : tmp2, i, (!strlen(tmp3)) ? "0" : tmp3);
}
ssensor_indices[0] = '\0';
for (uint32_t i = 0; i < DZ_MAX_SENSORS; i++) {
snprintf_P(stemp, sizeof(stemp), PSTR("l%d"), i);
WebGetArg(stemp, tmp, sizeof(tmp));
Settings.domoticz_sensor_idx[i] = (!strlen(tmp)) ? 0 : atoi(tmp);
snprintf_P(ssensor_indices, sizeof(ssensor_indices), PSTR("%s%s%d"), ssensor_indices, (strlen(ssensor_indices)) ? "," : "", Settings.domoticz_sensor_idx[i]);
for (uint32_t i = 1; i <= DZ_MAX_SENSORS; i++) {
snprintf_P(arg_idx, sizeof(arg_idx), PSTR("l%d"), i -1);
WebGetArg(arg_idx, tmp1, sizeof(tmp1));
snprintf_P(command, sizeof(command),PSTR("%s;" D_PRFX_DOMOTICZ D_CMND_SENSORIDX "%d %s"),
command, i, (!strlen(tmp1)) ? "0" : tmp1);
}
WebGetArg(PSTR("ut"), tmp, sizeof(tmp));
Settings.domoticz_update_timer = (!strlen(tmp)) ? DOMOTICZ_UPDATE_TIMER : atoi(tmp);
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_DOMOTICZ D_CMND_IDX " %d,%d,%d,%d, " D_CMND_KEYIDX " %d,%d,%d,%d, " D_CMND_SWITCHIDX " %d,%d,%d,%d, " D_CMND_SENSORIDX " %s, " D_CMND_UPDATETIMER " %d"),
Settings.domoticz_relay_idx[0], Settings.domoticz_relay_idx[1], Settings.domoticz_relay_idx[2], Settings.domoticz_relay_idx[3],
Settings.domoticz_key_idx[0], Settings.domoticz_key_idx[1], Settings.domoticz_key_idx[2], Settings.domoticz_key_idx[3],
Settings.domoticz_switch_idx[0], Settings.domoticz_switch_idx[1], Settings.domoticz_switch_idx[2], Settings.domoticz_switch_idx[3],
ssensor_indices, Settings.domoticz_update_timer);
ExecuteWebCommand(command); // Note: beware of max number of commands in backlog currently 30 (MAX_BACKLOG)
}
#endif // USE_WEBSERVER

View File

@ -269,7 +269,8 @@ void HlwDrvInit(void)
Energy.current_available = false;
Energy.voltage_available = false;
}
Energy.use_overtemp = true; // Use global temperature for overtemp detection
TasmotaGlobal.energy_driver = XNRG_01;
}
}

View File

@ -221,7 +221,7 @@ void CseSnsInit(void) {
// Software serial init needs to be done here as earlier (serial) interrupts may lead to Exceptions
// CseSerial = new TasmotaSerial(Pin(GPIO_CSE7766_RX), Pin(GPIO_CSE7766_TX), 1);
CseSerial = new TasmotaSerial(Pin(GPIO_CSE7766_RX), -1, 1);
if (CseSerial->begin(4800, 2)) { // Fake Software Serial 8E1 by using two stop bits
if (CseSerial->begin(4800, SERIAL_8E1)) {
if (CseSerial->hardwareSerial()) {
SetSerial(4800, TS_SERIAL_8E1);
ClaimSerial();
@ -230,6 +230,7 @@ void CseSnsInit(void) {
Settings.param[P_CSE7766_INVALID_POWER] = CSE_MAX_INVALID_POWER; // SetOption39 1..255
}
Cse.power_invalid = Settings.param[P_CSE7766_INVALID_POWER];
Energy.use_overtemp = true; // Use global temperature for overtemp detection
} else {
TasmotaGlobal.energy_driver = ENERGY_NONE;
}

View File

@ -573,6 +573,7 @@ void McpSnsInit(void)
mcp_buffer = (char*)(malloc(MCP_BUFFER_SIZE));
}
DigitalWrite(GPIO_MCP39F5_RST, 0, 1); // MCP enable
Energy.use_overtemp = true; // Use global temperature for overtemp detection
} else {
TasmotaGlobal.energy_driver = ENERGY_NONE;
}

View File

@ -215,6 +215,7 @@ void Ade7953DrvInit(void)
Energy.phase_count = 2; // Handle two channels as two phases
Energy.voltage_common = true; // Use common voltage
Energy.frequency_common = true; // Use common frequency
Energy.use_overtemp = true; // Use global temperature for overtemp detection
TasmotaGlobal.energy_driver = XNRG_07;
}
}

View File

@ -219,6 +219,7 @@ void Bl0940SnsInit(void) {
Settings.energy_current_calibration = BL0940_IREF;
Settings.energy_power_calibration = BL0940_PREF;
}
Energy.use_overtemp = true; // Use global temperature for overtemp detection
for (uint32_t i = 0; i < 5; i++) {
for (uint32_t j = 0; j < 6; j++) {

View File

@ -600,6 +600,7 @@ void Cse7761DrvInit(void) {
#ifdef CSE7761_FREQUENCY
Energy.frequency_common = true; // Use common frequency
#endif
Energy.use_overtemp = true; // Use global temperature for overtemp detection
TasmotaGlobal.energy_driver = XNRG_19;
}
}

View File

@ -33,6 +33,7 @@
#define NRG_DUMMY_U_COMMON true // Phase voltage = false, Common voltage = true
#define NRG_DUMMY_F_COMMON true // Phase frequency = false, Common frequency = true
#define NRG_DUMMY_DC false // AC = false, DC = true;
#define NRG_DUMMY_OVERTEMP true // Use global temperature for overtemp detection
#define NRG_DUMMY_UREF 24000 // Voltage 240.00 V (= P / I)
#define NRG_DUMMY_IREF 41666 // Current 0.417 A (= P / U)
@ -99,6 +100,10 @@ bool NrgDummyCommand(void) {
}
}
}
else if (CMND_ENERGYCONFIG == Energy.command_code) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("NRG: Config index %d, payload %d, data '%s'"),
XdrvMailbox.index, XdrvMailbox.payload, XdrvMailbox.data ? XdrvMailbox.data : "null" );
}
else serviced = false; // Unknown command
return serviced;
@ -117,6 +122,7 @@ void NrgDummyDrvInit(void) {
Energy.voltage_common = NRG_DUMMY_U_COMMON; // Phase voltage = false, Common voltage = true
Energy.frequency_common = NRG_DUMMY_F_COMMON; // Phase frequency = false, Common frequency = true
Energy.type_dc = NRG_DUMMY_DC; // AC = false, DC = true;
Energy.use_overtemp = NRG_DUMMY_OVERTEMP; // Use global temperature for overtemp detection
TasmotaGlobal.energy_driver = XNRG_20;
}

View File

@ -233,8 +233,10 @@ int advertismentCallback(BLE_ESP32::ble_advertisment_t *pStruct)
memcpy(UUID,oBeacon.getProximityUUID().getNative()->u128.value,16);
ESP32BLE_ReverseStr(UUID,16);
uint16_t Major = ENDIAN_CHANGE_U16(oBeacon.getMajor());
uint16_t Minor = ENDIAN_CHANGE_U16(oBeacon.getMinor());
// uint16_t Major = ENDIAN_CHANGE_U16(oBeacon.getMajor());
// uint16_t Minor = ENDIAN_CHANGE_U16(oBeacon.getMinor());
uint16_t Major = oBeacon.getMajor();
uint16_t Minor = oBeacon.getMinor();
uint8_t PWR = oBeacon.getSignalPower();
DumpHex((const unsigned char*)&UUID,16,ib.UID);
@ -337,7 +339,7 @@ uint32_t ibeacon_add(struct IBEACON *ib) {
if (!strncmp(ib->MAC,"FFFF",4) || strncmp(ib->FACID,"00000000",8)) {
for (uint32_t cnt=0;cnt<MAX_IBEACONS;cnt++) {
if (ibeacons[cnt].FLAGS) {
if (!strncmp_P(ib->UID,PSTR("00000000000000000000000000000000"),32)) {
// if (!strncmp_P(ib->UID,PSTR("00000000000000000000000000000000"),32)) {
if (!strncmp(ibeacons[cnt].MAC,ib->MAC,12)) {
// exists
strncpy(ibeacons[cnt].NAME,ib->NAME,sizeof(ibeacons[cnt].NAME));
@ -350,7 +352,7 @@ uint32_t ibeacon_add(struct IBEACON *ib) {
ibeacons[cnt].count++;
return 2;
}
} else {
/* } else {
if (!strncmp(ibeacons[cnt].UID,ib->UID,32)) {
// exists
strncpy(ibeacons[cnt].NAME,ib->NAME,sizeof(ibeacons[cnt].NAME));
@ -363,7 +365,7 @@ uint32_t ibeacon_add(struct IBEACON *ib) {
ibeacons[cnt].count++;
return 2;
}
}
}*/
}
}
for (uint32_t cnt=0;cnt<MAX_IBEACONS;cnt++) {