Fix hub daily energy by publishing 0 W on the unused charge/discharge sign (#336)
- Hub `battery_charging_power` / `battery_discharging_power` left the unused sign as NAN, while the shunt already publishes 0 W. - ESPHome `total_daily_energy` (`method: right`) skips NAN without advancing `last_update_`, so the next finite watt is multiplied by the whole gap (for example a charge spike after a long discharge). - Publish 0 W on the unused sign (and when power is NAN / no BMS is combined) so both daily meters keep integrating.
This commit is contained in:
1 parent
b3af7e89a9
commit
2e21aa73c0
1 file changed
+12
-7
@@ -1,4 +1,4 @@
|
||||
# Updated : 2026.11.06
|
||||
# Updated : 2026.11.08
|
||||
# Version : 1.8.1
|
||||
# GitHub : https://github.com/Sleeper85/esphome-yambms
|
||||
|
||||
@@ -545,8 +545,8 @@ interval:
|
||||
float total_voltage = NAN;
|
||||
float current = NAN;
|
||||
float power = NAN;
|
||||
float battery_charging_power = NAN;
|
||||
float battery_discharging_power = NAN;
|
||||
float battery_charging_power = 0;
|
||||
float battery_discharging_power = 0;
|
||||
float soc = NAN;
|
||||
float soh = NAN;
|
||||
float charging_cycles = NAN;
|
||||
@@ -590,13 +590,18 @@ interval:
|
||||
else
|
||||
power = round(id(yambms${yambms_id}_var_bms_total_power));
|
||||
|
||||
// battery_charging_power
|
||||
if (power > 0)
|
||||
// battery_charging_power
|
||||
if (!std::isnan(power) && power > 0)
|
||||
{
|
||||
battery_charging_power = power;
|
||||
|
||||
battery_discharging_power = 0;
|
||||
}
|
||||
// battery_discharging_power
|
||||
else
|
||||
else if (!std::isnan(power))
|
||||
{
|
||||
battery_charging_power = 0;
|
||||
battery_discharging_power = power * -1; // Must be positive energy
|
||||
}
|
||||
|
||||
// MEAN Battery SOC (Shunt/BMS)
|
||||
if (id(yambms${yambms_id}_var_shunt_use) == true)
|
||||
|
||||
Reference in new issue
Block a user