mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-25 07:17:16 +00:00
v5.12.0e - Add command PowerDelta
5.12.0e * Add command PowerDelta 0..100 (percentage) to Energy monitoring devices to report on active power load change (#2157)
This commit is contained in:
parent
058e911c94
commit
12fa894303
@ -5,6 +5,7 @@
|
|||||||
* Add additional time offset to Wifi Retry based on device mac address (#2089)
|
* Add additional time offset to Wifi Retry based on device mac address (#2089)
|
||||||
* Add command Color6 RRGGBB for Clock hour marker color and command Rotation pixels for Clock rotation (#2092)
|
* Add command Color6 RRGGBB for Clock hour marker color and command Rotation pixels for Clock rotation (#2092)
|
||||||
* Add HTML language header in local language (#2123)
|
* Add HTML language header in local language (#2123)
|
||||||
|
* Add command PowerDelta 0..100 (percentage) to Energy monitoring devices to report on active power load change (#2157)
|
||||||
* Fix MAX31850 higher temperatures (#1269)
|
* Fix MAX31850 higher temperatures (#1269)
|
||||||
*
|
*
|
||||||
* 5.12.0d
|
* 5.12.0d
|
||||||
|
@ -275,6 +275,7 @@
|
|||||||
// Commands xdrv_03_energy.ino
|
// Commands xdrv_03_energy.ino
|
||||||
#define D_CMND_POWERLOW "PowerLow"
|
#define D_CMND_POWERLOW "PowerLow"
|
||||||
#define D_CMND_POWERHIGH "PowerHigh"
|
#define D_CMND_POWERHIGH "PowerHigh"
|
||||||
|
#define D_CMND_POWERDELTA "PowerDelta"
|
||||||
#define D_CMND_VOLTAGELOW "VoltageLow"
|
#define D_CMND_VOLTAGELOW "VoltageLow"
|
||||||
#define D_CMND_VOLTAGEHIGH "VoltageHigh"
|
#define D_CMND_VOLTAGEHIGH "VoltageHigh"
|
||||||
#define D_CMND_CURRENTLOW "CurrentLow"
|
#define D_CMND_CURRENTLOW "CurrentLow"
|
||||||
@ -359,6 +360,7 @@ enum UnitNames {
|
|||||||
UNIT_MILLISECOND,
|
UNIT_MILLISECOND,
|
||||||
UNIT_MINUTE,
|
UNIT_MINUTE,
|
||||||
UNIT_PPM,
|
UNIT_PPM,
|
||||||
|
UNIT_PERCENTAGE,
|
||||||
UNIT_PRESSURE,
|
UNIT_PRESSURE,
|
||||||
UNIT_SECOND,
|
UNIT_SECOND,
|
||||||
UNIT_SECTORS,
|
UNIT_SECTORS,
|
||||||
@ -376,6 +378,7 @@ const char kUnitNames[] PROGMEM =
|
|||||||
D_UNIT_MILLISECOND "|"
|
D_UNIT_MILLISECOND "|"
|
||||||
D_UNIT_MINUTE "|"
|
D_UNIT_MINUTE "|"
|
||||||
D_UNIT_PARTS_PER_MILLION "|"
|
D_UNIT_PARTS_PER_MILLION "|"
|
||||||
|
"%|"
|
||||||
D_UNIT_PRESSURE "|"
|
D_UNIT_PRESSURE "|"
|
||||||
D_UNIT_SECOND "|"
|
D_UNIT_SECOND "|"
|
||||||
D_UNIT_SECTORS "|"
|
D_UNIT_SECTORS "|"
|
||||||
|
@ -149,9 +149,7 @@ struct SYSCFG {
|
|||||||
uint8_t ledstate; // 2FB
|
uint8_t ledstate; // 2FB
|
||||||
uint8_t param[PARAM8_SIZE]; // 2FC was domoticz_in_topic until 5.1.6
|
uint8_t param[PARAM8_SIZE]; // 2FC was domoticz_in_topic until 5.1.6
|
||||||
char state_text[4][11]; // 313
|
char state_text[4][11]; // 313
|
||||||
|
uint8_t energy_power_delta; // 33F
|
||||||
byte free_33F[1]; // 33F
|
|
||||||
|
|
||||||
uint16_t domoticz_update_timer; // 340
|
uint16_t domoticz_update_timer; // 340
|
||||||
uint16_t pwm_range; // 342
|
uint16_t pwm_range; // 342
|
||||||
|
|
||||||
|
@ -509,6 +509,7 @@ void SettingsDefaultSet2()
|
|||||||
// Settings.domoticz_switch_idx[i] = 0;
|
// Settings.domoticz_switch_idx[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Settings.energy_power_delta = 80;
|
||||||
Settings.energy_power_calibration = HLW_PREF_PULSE;
|
Settings.energy_power_calibration = HLW_PREF_PULSE;
|
||||||
Settings.energy_voltage_calibration = HLW_UREF_PULSE;
|
Settings.energy_voltage_calibration = HLW_UREF_PULSE;
|
||||||
Settings.energy_current_calibration = HLW_IREF_PULSE;
|
Settings.energy_current_calibration = HLW_IREF_PULSE;
|
||||||
@ -889,6 +890,7 @@ void SettingsDelta()
|
|||||||
}
|
}
|
||||||
if (Settings.version < 0x050C0005) {
|
if (Settings.version < 0x050C0005) {
|
||||||
Settings.light_rotation = 0;
|
Settings.light_rotation = 0;
|
||||||
|
Settings.energy_power_delta = 80;
|
||||||
char fingerprint[60];
|
char fingerprint[60];
|
||||||
memcpy(fingerprint, Settings.mqtt_fingerprint, sizeof(fingerprint));
|
memcpy(fingerprint, Settings.mqtt_fingerprint, sizeof(fingerprint));
|
||||||
char *p = fingerprint;
|
char *p = fingerprint;
|
||||||
|
@ -71,11 +71,12 @@ typedef unsigned long power_t; // Power (Relay) type
|
|||||||
//#define PWM_FREQ 910 // 100..1000 Hz led refresh (iTead value)
|
//#define PWM_FREQ 910 // 100..1000 Hz led refresh (iTead value)
|
||||||
#define PWM_FREQ 880 // 100..1000 Hz led refresh (BN-SZ01 value)
|
#define PWM_FREQ 880 // 100..1000 Hz led refresh (BN-SZ01 value)
|
||||||
|
|
||||||
#define MAX_POWER_HOLD 10 // Time in SECONDS to allow max agreed power (Pow)
|
#define DEFAULT_POWER_DELTA 80 // Power change percentage
|
||||||
#define MAX_POWER_WINDOW 30 // Time in SECONDS to disable allow max agreed power (Pow)
|
#define MAX_POWER_HOLD 10 // Time in SECONDS to allow max agreed power
|
||||||
#define SAFE_POWER_HOLD 10 // Time in SECONDS to allow max unit safe power (Pow)
|
#define MAX_POWER_WINDOW 30 // Time in SECONDS to disable allow max agreed power
|
||||||
#define SAFE_POWER_WINDOW 30 // Time in MINUTES to disable allow max unit safe power (Pow)
|
#define SAFE_POWER_HOLD 10 // Time in SECONDS to allow max unit safe power
|
||||||
#define MAX_POWER_RETRY 5 // Retry count allowing agreed power limit overflow (Pow)
|
#define SAFE_POWER_WINDOW 30 // Time in MINUTES to disable allow max unit safe power
|
||||||
|
#define MAX_POWER_RETRY 5 // Retry count allowing agreed power limit overflow
|
||||||
|
|
||||||
#define STATES 20 // State loops per second
|
#define STATES 20 // State loops per second
|
||||||
#define SYSLOG_TIMER 600 // Seconds to restore syslog_level
|
#define SYSLOG_TIMER 600 // Seconds to restore syslog_level
|
||||||
|
@ -29,12 +29,14 @@
|
|||||||
enum EnergyHardware { ENERGY_NONE, ENERGY_HLW8012, ENERGY_CSE7766, ENERGY_PZEM004T };
|
enum EnergyHardware { ENERGY_NONE, ENERGY_HLW8012, ENERGY_CSE7766, ENERGY_PZEM004T };
|
||||||
|
|
||||||
enum EnergyCommands {
|
enum EnergyCommands {
|
||||||
|
CMND_POWERDELTA,
|
||||||
CMND_POWERLOW, CMND_POWERHIGH, CMND_VOLTAGELOW, CMND_VOLTAGEHIGH, CMND_CURRENTLOW, CMND_CURRENTHIGH,
|
CMND_POWERLOW, CMND_POWERHIGH, CMND_VOLTAGELOW, CMND_VOLTAGEHIGH, CMND_CURRENTLOW, CMND_CURRENTHIGH,
|
||||||
CMND_POWERCAL, CMND_POWERSET, CMND_VOLTAGECAL, CMND_VOLTAGESET, CMND_CURRENTCAL, CMND_CURRENTSET,
|
CMND_POWERCAL, CMND_POWERSET, CMND_VOLTAGECAL, CMND_VOLTAGESET, CMND_CURRENTCAL, CMND_CURRENTSET,
|
||||||
CMND_ENERGYRESET, CMND_MAXENERGY, CMND_MAXENERGYSTART,
|
CMND_ENERGYRESET, CMND_MAXENERGY, CMND_MAXENERGYSTART,
|
||||||
CMND_MAXPOWER, CMND_MAXPOWERHOLD, CMND_MAXPOWERWINDOW,
|
CMND_MAXPOWER, CMND_MAXPOWERHOLD, CMND_MAXPOWERWINDOW,
|
||||||
CMND_SAFEPOWER, CMND_SAFEPOWERHOLD, CMND_SAFEPOWERWINDOW };
|
CMND_SAFEPOWER, CMND_SAFEPOWERHOLD, CMND_SAFEPOWERWINDOW };
|
||||||
const char kEnergyCommands[] PROGMEM =
|
const char kEnergyCommands[] PROGMEM =
|
||||||
|
D_CMND_POWERDELTA "|"
|
||||||
D_CMND_POWERLOW "|" D_CMND_POWERHIGH "|" D_CMND_VOLTAGELOW "|" D_CMND_VOLTAGEHIGH "|" D_CMND_CURRENTLOW "|" D_CMND_CURRENTHIGH "|"
|
D_CMND_POWERLOW "|" D_CMND_POWERHIGH "|" D_CMND_VOLTAGELOW "|" D_CMND_VOLTAGEHIGH "|" D_CMND_CURRENTLOW "|" D_CMND_CURRENTHIGH "|"
|
||||||
D_CMND_POWERCAL "|" D_CMND_POWERSET "|" D_CMND_VOLTAGECAL "|" D_CMND_VOLTAGESET "|" D_CMND_CURRENTCAL "|" D_CMND_CURRENTSET "|"
|
D_CMND_POWERCAL "|" D_CMND_POWERSET "|" D_CMND_VOLTAGECAL "|" D_CMND_VOLTAGESET "|" D_CMND_CURRENTCAL "|" D_CMND_CURRENTSET "|"
|
||||||
D_CMND_ENERGYRESET "|" D_CMND_MAXENERGY "|" D_CMND_MAXENERGYSTART "|"
|
D_CMND_ENERGYRESET "|" D_CMND_MAXENERGY "|" D_CMND_MAXENERGYSTART "|"
|
||||||
@ -44,6 +46,7 @@ const char kEnergyCommands[] PROGMEM =
|
|||||||
float energy_voltage = 0; // 123.1 V
|
float energy_voltage = 0; // 123.1 V
|
||||||
float energy_current = 0; // 123.123 A
|
float energy_current = 0; // 123.123 A
|
||||||
float energy_power = 0; // 123.1 W
|
float energy_power = 0; // 123.1 W
|
||||||
|
float energy_power_last = 0;
|
||||||
float energy_power_factor = 0; // 0.12
|
float energy_power_factor = 0; // 0.12
|
||||||
float energy_daily = 0; // 12.123 kWh
|
float energy_daily = 0; // 12.123 kWh
|
||||||
float energy_total = 0; // 12345.12345 kWh
|
float energy_total = 0; // 12345.12345 kWh
|
||||||
@ -679,6 +682,13 @@ void EnergyMarginCheck()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!jsonflg && Settings.energy_power_delta) {
|
||||||
|
float diff = abs(energy_power_last - energy_power);
|
||||||
|
float max_power = (energy_power_last > energy_power) ? energy_power_last : energy_power;
|
||||||
|
energy_power_last = energy_power;
|
||||||
|
if (((diff / max_power) * 100) > Settings.energy_power_delta) EnergyMqttShow();
|
||||||
|
}
|
||||||
|
|
||||||
#if FEATURE_POWER_LIMIT
|
#if FEATURE_POWER_LIMIT
|
||||||
// Max Power
|
// Max Power
|
||||||
if (Settings.energy_max_power_limit) {
|
if (Settings.energy_max_power_limit) {
|
||||||
@ -768,7 +778,14 @@ boolean EnergyCommand()
|
|||||||
unsigned long nvalue = 0;
|
unsigned long nvalue = 0;
|
||||||
|
|
||||||
int command_code = GetCommandCode(command, sizeof(command), XdrvMailbox.topic, kEnergyCommands);
|
int command_code = GetCommandCode(command, sizeof(command), XdrvMailbox.topic, kEnergyCommands);
|
||||||
if (CMND_POWERLOW == command_code) {
|
if (CMND_POWERDELTA == command_code) {
|
||||||
|
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload < 101)) {
|
||||||
|
Settings.energy_power_delta = (1 == XdrvMailbox.payload) ? DEFAULT_POWER_DELTA : XdrvMailbox.payload;
|
||||||
|
}
|
||||||
|
nvalue = Settings.energy_power_delta;
|
||||||
|
unit = UNIT_PERCENTAGE;
|
||||||
|
}
|
||||||
|
else if (CMND_POWERLOW == command_code) {
|
||||||
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload < 3601)) {
|
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload < 3601)) {
|
||||||
Settings.energy_min_power = XdrvMailbox.payload;
|
Settings.energy_min_power = XdrvMailbox.payload;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user