Rename bms_temperature_celcius to bms_temperature_celsius
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.
This commit is contained in:
+7
-1
@@ -44,6 +44,10 @@ class BMSInfoField:
|
||||
|
||||
type BMSField = BMSScalarField | BMSMultiField | BMSInfoField
|
||||
|
||||
# Corrected field spellings: old name to current name. An older server can
|
||||
# still send the old name during an upgrade.
|
||||
RENAMED_FIELDS = {"bms_temperature_celcius": "bms_temperature_celsius"}
|
||||
|
||||
|
||||
def _field_from_dict(d: dict[str, Any]) -> BMSField:
|
||||
"""Reconstruct a BMSField from its JSON-serialized dict."""
|
||||
@@ -69,7 +73,9 @@ class UPS(ABC):
|
||||
@classmethod
|
||||
def from_dict(cls, data: dict[str, Any]) -> "UPS":
|
||||
"""Reconstruct a UPS snapshot from a JSON-decoded field dict."""
|
||||
return _UPSSnapshot({name: _field_from_dict(v) for name, v in data.items()})
|
||||
return _UPSSnapshot({
|
||||
RENAMED_FIELDS.get(name, name): _field_from_dict(v) for name, v in data.items()
|
||||
})
|
||||
|
||||
|
||||
class _UPSSnapshot(UPS):
|
||||
|
||||
@@ -353,7 +353,7 @@ class River2Decoder:
|
||||
else:
|
||||
charge_ratio(values["soc"], priority=1)
|
||||
temp = values["temp"]
|
||||
snapshot.bms_temperature_celcius = BMSMultiField(
|
||||
snapshot.bms_temperature_celsius = BMSMultiField(
|
||||
help="Battery Temperature", label="sensor",
|
||||
raw_values={1: temp}, values={1: str(temp)}, units="°C",
|
||||
)
|
||||
|
||||
@@ -305,7 +305,7 @@ class River3Decoder:
|
||||
for source, priority in (("cms_batt_temp", 1), ("bms_max_cell_temp", 2)):
|
||||
temp = values.get(source)
|
||||
if temp is not None and priority >= self._river3_temp_priority:
|
||||
snapshot.bms_temperature_celcius = BMSMultiField(
|
||||
snapshot.bms_temperature_celsius = BMSMultiField(
|
||||
help="Battery Temperature", label="sensor",
|
||||
raw_values={1: temp}, values={1: str(temp)}, units="°C",
|
||||
)
|
||||
|
||||
@@ -23,7 +23,7 @@ class EcoFlowSnapshot(UPS):
|
||||
ef_packets_received: BMSScalarField | None = None
|
||||
|
||||
bms_capacity_charge_ratio: BMSScalarField | None = None
|
||||
bms_temperature_celcius: BMSMultiField | None = None
|
||||
bms_temperature_celsius: BMSMultiField | None = None
|
||||
bms_charge_is_charging: BMSScalarField | None = None
|
||||
bms_charge_is_discharging: BMSScalarField | None = None
|
||||
ef_input_power_watts: BMSScalarField | None = None
|
||||
|
||||
+1
-1
@@ -295,7 +295,7 @@ def parse_03_response(response: bytearray, debug: int = 0) -> JBDBMS | bool:
|
||||
result.bms_temperature_sensor_num = BMSScalarField(
|
||||
help="Temperature Sensors", raw_value=ntc_num, value="{0}".format(ntc_num)
|
||||
)
|
||||
result.bms_temperature_celcius = BMSMultiField(
|
||||
result.bms_temperature_celsius = BMSMultiField(
|
||||
help="Temperature",
|
||||
label="sensor",
|
||||
raw_values={i + 1: temp for i, temp in enumerate(temperatures)},
|
||||
|
||||
@@ -33,7 +33,7 @@ class JBDBMS(UPS):
|
||||
bms_cell_number: BMSScalarField | None = None
|
||||
bms_cells_balancing: BMSMultiField | None = None
|
||||
bms_temperature_sensor_num: BMSScalarField | None = None
|
||||
bms_temperature_celcius: BMSMultiField | None = None
|
||||
bms_temperature_celsius: BMSMultiField | None = None
|
||||
bms_voltage_cells_volts: BMSMultiField | None = None
|
||||
|
||||
def items(self) -> Iterator[tuple[str, BMSField]]:
|
||||
|
||||
Reference in New Issue
Block a user