Report EcoFlow power and temperature as floats
River 2 reported total power and temperature as integers. River 3 reported temperature as an integer. InfluxDB keeps one field type for each measurement, so it rejected these points when another device wrote floats to the same measurement.
This commit is contained in:
@@ -131,6 +131,27 @@ def test_measurement_priorities_are_per_instance_and_reset_per_connection(
|
||||
assert value(snapshot) == low
|
||||
|
||||
|
||||
@pytest.mark.parametrize("decoder_type,packets", [
|
||||
(ecoflow_river2.River2Decoder, [PD_PACKET, (3, 0x20, 0x32, bytes(20) + b"\x1c")]),
|
||||
(ecoflow_river3.River3Decoder, [
|
||||
CELL_TEMP_PACKET, (2, 0xFE, 0x15, b"\x1d" + struct.pack("<f", 244) + b"\x25" + struct.pack("<f", 39)),
|
||||
]),
|
||||
], ids=["river2", "river3"])
|
||||
def test_shared_power_and_temperature_measurements_are_floats(decoder_type, packets):
|
||||
# InfluxDB keeps one type per measurement. The JBD temperatures are floats,
|
||||
# so an integer from either EcoFlow model would be rejected in a shared bucket.
|
||||
snapshot = EcoFlowSnapshot()
|
||||
decoder = decoder_type()
|
||||
for packet in packets:
|
||||
decoder.update(snapshot, *packet)
|
||||
values = [
|
||||
snapshot.ef_input_power_watts.raw_value,
|
||||
snapshot.ef_output_power_watts.raw_value,
|
||||
*snapshot.bms_temperature_celsius.raw_values.values(),
|
||||
]
|
||||
assert [type(value) for value in values] == [float, float, float]
|
||||
|
||||
|
||||
def test_snapshot_keeps_diagnostic_packets_and_json_round_trip():
|
||||
from bmspy.classes import UPS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user