Correct the spelling in the JBD and EcoFlow snapshots, the diagnostic tool, and the tests. UPS.from_dict maps the old name to the new name, so a client still reads data from an older server during an upgrade. InfluxDB and Prometheus now receive this measurement under the new name.
45 lines
2.0 KiB
Python
45 lines
2.0 KiB
Python
"""JBD measurement snapshot, independent of serial I/O."""
|
|
|
|
from collections.abc import Iterator
|
|
from dataclasses import dataclass, fields as dataclass_fields
|
|
|
|
from bmspy.classes import BMSField, BMSInfoField, BMSMultiField, BMSScalarField, UPS
|
|
|
|
|
|
@dataclass
|
|
class JBDBMS(UPS):
|
|
bms_voltage_total_volts: BMSScalarField | None = None
|
|
bms_current_amps: BMSScalarField | None = None
|
|
bms_capacity_remaining_ah: BMSScalarField | None = None
|
|
bms_capacity_nominal_ah: BMSScalarField | None = None
|
|
bms_charge_cycles: BMSScalarField | None = None
|
|
bms_manufacture_date: BMSInfoField | None = None
|
|
bms_protection_sop_bool: BMSScalarField | None = None
|
|
bms_protection_sup_bool: BMSScalarField | None = None
|
|
bms_protection_wgop_bool: BMSScalarField | None = None
|
|
bms_protection_wgup_bool: BMSScalarField | None = None
|
|
bms_protection_cotp_bool: BMSScalarField | None = None
|
|
bms_protection_cutp_bool: BMSScalarField | None = None
|
|
bms_protection_dotp_bool: BMSScalarField | None = None
|
|
bms_protection_dutp_bool: BMSScalarField | None = None
|
|
bms_protection_cocp_bool: BMSScalarField | None = None
|
|
bms_protection_docp_bool: BMSScalarField | None = None
|
|
bms_protection_scp_bool: BMSScalarField | None = None
|
|
bms_protection_fdic_bool: BMSScalarField | None = None
|
|
bms_protection_slmos_bool: BMSScalarField | None = None
|
|
bms_capacity_charge_ratio: BMSScalarField | None = None
|
|
bms_charge_is_charging: BMSScalarField | None = None
|
|
bms_charge_is_discharging: BMSScalarField | None = None
|
|
bms_cell_number: BMSScalarField | None = None
|
|
bms_cells_balancing: BMSMultiField | None = None
|
|
bms_temperature_sensor_num: BMSScalarField | None = None
|
|
bms_temperature_celsius: BMSMultiField | None = None
|
|
bms_voltage_cells_volts: BMSMultiField | None = None
|
|
|
|
def items(self) -> Iterator[tuple[str, BMSField]]:
|
|
"""Yield (name, field) for all non-None BMS field attributes."""
|
|
for f in dataclass_fields(self):
|
|
v = getattr(self, f.name)
|
|
if v is not None:
|
|
yield f.name, v
|