mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-24 03:06:33 +00:00
Fix Energytotals cannot be set to negative values
Fix Energytotals cannot be set to negative values (#17965)
This commit is contained in:
parent
19b183cbee
commit
4c59b5b8d1
@ -11,6 +11,8 @@ All notable changes to this project will be documented in this file.
|
||||
### Changed
|
||||
|
||||
### Fixed
|
||||
- SEN5X floats and units (#17961)
|
||||
- Energytotals cannot be set to negative values (#17965)
|
||||
|
||||
### Removed
|
||||
|
||||
|
@ -118,3 +118,5 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
|
||||
### Changed
|
||||
|
||||
### Fixed
|
||||
- SEN5X floats and units [#17961](https://github.com/arendst/Tasmota/issues/17961)
|
||||
- Energytotals cannot be set to negative values [#17965](https://github.com/arendst/Tasmota/issues/17965)
|
||||
|
@ -697,7 +697,7 @@ void CmndEnergyTotal(void) {
|
||||
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= Energy->phase_count) && (params > 0)) {
|
||||
uint32_t phase = XdrvMailbox.index -1;
|
||||
// Reset Energy Total
|
||||
RtcSettings.energy_kWhtotal_ph[phase] = values[0];
|
||||
RtcSettings.energy_kWhtotal_ph[phase] = (int32_t)values[0];
|
||||
Settings->energy_kWhtotal_ph[phase] = RtcSettings.energy_kWhtotal_ph[phase];
|
||||
if (params > 1) {
|
||||
Settings->energy_kWhtotal_time = values[1];
|
||||
@ -716,7 +716,7 @@ void CmndEnergyYesterday(void) {
|
||||
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= Energy->phase_count) && (params > 0)) {
|
||||
uint32_t phase = XdrvMailbox.index -1;
|
||||
// Reset Energy Yesterday
|
||||
Settings->energy_kWhyesterday_ph[phase] = values[0] * 100;
|
||||
Settings->energy_kWhyesterday_ph[phase] = (int32_t)values[0] * 100;
|
||||
if (params > 1) {
|
||||
Settings->energy_kWhtotal_time = values[1];
|
||||
}
|
||||
@ -732,7 +732,7 @@ void CmndEnergyToday(void) {
|
||||
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= Energy->phase_count) && (params > 0)) {
|
||||
uint32_t phase = XdrvMailbox.index -1;
|
||||
// Reset Energy Today
|
||||
Energy->kWhtoday_offset[phase] = values[0] * 100;
|
||||
Energy->kWhtoday_offset[phase] = (int32_t)values[0] * 100;
|
||||
Energy->kWhtoday[phase] = 0;
|
||||
Energy->kWhtoday_delta[phase] = 0;
|
||||
Energy->start_energy[phase] = 0;
|
||||
@ -760,7 +760,7 @@ void CmndEnergyExportActive(void) {
|
||||
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= Energy->phase_count) && (params > 0)) {
|
||||
uint32_t phase = XdrvMailbox.index -1;
|
||||
// Reset Energy Export Active
|
||||
RtcSettings.energy_kWhexport_ph[phase] = values[0];
|
||||
RtcSettings.energy_kWhexport_ph[phase] = (int32_t)values[0];
|
||||
Settings->energy_kWhexport_ph[phase] = RtcSettings.energy_kWhexport_ph[phase];
|
||||
if (params > 1) {
|
||||
Settings->energy_kWhtotal_time = values[1];
|
||||
@ -789,9 +789,9 @@ void CmndEnergyUsage(void) {
|
||||
uint32_t params = ParseParameters(2, values);
|
||||
if (params > 0) {
|
||||
// Reset energy_usage.usage totals
|
||||
RtcSettings.energy_usage.usage1_kWhtotal = values[0];
|
||||
RtcSettings.energy_usage.usage1_kWhtotal = (int32_t)values[0];
|
||||
if (params > 1) {
|
||||
RtcSettings.energy_usage.usage2_kWhtotal = values[1];
|
||||
RtcSettings.energy_usage.usage2_kWhtotal = (int32_t)values[1];
|
||||
}
|
||||
Settings->energy_usage.usage1_kWhtotal = RtcSettings.energy_usage.usage1_kWhtotal;
|
||||
Settings->energy_usage.usage2_kWhtotal = RtcSettings.energy_usage.usage2_kWhtotal;
|
||||
@ -804,9 +804,9 @@ void CmndEnergyExport(void) {
|
||||
uint32_t params = ParseParameters(2, values);
|
||||
if (params > 0) {
|
||||
// Reset energy_usage.return totals
|
||||
RtcSettings.energy_usage.return1_kWhtotal = values[0] * 100;
|
||||
RtcSettings.energy_usage.return1_kWhtotal = (int32_t)values[0] * 100;
|
||||
if (params > 1) {
|
||||
RtcSettings.energy_usage.return2_kWhtotal = values[1] * 100;
|
||||
RtcSettings.energy_usage.return2_kWhtotal = (int32_t)values[1] * 100;
|
||||
}
|
||||
Settings->energy_usage.return1_kWhtotal = RtcSettings.energy_usage.return1_kWhtotal;
|
||||
Settings->energy_usage.return2_kWhtotal = RtcSettings.energy_usage.return2_kWhtotal;
|
||||
|
@ -930,7 +930,7 @@ void CmndEnergyTotal(void) {
|
||||
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= Energy->phase_count) && (params > 0)) {
|
||||
uint32_t phase = XdrvMailbox.index -1;
|
||||
// Reset Energy Total
|
||||
RtcEnergySettings.energy_total_kWh[phase] = (float)values[0] / 1000;
|
||||
RtcEnergySettings.energy_total_kWh[phase] = (float)(int32_t)values[0] / 1000;
|
||||
Energy->Settings.energy_total_kWh[phase] = RtcEnergySettings.energy_total_kWh[phase];
|
||||
if (params > 1) {
|
||||
Energy->Settings.energy_kWhtotal_time = values[1];
|
||||
@ -949,7 +949,7 @@ void CmndEnergyYesterday(void) {
|
||||
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= Energy->phase_count) && (params > 0)) {
|
||||
uint32_t phase = XdrvMailbox.index -1;
|
||||
// Reset Energy Yesterday
|
||||
Energy->Settings.energy_yesterday_kWh[phase] = (float)values[0] / 1000;
|
||||
Energy->Settings.energy_yesterday_kWh[phase] = (float)(int32_t)values[0] / 1000;
|
||||
if (params > 1) {
|
||||
Energy->Settings.energy_kWhtotal_time = values[1];
|
||||
}
|
||||
@ -965,7 +965,7 @@ void CmndEnergyToday(void) {
|
||||
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= Energy->phase_count) && (params > 0)) {
|
||||
uint32_t phase = XdrvMailbox.index -1;
|
||||
// Reset Energy Today
|
||||
Energy->energy_today_offset_kWh[phase] = (float)values[0] / 1000;
|
||||
Energy->energy_today_offset_kWh[phase] = (float)(int32_t)values[0] / 1000;
|
||||
Energy->kWhtoday[phase] = 0;
|
||||
Energy->kWhtoday_delta[phase] = 0;
|
||||
Energy->start_energy[phase] = 0;
|
||||
@ -993,7 +993,7 @@ void CmndEnergyExportActive(void) {
|
||||
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= Energy->phase_count) && (params > 0)) {
|
||||
uint32_t phase = XdrvMailbox.index -1;
|
||||
// Reset Energy Export Active
|
||||
RtcEnergySettings.energy_export_kWh[phase] = (float)values[0] / 1000;
|
||||
RtcEnergySettings.energy_export_kWh[phase] = (float)(int32_t)values[0] / 1000;
|
||||
Energy->Settings.energy_export_kWh[phase] = RtcEnergySettings.energy_export_kWh[phase];
|
||||
if (params > 1) {
|
||||
Energy->Settings.energy_kWhtotal_time = values[1];
|
||||
@ -1017,9 +1017,9 @@ void CmndEnergyUsage(void) {
|
||||
uint32_t params = ParseParameters(2, values);
|
||||
if (params > 0) {
|
||||
// Reset energy_usage.usage totals
|
||||
RtcEnergySettings.energy_usage.usage_total_kWh[0] = (float)values[0] / 1000;
|
||||
RtcEnergySettings.energy_usage.usage_total_kWh[0] = (float)(int32_t)values[0] / 1000;
|
||||
if (params > 1) {
|
||||
RtcEnergySettings.energy_usage.usage_total_kWh[1] = (float)values[1] / 1000;
|
||||
RtcEnergySettings.energy_usage.usage_total_kWh[1] = (float)(int32_t)values[1] / 1000;
|
||||
}
|
||||
Energy->Settings.energy_usage.usage_total_kWh[0] = RtcEnergySettings.energy_usage.usage_total_kWh[0];
|
||||
Energy->Settings.energy_usage.usage_total_kWh[1] = RtcEnergySettings.energy_usage.usage_total_kWh[1];
|
||||
@ -1032,9 +1032,9 @@ void CmndEnergyExport(void) {
|
||||
uint32_t params = ParseParameters(2, values);
|
||||
if (params > 0) {
|
||||
// Reset energy_usage.return totals
|
||||
RtcEnergySettings.energy_usage.return_total_kWh[0] = (float)values[0] / 1000;
|
||||
RtcEnergySettings.energy_usage.return_total_kWh[0] = (float)(int32_t)values[0] / 1000;
|
||||
if (params > 1) {
|
||||
RtcEnergySettings.energy_usage.return_total_kWh[1] = (float)values[1] / 1000;
|
||||
RtcEnergySettings.energy_usage.return_total_kWh[1] = (float)(int32_t)values[1] / 1000;
|
||||
}
|
||||
Energy->Settings.energy_usage.return_total_kWh[0] = RtcEnergySettings.energy_usage.return_total_kWh[0];
|
||||
Energy->Settings.energy_usage.return_total_kWh[1] = RtcEnergySettings.energy_usage.return_total_kWh[1];
|
||||
|
Loading…
x
Reference in New Issue
Block a user