Commit Graph
6 Commits
Author SHA1 Message Date
tim 98fd08e39b Report a power return at any charge level
The charge tests and the power tests were one if/elif chain. If mains power returned while the charge was below the warning threshold, the loop did not report it, did not cancel the shutdown, and did not clear the flags for the next power failure.

The power tests now run first, on their own. The charge tests apply only while the battery discharges for two consecutive readings, so a low battery on mains power starts no shutdown. A device that reports no battery current is judged by its charge alone.
2026-10-10 10:59:35 +02:00
tim 3bc86b85a2 Compare the newest readings in bmspy-ups
The loop compared the current reading with history[1], history[2], and history[3]. The history holds the oldest reading first, so these were three of the oldest readings. A plain power failure sent no email, and the shutdown started 4 minutes late. The loop now uses the three readings before the current one.

Four tests used reading sequences that matched the old comparison. They now use plain sequences.
2026-10-10 10:59:35 +02:00
tim 82def5737f Select the bmspy-ups device from the configured devices
bmspy-ups selected its device from the devices that had data at startup, and exited with status 0 if the selection failed. One failed first read ended the monitor or made it select the wrong device.

The server has a new DEVICES command that lists the configured names, and client.list_devices calls it. bmspy-ups selects from that list and then waits for the first data of its device. A wrong or missing --device now exits with status 2. The service file does not restart on that status, because a restart cannot correct it.

An older server ends on the unknown DEVICES command, so update the server first.
2026-10-10 09:03:35 +02:00
tim b569bcf27b Fix email, shutdown, and option bugs in bmspy-ups
The recipient check used a regular expression that never matched, so a full address got the host name appended. The main loop passed the device name with a parameter name that read_data does not have. A canceled shutdown did not clear its flag, so a second incident did not schedule a shutdown. The recorded shutdown time used the wrong unit. The --port option stayed text and never matched the STARTTLS ports.
2026-10-10 09:03:34 +02:00
tim 75564f96f0 Fix UPS functionality for multiple devices 2026-05-02 23:25:15 +02:00
tim 897ae5dfb7 Add unit tests 2026-05-02 23:12:29 +02:00