Change Energy JSON data

- Bump version 8.3.1.2
- Change Energy JSON Total field from ``"Total":[33.736,11.717,16.978]`` to ``"Total":33.736,"TotalTariff":[11.717,16.978]``
- Change Energy JSON ExportActive field from ``"ExportActive":[33.736,11.717,16.978]`` to ``"ExportActive":33.736,"ExportActiveTariff":[11.717,16.978]``
- Add Three Phase Export Active Energy to SDM630 driver
This commit is contained in:
Theo Arends 2020-05-22 17:48:21 +02:00
parent 86921e60b2
commit 855e054db8
8 changed files with 107 additions and 50 deletions

View File

@ -52,10 +52,13 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
## Changelog
### Version 8.3.1.1
### Version 8.3.1.2
- Change IRremoteESP8266 library updated to v2.7.7
- Change Energy JSON Total field from ``"Total":[33.736,11.717,16.978]`` to ``"Total":33.736,"TotalTariff":[11.717,16.978]``
- Change Energy JSON ExportActive field from ``"ExportActive":[33.736,11.717,16.978]`` to ``"ExportActive":33.736,"ExportActiveTariff":[11.717,16.978]``
- Add command ``Rule0`` to change global rule parameters
- Add more functionality to ``Switchmode`` 11 and 12 (#8450)
- Add support for VEML6075 UVA/UVB/UVINDEX Sensor by device111 (#8432)
- Add support for VEML7700 Ambient light intensity Sensor by device111 (#8432)
- Add Three Phase Export Active Energy to SDM630 driver

View File

@ -1,5 +1,11 @@
## Unreleased (development)
### 8.3.1.2 20200522
- Change Energy JSON Total field from ``"Total":[33.736,11.717,16.978]`` to ``"Total":33.736,"TotalTariff":[11.717,16.978]``
- Change Energy JSON ExportActive field from ``"ExportActive":[33.736,11.717,16.978]`` to ``"ExportActive":33.736,"ExportActiveTariff":[11.717,16.978]``
- Add Three Phase Export Active Energy to SDM630 driver
### 8.3.1.1 20200518
- Change IRremoteESP8266 library updated to v2.7.7

View File

@ -20,7 +20,7 @@
#ifndef _TASMOTA_VERSION_H_
#define _TASMOTA_VERSION_H_
const uint32_t VERSION = 0x08030101;
const uint32_t VERSION = 0x08030102;
// Lowest compatible version
const uint32_t VERSION_COMPATIBLE = 0x07010006;

View File

@ -80,10 +80,12 @@ struct ENERGY {
float power_factor[3] = { NAN, NAN, NAN }; // 0.12
float frequency[3] = { NAN, NAN, NAN }; // 123.1 Hz
// float import_active[3] = { NAN, NAN, NAN }; // 123.123 kWh
float export_active[3] = { NAN, NAN, NAN }; // 123.123 kWh
float start_energy = 0; // 12345.12345 kWh total previous
float daily = 0; // 123.123 kWh
float total = 0; // 12345.12345 kWh total energy
float export_active = NAN; // 123.123 KWh
unsigned long kWhtoday_delta = 0; // 1212312345 Wh 10^-5 (deca micro Watt hours) - Overflows to Energy.kWhtoday (HLW and CSE only)
unsigned long kWhtoday_offset = 0; // 12312312 Wh * 10^-2 (deca milli Watt hours) - 5764 = 0.05764 kWh = 0.058 kWh = Energy.daily
@ -170,9 +172,18 @@ void EnergyUpdateToday(void)
RtcSettings.energy_usage.last_usage_kWhtotal = (uint32_t)(Energy.total * 100000);
uint32_t return_diff = 0;
if (!isnan(Energy.export_active)) {
return_diff = (uint32_t)(Energy.export_active * 100000) - RtcSettings.energy_usage.last_return_kWhtotal;
RtcSettings.energy_usage.last_return_kWhtotal = (uint32_t)(Energy.export_active * 100000);
if (!isnan(Energy.export_active[0])) {
// return_diff = (uint32_t)(Energy.export_active * 100000) - RtcSettings.energy_usage.last_return_kWhtotal;
// RtcSettings.energy_usage.last_return_kWhtotal = (uint32_t)(Energy.export_active * 100000);
float export_active = 0.0;
for (uint32_t i = 0; i < Energy.phase_count; i++) {
if (!isnan(Energy.export_active[i])) {
export_active += Energy.export_active[i];
}
}
return_diff = (uint32_t)(export_active * 100000) - RtcSettings.energy_usage.last_return_kWhtotal;
RtcSettings.energy_usage.last_return_kWhtotal = (uint32_t)(export_active * 100000);
}
if (EnergyTariff1Active()) { // Tarrif1 = Off-Peak
@ -466,13 +477,13 @@ void EnergyEverySecond(void)
if (!isnan(Energy.reactive_power[i])) { Energy.reactive_power[i] = 0; }
if (!isnan(Energy.frequency[i])) { Energy.frequency[i] = 0; }
if (!isnan(Energy.power_factor[i])) { Energy.power_factor[i] = 0; }
if (!isnan(Energy.export_active[i])) { Energy.export_active[i] = 0; }
data_valid--;
}
}
}
if (!data_valid) {
if (!isnan(Energy.export_active)) { Energy.export_active = 0; }
Energy.start_energy = 0;
XnrgCall(FUNC_ENERGY_RESET);
@ -948,29 +959,31 @@ void EnergyShow(bool json)
char voltage_chr[Energy.phase_count][FLOATSZ];
char current_chr[Energy.phase_count][FLOATSZ];
char active_power_chr[Energy.phase_count][FLOATSZ];
char export_active_chr[Energy.phase_count][FLOATSZ];
for (uint32_t i = 0; i < Energy.phase_count; i++) {
dtostrfd(Energy.voltage[i], Settings.flag2.voltage_resolution, voltage_chr[i]);
dtostrfd(Energy.current[i], Settings.flag2.current_resolution, current_chr[i]);
dtostrfd(Energy.active_power[i], Settings.flag2.wattage_resolution, active_power_chr[i]);
dtostrfd(Energy.export_active[i], Settings.flag2.energy_resolution, export_active_chr[i]);
}
char energy_total_chr[FLOATSZ];
dtostrfd(Energy.total, Settings.flag2.energy_resolution, energy_total_chr);
char energy_daily_chr[FLOATSZ];
dtostrfd(Energy.daily, Settings.flag2.energy_resolution, energy_daily_chr);
char energy_yesterday_chr[FLOATSZ];
dtostrfd((float)Settings.energy_kWhyesterday / 100000, Settings.flag2.energy_resolution, energy_yesterday_chr);
char energy_total_chr[3][FLOATSZ];
dtostrfd(Energy.total, Settings.flag2.energy_resolution, energy_total_chr[0]);
char export_active_chr[3][FLOATSZ];
dtostrfd(Energy.export_active, Settings.flag2.energy_resolution, export_active_chr[0]);
uint8_t energy_total_fields = 1;
bool energy_tariff = false;
char energy_usage_chr[2][FLOATSZ];
char energy_return_chr[2][FLOATSZ];
if (Settings.tariff[0][0] != Settings.tariff[1][0]) {
dtostrfd((float)RtcSettings.energy_usage.usage1_kWhtotal / 100000, Settings.flag2.energy_resolution, energy_total_chr[1]); // Tariff1
dtostrfd((float)RtcSettings.energy_usage.usage2_kWhtotal / 100000, Settings.flag2.energy_resolution, energy_total_chr[2]); // Tariff2
dtostrfd((float)RtcSettings.energy_usage.return1_kWhtotal / 100000, Settings.flag2.energy_resolution, export_active_chr[1]); // Tariff1
dtostrfd((float)RtcSettings.energy_usage.return2_kWhtotal / 100000, Settings.flag2.energy_resolution, export_active_chr[2]); // Tariff2
energy_total_fields = 3;
dtostrfd((float)RtcSettings.energy_usage.usage1_kWhtotal / 100000, Settings.flag2.energy_resolution, energy_usage_chr[0]); // Tariff1
dtostrfd((float)RtcSettings.energy_usage.usage2_kWhtotal / 100000, Settings.flag2.energy_resolution, energy_usage_chr[1]); // Tariff2
dtostrfd((float)RtcSettings.energy_usage.return1_kWhtotal / 100000, Settings.flag2.energy_resolution, energy_return_chr[0]); // Tariff1
dtostrfd((float)RtcSettings.energy_usage.return2_kWhtotal / 100000, Settings.flag2.energy_resolution, energy_return_chr[1]); // Tariff2
energy_tariff = true;
}
char value_chr[FLOATSZ *3]; // Used by EnergyFormatIndex
@ -980,15 +993,26 @@ void EnergyShow(bool json)
if (json) {
bool show_energy_period = (0 == tele_period);
ResponseAppend_P(PSTR(",\"" D_RSLT_ENERGY "\":{\"" D_JSON_TOTAL_START_TIME "\":\"%s\",\"" D_JSON_TOTAL "\":%s,\"" D_JSON_YESTERDAY "\":%s,\"" D_JSON_TODAY "\":%s"),
ResponseAppend_P(PSTR(",\"" D_RSLT_ENERGY "\":{\"" D_JSON_TOTAL_START_TIME "\":\"%s\",\"" D_JSON_TOTAL "\":%s"),
GetDateAndTime(DT_ENERGY).c_str(),
EnergyFormatIndex(value_chr, energy_total_chr[0], json, energy_total_fields),
energy_total_chr);
if (energy_tariff) {
ResponseAppend_P(PSTR(",\"" D_JSON_TOTAL D_CMND_TARIFF "\":%s"),
EnergyFormatIndex(value_chr, energy_usage_chr[0], json, 2));
}
ResponseAppend_P(PSTR(",\"" D_JSON_YESTERDAY "\":%s,\"" D_JSON_TODAY "\":%s"),
energy_yesterday_chr,
energy_daily_chr);
if (!isnan(Energy.export_active)) {
if (!isnan(Energy.export_active[0])) {
ResponseAppend_P(PSTR(",\"" D_JSON_EXPORT_ACTIVE "\":%s"),
EnergyFormatIndex(value_chr, export_active_chr[0], json, energy_total_fields));
EnergyFormat(value_chr, export_active_chr[0], json));
if (energy_tariff) {
ResponseAppend_P(PSTR(",\"" D_JSON_EXPORT_ACTIVE D_CMND_TARIFF "\":%s"),
EnergyFormatIndex(value_chr, energy_return_chr[0], json, 2));
}
}
if (show_energy_period) {
@ -1028,14 +1052,14 @@ void EnergyShow(bool json)
#ifdef USE_DOMOTICZ
if (show_energy_period) { // Only send if telemetry
dtostrfd(Energy.total * 1000, 1, energy_total_chr[0]);
DomoticzSensorPowerEnergy((int)Energy.active_power[0], energy_total_chr[0]); // PowerUsage, EnergyToday
dtostrfd(Energy.total * 1000, 1, energy_total_chr);
DomoticzSensorPowerEnergy((int)Energy.active_power[0], energy_total_chr); // PowerUsage, EnergyToday
dtostrfd((float)RtcSettings.energy_usage.usage1_kWhtotal / 100, 1, energy_total_chr[1]); // Tariff1
dtostrfd((float)RtcSettings.energy_usage.usage2_kWhtotal / 100, 1, energy_total_chr[2]); // Tariff2
dtostrfd((float)RtcSettings.energy_usage.return1_kWhtotal / 100, 1, export_active_chr[1]);
dtostrfd((float)RtcSettings.energy_usage.return2_kWhtotal / 100, 1, export_active_chr[2]);
DomoticzSensorP1SmartMeter(energy_total_chr[1], energy_total_chr[2], export_active_chr[1], export_active_chr[2], (int)Energy.active_power[0]);
dtostrfd((float)RtcSettings.energy_usage.usage1_kWhtotal / 100, 1, energy_usage_chr[0]); // Tariff1
dtostrfd((float)RtcSettings.energy_usage.usage2_kWhtotal / 100, 1, energy_usage_chr[1]); // Tariff2
dtostrfd((float)RtcSettings.energy_usage.return1_kWhtotal / 100, 1, energy_return_chr[0]);
dtostrfd((float)RtcSettings.energy_usage.return2_kWhtotal / 100, 1, energy_return_chr[1]);
DomoticzSensorP1SmartMeter(energy_usage_chr[0], energy_usage_chr[1], energy_return_chr[0], energy_return_chr[1], (int)Energy.active_power[0]);
if (Energy.voltage_available) {
DomoticzSensor(DZ_VOLTAGE, voltage_chr[0]); // Voltage
@ -1082,9 +1106,9 @@ void EnergyShow(bool json)
EnergyFormat(value_chr, frequency_chr[0], json, Energy.voltage_common));
}
}
WSContentSend_PD(HTTP_ENERGY_SNS2, energy_daily_chr, energy_yesterday_chr, energy_total_chr[0]);
if (!isnan(Energy.export_active)) {
WSContentSend_PD(HTTP_ENERGY_SNS3, export_active_chr[0]);
WSContentSend_PD(HTTP_ENERGY_SNS2, energy_daily_chr, energy_yesterday_chr, energy_total_chr);
if (!isnan(Energy.export_active[0])) {
WSContentSend_PD(HTTP_ENERGY_SNS3, EnergyFormat(value_chr, export_active_chr[0], json));
}
XnrgCall(FUNC_WEB_SENSOR);

View File

@ -134,7 +134,7 @@ void SDM120Every250ms(void)
break;
case 9:
Energy.export_active = value; // 6.216 kWh
Energy.export_active[0] = value; // 6.216 kWh
break;
case 10:

View File

@ -74,7 +74,7 @@ void Dds2382EverySecond(void)
if (Settings.flag3.dds2382_model) { // SetOption71 - Select different Modbus registers for Active Energy (#6531)
offset = 19;
}
Energy.export_active = (float)((buffer[offset] << 24) + (buffer[offset +1] << 16) + (buffer[offset +2] << 8) + buffer[offset +3]) / 100.0; // 429496.729 kW
Energy.export_active[0] = (float)((buffer[offset] << 24) + (buffer[offset +1] << 16) + (buffer[offset +2] << 8) + buffer[offset +3]) / 100.0; // 429496.729 kW
float import_active = (float)((buffer[offset +4] << 24) + (buffer[offset +5] << 16) + (buffer[offset +6] << 8) + buffer[offset +7]) / 100.0; // 429496.729 kW
EnergyUpdateTotal(import_active, true); // 484.708 kWh

View File

@ -40,22 +40,30 @@
TasmotaModbus *Sdm630Modbus;
const uint16_t sdm630_start_addresses[] {
0x0000, // L1 - SDM630_VOLTAGE [V]
0x0002, // L2 - SDM630_VOLTAGE [V]
0x0004, // L3 - SDM630_VOLTAGE [V]
0x0006, // L1 - SDM630_CURRENT [A]
0x0008, // L2 - SDM630_CURRENT [A]
0x000A, // L3 - SDM630_CURRENT [A]
0x000C, // L1 - SDM630_POWER [W]
0x000E, // L2 - SDM630_POWER [W]
0x0010, // L3 - SDM630_POWER [W]
0x0018, // L1 - SDM630_REACTIVE_POWER [VAR]
0x001A, // L2 - SDM630_REACTIVE_POWER [VAR]
0x001C, // L3 - SDM630_REACTIVE_POWER [VAR]
0x001E, // L1 - SDM630_POWER_FACTOR
0x0020, // L2 - SDM630_POWER_FACTOR
0x0022, // L3 - SDM630_POWER_FACTOR
0x0156 // Total - SDM630_TOTAL_ACTIVE_ENERGY [Wh]
// 3P4 3P3 1P2 Unit Description
0x0000, // + - + V Phase 1 line to neutral volts
0x0002, // + - - V Phase 2 line to neutral volts
0x0004, // + - - V Phase 3 line to neutral volts
0x0006, // + + + A Phase 1 current
0x0008, // + + - A Phase 2 current
0x000A, // + + - A Phase 3 current
0x000C, // + - + W Phase 1 power
0x000E, // + - + W Phase 2 power
0x0010, // + - - W Phase 3 power
0x0018, // + - + VAr Phase 1 volt amps reactive
0x001A, // + - - VAr Phase 2 volt amps reactive
0x001C, // + - - VAr Phase 3 volt amps reactive
0x001E, // + - + Phase 1 power factor
0x0020, // + - - Phase 2 power factor
0x0022, // + - - Phase 3 power factor
0x0046, // + + + Hz Frequency of supply voltages
0x0160, // + + + kWh Phase 1 export active energy
0x0162, // + + + kWh Phase 2 export active energy
0x0164, // + + + kWh Phase 3 export active energy
// 0x015A, // + + + kWh Phase 1 import active energy
// 0x015C, // + + + kWh Phase 2 import active energy
// 0x015E, // + + + kWh Phase 3 import active energy
0x0156 // + + + kWh Total active energy
};
struct SDM630 {
@ -153,6 +161,22 @@ void SDM630Every250ms(void)
break;
case 15:
Energy.frequency[0] = value;
break;
case 16:
Energy.export_active[0] = value;
break;
case 17:
Energy.export_active[1] = value;
break;
case 18:
Energy.export_active[2] = value;
break;
case 19:
EnergyUpdateTotal(value, true);
break;
}

View File

@ -110,7 +110,7 @@ void DDSU666Every250ms(void)
break;
case 7:
Energy.export_active = value; // 6.216 kWh
Energy.export_active[0] = value; // 6.216 kWh
break;
}