birdie1 / victron

Victron bluetooth and serial communication at a python script. With MQTT and HomeAssistant support.
GNU General Public License v3.0
125 stars 16 forks source link

exception after random runtime bluetooth #21

Open doccodyblue opened 2 years ago

doccodyblue commented 2 years ago

Setup:

After running fine for a while the following exception occurs. (see below) I can immediately restart and victron.py continues to fetch data. I know that the bluetooth connection can be unreliable but maybe theres something to catch in the code here.

[INFO ] (2022-10-12 04:10:26,478) victron_bluetooth.py::224 Solar1: Connecting... [INFO ] (2022-10-12 04:10:37,245) victron_gatt.py::50 Solar1: Connected! [INFO ] (2022-10-12 04:10:37,247) victron_gatt.py::50 Solar1: Connected! [INFO ] (2022-10-12 04:10:40,344) victron_gatt.py::50 Solar1: Connected! [INFO ] (2022-10-12 04:10:58,485) victron_gatt.py::62 Solar1: Disconnected! [INFO ] (2022-10-12 04:11:59,511) victron_bluetooth.py::224 Solar1: Connecting... [INFO ] (2022-10-12 04:12:03,818) victron_gatt.py::50 Solar1: Connected! [INFO ] (2022-10-12 04:12:03,819) victron_gatt.py::62 Solar1: Disconnected! Exception in thread Thread-2: Traceback (most recent call last): File "/home/anschi/.local/lib/python3.9/site-packages/gatt/gatt_linux.py", line 138, in start_discovery self._adapter.SetDiscoveryFilter(discovery_filter) File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 141, in call return self._connection.call_blocking(self._named_service, File "/usr/lib/python3/dist-packages/dbus/connection.py", line 652, in call_blocking reply_message = self.send_message_with_reply_and_block( dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name :1.7 was not provided by any .service files

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner self.run() File "/usr/lib/python3.9/threading.py", line 1266, in run self.function(*self.args, **self.kwargs) File "/home/anschi/apps/victron/victron.py", line 25, in victron_thread v.connect_disconnect_loop() File "/home/anschi/apps/victron/lib/victron.py", line 52, in connect_disconnect_loop self.victron_type.connect_disconnect_loop(self.cmd, self.config['timer']) File "/home/anschi/apps/victron/lib/victron_bluetooth/victron_bluetooth.py", line 248, in connect_disconnect_loop if self.connect_loop(): File "/home/anschi/apps/victron/lib/victron_bluetooth/victron_bluetooth.py", line 220, in connect_loop manager.start_discovery() File "/home/anschi/.local/lib/python3.9/site-packages/gatt/gatt_linux.py", line 149, in start_discovery raise _error_from_dbus_error(e) gatt.errors.Failed: The name :1.7 was not provided by any .service files