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.
This commit is contained in:
tim
2026-10-10 09:03:35 +02:00
parent 161ae7ee65
commit 82def5737f
7 changed files with 115 additions and 31 deletions
+6
View File
@@ -91,6 +91,12 @@ class TestReadData:
call_args = mock_comms.call_args[0][1]
assert call_args.get("ups") == "myups"
def test_list_devices_returns_configured_names(self):
from bmspy.client import list_devices
with patch("bmspy.client.socket_comms", return_value={"devices": ["network", "nas"]}) as mock_comms:
assert list_devices("/fake/socket", "test") == ["network", "nas"]
assert mock_comms.call_args[0][1] == {"command": "DEVICES", "client": "test"}
def test_no_ups_filter_not_in_request(self):
with patch("bmspy.client.socket_comms") as mock_comms:
mock_comms.return_value = {}