Commit Graph
40 Commits
Author SHA1 Message Date
tim d86d59c0f7 Stop the server thread at the end of each server test
The server tests left main() in a thread after each test. These threads kept their patches active and delayed the suite. Each test now sends an invalid command, which ends the server loop, and then joins the thread. The suite time drops from about 8.5 seconds to about 2 seconds.

Remove one unused line from a test.
2026-10-10 09:03:34 +02:00
tim c97f6cc176 Handle a JBD read that returns no response
collect_data called len() on each response. A port that cannot open returns False or None, so the call raised TypeError and ended the server. Treat each empty or absent response as a failed read.
2026-10-10 09:03:33 +02:00
tim aa9888800e 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.
2026-10-10 09:03:33 +02:00
tim f36bb2510c 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.
2026-10-10 09:03:33 +02:00
tim 452a3bc207 Correct the ups_alarm field spelling
The upstream River 3 schema spells field 355 `ups_alram`. Use `ups_alarm` in the decoder, the generated schema, and the field reference. The schema generator now applies a rename map, so a regenerated schema keeps the corrected name.
2026-10-10 09:03:32 +02:00
tim 5fa6000c70 Separate JBD decoding from serial transport
Move response decoding into jbd_proto and the data container into jbd_snapshot. Preserve the existing jbd_bms imports and test the transport boundary.
2026-10-08 14:09:05 +02:00
tim 3422742204 Fix server SIGTERM handler signature 2026-10-08 14:08:20 +02:00
tim c2faeb669a Add River 3 telemetry and schema-based diagnostics
Decode River 3 separately and accumulate partial reports against a field-level checklist. Keep watch mode running after completion.

Label fields and nested records from the pinned pr705 schema. Preserve unknown values and document unverified meanings and routing.

Add synthetic regressions, the River 3 field reference, schema-generation tooling, and upstream attribution.
2026-10-08 14:08:20 +02:00
tim bac953bf48 Replace Poetry with uv
Use standard project metadata, dependency groups, and the uv build backend. The new lock preserves the previous dependency versions. Documentation and services use uv, and services leave their shared environment unchanged at startup.

Remove the entry point for the empty USB HID prototype. Exclude local prototypes, captures, and the external Type 7 lookup table from version control and distributions.
2026-10-08 14:03:09 +02:00
tim 79f9ebf0c7 Integrate EcoFlow Bluetooth devices into the server
Serial paths and collector interfaces remain compatible. Bluetooth polling uses a 60-second cache and backoff. Offline Bluetooth devices no longer retry forever inside a client request. Invalid device specifications do not echo account IDs.
2026-10-08 14:02:45 +02:00
tim 886991caf3 Add River 2 Bluetooth telemetry and diagnostics
Decode River 2 charge, temperature, power flow, and time estimates. Preserve precise charge readings across packet reordering and omit unavailable time estimates.

Require valid PD, EMS, and BMS core heartbeats for diagnostic completion. Report optional packets separately and support raw watch output with reliable disconnect cleanup. Use synthetic regression tests and keep captures, credentials, and external keydata private.

Device details come from command-line arguments or discovery. This commit retains Poetry; the separate packaging commit migrates to uv.
2026-10-08 14:02:45 +02:00
tim 90388d2800 Stop Prometheus mode from falling through to the client 2026-10-07 17:44:48 +02:00
tim 75564f96f0 Fix UPS functionality for multiple devices 2026-05-02 23:25:15 +02:00
tim a74934c439 Fix prometheus functionality 2026-05-02 23:12:40 +02:00
tim 897ae5dfb7 Add unit tests 2026-05-02 23:12:29 +02:00
tim 4e2a967dcf Add docstrings 2026-05-02 23:12:29 +02:00
tim 86f2c548b3 Formatting cleanups for UPS and Prometheus functionality 2026-05-02 18:19:03 +02:00
tim deb6b2bdcc Add a new DeviceState class to capture metadata from a reading 2026-05-02 18:13:33 +02:00
tim d08e26b0db Rename JBDUPS to JBDBMS, as this is more accurate 2026-05-02 18:08:55 +02:00
tim ff578f1889 Add typing, as well as a new UPS type that should be inherited by all new models 2026-05-02 18:08:55 +02:00
tim 973dc9bc96 Fix formatting 2026-05-02 17:40:31 +02:00
tim ad58fc8bc2 Add debugger 2026-05-02 17:40:31 +02:00
tim 4f54b9be36 Extract out classes that should be common to all UPS models 2026-05-02 17:40:31 +02:00
tim f2ffc4568a Add multi-device support
server.py
  - --device is now repeatable (-d ups1:/dev/ttyUSB0 -d ups2:/dev/ttyUSB1). Bare paths (/dev/ttyUSB0) auto-name from the last path component (ttyUSB0).
  - Maintains {name: {ser, data, timestamp}} per UPS — each device has independent data freshness.
  - GET response is now {ups_name: JBDUPS}. Accepts optional ups key in the request to return only one.

client.py
  - read_data() gains ups=None parameter — pass a name to filter server-side, or omit for all.
  - Always returns {ups_name: JBDUPS}.

influxdb.py
  - influxdb_create_snapshot() iterates {name: JBDUPS} and tags every InfluxDB point with ups=name.
  - influxdb_export() / bmspy-influxdb gain --ups to export only a specific UPS.

__init__.py
  - bmspy CLI gains --ups to display only a named UPS.
  - Displays each UPS under a === name === header.
2026-05-02 17:40:31 +02:00
tim 827f59cf49 Update from influxdb_client to influxdb_client_3 2026-05-02 17:40:31 +02:00
tim a782e19563 Update Python minumum version to allow new dependencies
Add a manual pin to typing-extensions >= 4.13, as lower versions that might already be installed will break on Python >= 3.14
2026-05-02 17:40:31 +02:00
tim 4b13450b65 Refactor data dict into a proper JBDUPS class. 2026-05-02 17:40:31 +02:00
tim b672c9f5ae Add UPS functionality 2024-05-14 09:22:06 +02:00
tim af97e393f6 Improve documentation, and improve systemd service files 2024-05-09 09:43:06 +02:00
tim cae4d1b0a4 Use JSON for serialising requests/responses, rather than pickle, to make C integration easier 2024-05-09 09:42:59 +02:00
tim dab791fb79 Refactor into a client/server model, to enable multiple clients to access the BMS data 2024-04-30 17:28:14 +02:00
tim 81fa555402 Fix invalid call 2024-04-28 13:53:18 +02:00
tim ae26cdf3c6 Shift functions around for poetry 2024-03-21 20:58:30 +02:00
tim be75d8fd88 Convert to using poetry to run bmspy 2024-03-19 22:28:39 +02:00
tim 2815665d2f Add some debugging when DB libraries are not found 2024-03-19 22:14:16 +02:00
tim 10bf0b4f1e Whitespace cleanups; rename InfluxDB field from "gauge" to "value"
... this abandons Prometheus "compatibility" for a better fit with InfluxDB naming.
2021-07-23 21:29:57 +02:00
tim 4e68925d34 Fix some issues with raw values 2021-07-22 14:55:14 +02:00
tim c174022d98 Add influx exporter
... as well as turning debug and ser into global variables (for ease of cleanup). Influx, unlike Prometheus, requires typed values, so a raw_value field has been added to the data structure: value is a string, raw_value keeps its type.
2021-07-22 02:57:27 +02:00
tim 951013f0b8 Add bms.py. 2021-02-03 13:23:18 +02:00
tim 0ac9c62ddb Initial commit 2021-02-03 11:19:58 +00:00