mirror of https://github.com/arendst/Tasmota.git
parent
cb1d99bd82
commit
04debb5305
|
@ -61,8 +61,8 @@
|
|||
#define D_JSON_ERASE "Erase"
|
||||
#define D_JSON_ERROR "Error"
|
||||
#define D_JSON_EVERY "Every"
|
||||
#define D_JSON_EXPORT_ACTIVE "ExportActivePower"
|
||||
#define D_JSON_EXPORT_REACTIVE "ExportReactivePower"
|
||||
#define D_JSON_EXPORT_ACTIVE "ExportActive"
|
||||
#define D_JSON_EXPORT_REACTIVE "ExportReactive"
|
||||
#define D_JSON_FAILED "Failed"
|
||||
#define D_JSON_FALLBACKTOPIC "FallbackTopic"
|
||||
#define D_JSON_FEATURES "Features"
|
||||
|
@ -86,8 +86,8 @@
|
|||
#define D_JSON_I2CSCAN_NO_DEVICES_FOUND "No devices found"
|
||||
#define D_JSON_ID "Id"
|
||||
#define D_JSON_ILLUMINANCE "Illuminance"
|
||||
#define D_JSON_IMPORT_ACTIVE "ImportActivePower"
|
||||
#define D_JSON_IMPORT_REACTIVE "ImportReactivePower"
|
||||
#define D_JSON_IMPORT_ACTIVE "ImportActive"
|
||||
#define D_JSON_IMPORT_REACTIVE "ImportReactive"
|
||||
#define D_JSON_INFRARED "Infrared"
|
||||
#define D_JSON_UNKNOWN "Unknown"
|
||||
#define D_JSON_LIGHT "Light"
|
||||
|
@ -148,7 +148,7 @@
|
|||
#define D_JSON_TODAY "Today"
|
||||
#define D_JSON_TOTAL "Total"
|
||||
#define D_JSON_TOTAL_USAGE "TotalUsage"
|
||||
#define D_JSON_TOTAL_REACTIVE "TotalReactivePower"
|
||||
#define D_JSON_TOTAL_REACTIVE "TotalReactive"
|
||||
#define D_JSON_TOTAL_START_TIME "TotalStartTime"
|
||||
#define D_JSON_TVOC "TVOC"
|
||||
#define D_JSON_TYPE "Type"
|
||||
|
|
|
@ -242,6 +242,7 @@ char* ToHex_P(const unsigned char * in, size_t insz, char * out, size_t outsz, c
|
|||
#undef USE_PZEM_AC // Disable PZEM014,016 Energy monitor
|
||||
#undef USE_PZEM_DC // Disable PZEM003,017 Energy monitor
|
||||
#undef USE_MCP39F501 // Disable support for MCP39F501 Energy monitor as used in Shelly 2 (+3k1 code)
|
||||
#undef USE_SDM120_2 // Disable support for Eastron SDM120-Modbus energy meter
|
||||
#define USE_DHT // Add support for DHT11, AM2301 (DHT21, DHT22, AM2302, AM2321) and SI7021 Temperature and Humidity sensor
|
||||
#undef USE_MAX31855 // Disable MAX31855 K-Type thermocouple sensor using softSPI
|
||||
#undef USE_IR_REMOTE // Disable IR remote commands using library IRremoteESP8266 and ArduinoJson
|
||||
|
@ -371,6 +372,7 @@ char* ToHex_P(const unsigned char * in, size_t insz, char * out, size_t outsz, c
|
|||
#undef USE_PZEM_AC // Disable PZEM014,016 Energy monitor
|
||||
#undef USE_PZEM_DC // Disable PZEM003,017 Energy monitor
|
||||
#undef USE_MCP39F501 // Disable support for MCP39F501 Energy monitor as used in Shelly 2 (+3k1 code)
|
||||
#undef USE_SDM120_2 // Disable support for Eastron SDM120-Modbus energy meter
|
||||
//#define USE_DHT // Add support for DHT11, AM2301 (DHT21, DHT22, AM2302, AM2321) and SI7021 Temperature and Humidity sensor
|
||||
#undef USE_MAX31855 // Disable MAX31855 K-Type thermocouple sensor using softSPI
|
||||
#undef USE_WS2812 // Disable WS2812 Led string using library NeoPixelBus (+5k code, +1k mem, 232 iram) - Disable by //
|
||||
|
@ -465,6 +467,7 @@ char* ToHex_P(const unsigned char * in, size_t insz, char * out, size_t outsz, c
|
|||
//#undef USE_MCP39F501 // Disable MCP39F501 Energy monitor as used in Shelly 2
|
||||
#undef USE_DHT // Disable support for DHT11, AM2301 (DHT21, DHT22, AM2302, AM2321) and SI7021 Temperature and Humidity sensor
|
||||
#undef USE_MAX31855 // Disable MAX31855 K-Type thermocouple sensor using softSPI
|
||||
#undef USE_SDM120_2 // Disable support for Eastron SDM120-Modbus energy meter
|
||||
#undef USE_IR_REMOTE // Disable IR driver
|
||||
#undef USE_WS2812 // Disable WS2812 Led string
|
||||
#undef USE_ARILUX_RF // Disable support for Arilux RF remote controller
|
||||
|
@ -543,6 +546,7 @@ char* ToHex_P(const unsigned char * in, size_t insz, char * out, size_t outsz, c
|
|||
#undef USE_PZEM_AC // Disable PZEM014,016 Energy monitor
|
||||
#undef USE_PZEM_DC // Disable PZEM003,017 Energy monitor
|
||||
#undef USE_MCP39F501 // Disable MCP39F501 Energy monitor as used in Shelly 2
|
||||
#undef USE_SDM120_2 // Disable support for Eastron SDM120-Modbus energy meter
|
||||
#undef USE_DHT // Disable support for DHT11, AM2301 (DHT21, DHT22, AM2302, AM2321) and SI7021 Temperature and Humidity sensor
|
||||
#undef USE_MAX31855 // Disable MAX31855 K-Type thermocouple sensor using softSPI
|
||||
#undef USE_IR_REMOTE // Disable IR driver
|
||||
|
|
|
@ -524,15 +524,36 @@ const uint8_t kGpioNiceList[] PROGMEM = {
|
|||
#if defined(USE_DS18B20) || defined(USE_DS18x20) || defined(USE_DS18x20_LEGACY)
|
||||
GPIO_DSB, // Single wire DS18B20 or DS18S20
|
||||
#endif
|
||||
#if defined(USE_LIGHT) && defined(USE_WS2812)
|
||||
|
||||
// Light
|
||||
#ifdef USE_LIGHT
|
||||
#ifdef USE_WS2812
|
||||
GPIO_WS2812, // WS2812 Led string
|
||||
#endif
|
||||
#ifdef USE_ARILUX_RF
|
||||
GPIO_ARIRFRCV, // AriLux RF Receive input
|
||||
GPIO_ARIRFSEL, // Arilux RF Receive input selected
|
||||
#endif
|
||||
GPIO_DI, // my92x1 PWM input
|
||||
GPIO_DCKI, // my92x1 CLK input
|
||||
#ifdef USE_SM16716
|
||||
GPIO_SM16716_CLK, // SM16716 CLOCK
|
||||
GPIO_SM16716_DAT, // SM16716 DATA
|
||||
GPIO_SM16716_SEL, // SM16716 SELECT
|
||||
#endif // USE_SM16716
|
||||
#ifdef USE_TUYA_DIMMER
|
||||
GPIO_TUYA_TX, // Tuya Serial interface
|
||||
GPIO_TUYA_RX, // Tuya Serial interface
|
||||
#endif
|
||||
#endif // USE_LIGHT
|
||||
|
||||
#if defined(USE_IR_REMOTE) || defined(USE_IR_REMOTE_FULL)
|
||||
GPIO_IRSEND, // IR remote
|
||||
#if defined(USE_IR_RECEIVE) || defined(USE_IR_REMOTE_FULL)
|
||||
GPIO_IRRECV, // IR receiver
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_RC_SWITCH
|
||||
GPIO_RFSEND, // RF transmitter
|
||||
GPIO_RFRECV, // RF receiver
|
||||
|
@ -553,19 +574,22 @@ const uint8_t kGpioNiceList[] PROGMEM = {
|
|||
GPIO_HX711_SCK, // HX711 Load Cell clock
|
||||
GPIO_HX711_DAT, // HX711 Load Cell data
|
||||
#endif
|
||||
#if defined(USE_ENERGY_SENSOR) && defined(USE_HLW8012)
|
||||
|
||||
// Energy sensors
|
||||
#ifdef USE_ENERGY_SENSOR
|
||||
#ifdef USE_HLW8012
|
||||
GPIO_NRG_SEL, // HLW8012/HLJ-01 Sel output (1 = Voltage)
|
||||
GPIO_NRG_SEL_INV, // HLW8012/HLJ-01 Sel output (0 = Voltage)
|
||||
GPIO_NRG_CF1, // HLW8012/HLJ-01 CF1 voltage / current
|
||||
GPIO_HLW_CF, // HLW8012 CF power
|
||||
GPIO_HJL_CF, // HJL-01/BL0937 CF power
|
||||
#endif
|
||||
#if defined(USE_ENERGY_SENSOR) && defined(USE_I2C) && defined(USE_ADE7953)
|
||||
#if defined(USE_I2C) && defined(USE_ADE7953)
|
||||
GPIO_ADE7953_IRQ, // ADE7953 IRQ
|
||||
#endif
|
||||
GPIO_CSE7766_TX, // CSE7766 Serial interface (S31 and Pow R2)
|
||||
GPIO_CSE7766_RX, // CSE7766 Serial interface (S31 and Pow R2)
|
||||
#if defined(USE_ENERGY_SENSOR) && defined(USE_MCP39F501)
|
||||
#ifdef USE_MCP39F501
|
||||
GPIO_MCP39F5_TX, // MCP39F501 Serial interface (Shelly2)
|
||||
GPIO_MCP39F5_RX, // MCP39F501 Serial interface (Shelly2)
|
||||
GPIO_MCP39F5_RST, // MCP39F501 Reset (Shelly2)
|
||||
|
@ -582,14 +606,26 @@ const uint8_t kGpioNiceList[] PROGMEM = {
|
|||
#ifdef USE_PZEM_DC
|
||||
GPIO_PZEM017_RX, // PZEM-003,017 Serial Modbus interface
|
||||
#endif
|
||||
#ifdef USE_SDM120_2
|
||||
GPIO_SDM120_TX, // SDM120 Serial interface
|
||||
GPIO_SDM120_RX, // SDM120 Serial interface
|
||||
#endif
|
||||
#endif // USE_ENERGY_SENSOR
|
||||
#ifndef USE_SDM120_2
|
||||
#ifdef USE_SDM120
|
||||
GPIO_SDM120_TX, // SDM120 Serial interface
|
||||
GPIO_SDM120_RX, // SDM120 Serial interface
|
||||
#endif
|
||||
#endif // USE_SDM120_2
|
||||
#ifdef USE_SDM630
|
||||
GPIO_SDM630_TX, // SDM630 Serial interface
|
||||
GPIO_SDM630_RX, // SDM630 Serial interface
|
||||
#endif
|
||||
#ifdef USE_SOLAX_X1
|
||||
GPIO_SOLAXX1_TX, // Solax Inverter tx pin
|
||||
GPIO_SOLAXX1_RX, // Solax Inverter rx pin
|
||||
#endif
|
||||
|
||||
#ifdef USE_SERIAL_BRIDGE
|
||||
GPIO_SBR_TX, // Serial Bridge Serial interface
|
||||
GPIO_SBR_RX, // Serial Bridge Serial interface
|
||||
|
@ -619,10 +655,6 @@ const uint8_t kGpioNiceList[] PROGMEM = {
|
|||
#ifdef USE_MP3_PLAYER
|
||||
GPIO_MP3_DFR562, // RB-DFR-562, DFPlayer Mini MP3 Player Serial interface
|
||||
#endif
|
||||
#if defined(USE_LIGHT) && defined(USE_TUYA_DIMMER)
|
||||
GPIO_TUYA_TX, // Tuya Serial interface
|
||||
GPIO_TUYA_RX, // Tuya Serial interface
|
||||
#endif
|
||||
#ifdef USE_AZ7798
|
||||
GPIO_AZ_TXD, // AZ-Instrument 7798 CO2 datalogger Serial interface
|
||||
GPIO_AZ_RXD, // AZ-Instrument 7798 CO2 datalogger Serial interface
|
||||
|
@ -647,33 +679,16 @@ const uint8_t kGpioNiceList[] PROGMEM = {
|
|||
GPIO_MAX31855CLK, // MAX31855 Serial interface
|
||||
GPIO_MAX31855DO, // MAX31855 Serial interface
|
||||
#endif
|
||||
#ifdef USE_LIGHT
|
||||
GPIO_DI, // my92x1 PWM input
|
||||
GPIO_DCKI, // my92x1 CLK input
|
||||
#ifdef USE_SM16716
|
||||
GPIO_SM16716_CLK, // SM16716 CLOCK
|
||||
GPIO_SM16716_DAT, // SM16716 DATA
|
||||
GPIO_SM16716_SEL, // SM16716 SELECT
|
||||
#endif // USE_SM16716
|
||||
#endif // USE_LIGHT
|
||||
#ifdef ROTARY_V1
|
||||
GPIO_ROT1A, // Rotary switch1 A Pin
|
||||
GPIO_ROT1B, // Rotary switch1 B Pin
|
||||
GPIO_ROT2A, // Rotary switch2 A Pin
|
||||
GPIO_ROT2B, // Rotary switch2 B Pin
|
||||
#endif
|
||||
#ifdef USE_ARILUX_RF
|
||||
GPIO_ARIRFRCV, // AriLux RF Receive input
|
||||
GPIO_ARIRFSEL, // Arilux RF Receive input selected
|
||||
#endif
|
||||
#ifdef USE_HRE
|
||||
GPIO_HRE_CLOCK,
|
||||
GPIO_HRE_DATA,
|
||||
#endif
|
||||
#ifdef USE_SOLAX_X1
|
||||
GPIO_SOLAXX1_TX, // Solax Inverter tx pin
|
||||
GPIO_SOLAXX1_RX, // Solax Inverter rx pin
|
||||
#endif
|
||||
};
|
||||
|
||||
const uint8_t kModuleNiceList[] PROGMEM = {
|
||||
|
|
|
@ -391,7 +391,6 @@ void EnergyOverTempCheck()
|
|||
Energy.start_energy = 0;
|
||||
|
||||
XnrgCall(FUNC_ENERGY_RESET);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -429,7 +428,9 @@ void CmndEnergyReset(void)
|
|||
Settings.energy_kWhtoday = Energy.kWhtoday;
|
||||
RtcSettings.energy_kWhtoday = Energy.kWhtoday;
|
||||
Energy.daily = (float)Energy.kWhtoday / 100000;
|
||||
if (!RtcSettings.energy_kWhtotal && !Energy.kWhtoday) { Settings.energy_kWhtotal_time = LocalTime(); }
|
||||
if (!RtcSettings.energy_kWhtotal && !Energy.kWhtoday) {
|
||||
Settings.energy_kWhtotal_time = LocalTime();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
Settings.energy_kWhyesterday = lnum *100;
|
||||
|
|
|
@ -94,46 +94,46 @@ void SDM120Every200ms(void)
|
|||
Energy.data_valid = 0;
|
||||
|
||||
float value;
|
||||
((uint8_t*)&value)[3] = buffer[3];
|
||||
((uint8_t*)&value)[3] = buffer[3]; // Get float values
|
||||
((uint8_t*)&value)[2] = buffer[4];
|
||||
((uint8_t*)&value)[1] = buffer[5];
|
||||
((uint8_t*)&value)[0] = buffer[6];
|
||||
|
||||
switch(Sdm120.read_state) {
|
||||
case 0:
|
||||
Energy.voltage = value;
|
||||
Energy.voltage = value; // 230.2 V
|
||||
break;
|
||||
|
||||
case 1:
|
||||
Energy.current = value;
|
||||
Energy.current = value; // 1.260 A
|
||||
break;
|
||||
|
||||
case 2:
|
||||
Energy.active_power = value;
|
||||
Energy.active_power = value; // -196.3 W
|
||||
break;
|
||||
|
||||
case 3:
|
||||
Energy.apparent_power = value;
|
||||
Energy.apparent_power = value; // 223.4 VA
|
||||
break;
|
||||
|
||||
case 4:
|
||||
Energy.reactive_power = value;
|
||||
Energy.reactive_power = value; // 92.2
|
||||
break;
|
||||
|
||||
case 5:
|
||||
Energy.power_factor = value;
|
||||
Energy.power_factor = value; // -0.91
|
||||
break;
|
||||
|
||||
case 6:
|
||||
Energy.frequency = value;
|
||||
Energy.frequency = value; // 50.0 Hz
|
||||
break;
|
||||
|
||||
case 7:
|
||||
if (!Energy.start_energy || (value < Energy.start_energy)) {
|
||||
if (!Energy.start_energy || (value < Energy.start_energy)) { // 484.708 kWh
|
||||
Energy.start_energy = value; // Init after restart and hanlde roll-over if any
|
||||
}
|
||||
if (value != Energy.start_energy) {
|
||||
Energy.kWhtoday += (unsigned long)((value - Energy.start_energy) * 100);
|
||||
Energy.kWhtoday += (unsigned long)((value - Energy.start_energy) * 100000); // kWh to deca milli Wh
|
||||
Energy.start_energy = value;
|
||||
}
|
||||
EnergyUpdateToday();
|
||||
|
@ -141,30 +141,30 @@ void SDM120Every200ms(void)
|
|||
|
||||
#ifdef USE_SDM220
|
||||
case 8:
|
||||
Sdm220.phase_angle = value;
|
||||
Sdm220.phase_angle = value; // 0.00 Deg
|
||||
break;
|
||||
|
||||
case 9:
|
||||
Sdm220.import_active = value;
|
||||
Sdm220.import_active = value; // 478.492 kWh
|
||||
break;
|
||||
|
||||
case 10:
|
||||
Sdm220.export_active = value;
|
||||
Sdm220.export_active = value; // 6.216 kWh
|
||||
break;
|
||||
|
||||
case 11:
|
||||
Sdm220.import_reactive = value;
|
||||
Sdm220.import_reactive = value; // 172.750 kVArh
|
||||
break;
|
||||
|
||||
case 12:
|
||||
Sdm220.export_reactive = value;
|
||||
Sdm220.export_reactive = value; // 2.844 kVArh
|
||||
break;
|
||||
|
||||
case 13:
|
||||
Sdm220.total_reactive = value;
|
||||
Sdm220.total_reactive = value; // 175.594 kVArh
|
||||
break;
|
||||
#endif // USE_SDM220
|
||||
} // end switch
|
||||
}
|
||||
|
||||
Sdm120.read_state++;
|
||||
if (sizeof(sdm120_start_addresses)/2 == Sdm120.read_state) {
|
||||
|
@ -215,35 +215,35 @@ void Sdm220Reset(void)
|
|||
|
||||
#ifdef USE_WEBSERVER
|
||||
const char HTTP_ENERGY_SDM220[] PROGMEM =
|
||||
"{s}" D_PHASE_ANGLE "{m}%s " D_UNIT_ANGLE "{e}"
|
||||
"{s}" D_IMPORT_ACTIVE "{m}%s " D_UNIT_KILOWATTHOUR "{e}"
|
||||
"{s}" D_EXPORT_ACTIVE "{m}%s " D_UNIT_KILOWATTHOUR "{e}"
|
||||
"{s}" D_TOTAL_REACTIVE "{m}%s " D_UNIT_KWARH "{e}"
|
||||
"{s}" D_IMPORT_REACTIVE "{m}%s " D_UNIT_KWARH "{e}"
|
||||
"{s}" D_EXPORT_REACTIVE "{m}%s " D_UNIT_KWARH "{e}"
|
||||
"{s}" D_TOTAL_REACTIVE "{m}%s " D_UNIT_KWARH "{e}";
|
||||
"{s}" D_PHASE_ANGLE "{m}%s " D_UNIT_ANGLE "{e}";
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
void Sdm220Show(bool json)
|
||||
{
|
||||
char import_active_chr[FLOATSZ];
|
||||
dtostrfd(Sdm220.import_active, Settings.flag2.energy_resolution, import_active_chr);
|
||||
char export_active_chr[FLOATSZ];
|
||||
dtostrfd(Sdm220.export_active, Settings.flag2.energy_resolution, export_active_chr);
|
||||
char total_reactive_chr[FLOATSZ];
|
||||
dtostrfd(Sdm220.total_reactive, Settings.flag2.energy_resolution, total_reactive_chr);
|
||||
char import_reactive_chr[FLOATSZ];
|
||||
dtostrfd(Sdm220.import_reactive, Settings.flag2.energy_resolution, import_reactive_chr);
|
||||
char export_reactive_chr[FLOATSZ];
|
||||
dtostrfd(Sdm220.export_reactive, Settings.flag2.energy_resolution, export_reactive_chr);
|
||||
char phase_angle_chr[FLOATSZ];
|
||||
dtostrfd(Sdm220.phase_angle, 2, phase_angle_chr);
|
||||
char import_active_chr[FLOATSZ];
|
||||
dtostrfd(Sdm220.import_active, Settings.flag2.wattage_resolution, import_active_chr);
|
||||
char export_active_chr[FLOATSZ];
|
||||
dtostrfd(Sdm220.export_active, Settings.flag2.wattage_resolution, export_active_chr);
|
||||
char import_reactive_chr[FLOATSZ];
|
||||
dtostrfd(Sdm220.import_reactive, Settings.flag2.wattage_resolution, import_reactive_chr);
|
||||
char export_reactive_chr[FLOATSZ];
|
||||
dtostrfd(Sdm220.export_reactive, Settings.flag2.wattage_resolution, export_reactive_chr);
|
||||
char total_reactive_chr[FLOATSZ];
|
||||
dtostrfd(Sdm220.total_reactive, Settings.flag2.wattage_resolution, total_reactive_chr);
|
||||
|
||||
if (json) {
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_PHASE_ANGLE "\":%s,\"" D_JSON_IMPORT_ACTIVE "\":%s,\"" D_JSON_EXPORT_ACTIVE "\":%s,\"" D_JSON_IMPORT_REACTIVE "\":%s,\"" D_JSON_EXPORT_REACTIVE "\":%s,\"" D_JSON_TOTAL_REACTIVE "\":%s"),
|
||||
phase_angle_chr, import_active_chr, export_active_chr, import_reactive_chr, export_reactive_chr, total_reactive_chr);
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_IMPORT_ACTIVE "\":%s,\"" D_JSON_EXPORT_ACTIVE "\":%s,\"" D_JSON_TOTAL_REACTIVE "\":%s,\"" D_JSON_IMPORT_REACTIVE "\":%s,\"" D_JSON_EXPORT_REACTIVE "\":%s,\"" D_JSON_PHASE_ANGLE "\":%s"),
|
||||
import_active_chr, export_active_chr, total_reactive_chr, import_reactive_chr, export_reactive_chr, phase_angle_chr);
|
||||
#ifdef USE_WEBSERVER
|
||||
} else {
|
||||
WSContentSend_PD(HTTP_ENERGY_SDM220, phase_angle_chr, import_active_chr, export_active_chr, import_reactive_chr, export_reactive_chr, total_reactive_chr);
|
||||
WSContentSend_PD(HTTP_ENERGY_SDM220, import_active_chr, export_active_chr, total_reactive_chr, import_reactive_chr, export_reactive_chr, phase_angle_chr);
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue