cyrils / renogy-bt

Python library to read Renogy compatible BT-1 or BT-2 bluetooth modules using Raspberry Pi.
GNU General Public License v3.0
89 stars 36 forks source link

MQTT logging issues to HA #37

Closed lbeckingsale closed 11 months ago

lbeckingsale commented 11 months ago

I can connect to the battery and retrieve data but with MQTT enabled i get the below error. Any ideas?

INFO:root:Init BatteryClient: BT-TH => INFO:root:Adapter status - Powered: True INFO:root:Starting discovery... INFO:root:Devices found: 7 INFO:root:Found matching device BT-TH => [] INFO:root:[] Connected INFO:root:[] Resolved services INFO:root:subscribed to notification 0000fff1-0000-1000-8000- INFO:root:found write characteristic 0000ffd1-0000-1000-8000- INFO:root:resolved services DEBUG:root:create_request_payload 5000 => [255, 3, 19, 136, 0, 17, 20, 182] INFO:root:characteristic_enable_notifications_succeeded INFO:root:characteristic_write_value_succeeded INFO:root:on_data_received: response for read operation DEBUG:root:create_request_payload 5017 => [255, 3, 19, 153, 0, 17, 68, 179] INFO:root:characteristic_write_value_succeeded INFO:root:on_data_received: response for read operation DEBUG:root:create_request_payload 5042 => [255, 3, 19, 178, 0, 6, 116, 181] INFO:root:characteristic_write_value_succeeded INFO:root:on_data_received: response for read operation DEBUG:root:create_request_payload 5122 => [255, 3, 20, 2, 0, 8, 245, 226] INFO:root:characteristic_write_value_succeeded INFO:root:on_data_received: response for read operation DEBUG:root:create_request_payload 5223 => [255, 3, 20, 103, 0, 1, 37, 251] INFO:root:characteristic_write_value_succeeded INFO:root:on_data_received: response for read operation INFO:root:on_read_operation_complete DEBUG:root:BT-TH=> {'function': 'READ', 'cell_count': 4, 'cell_voltage_0': 3.3, 'cell_voltage_1': 3.3, 'cell_voltage_2': 3.3, 'cell_voltage_3': 3.3, 'sensor_count': 2, 'temperature_0': 13.0, 'temperature_1': 13.0, 'current': 0.0, 'voltage': 13.3, 'remaining_charge': 199.2, 'capacity': 200.0, 'model': 'RBT200LFP12-BT', 'device_id': 33, 'device': 'BT-TH', 'client': 'BatteryClient'}

INFO:root:mqtt logging ERROR:dbus.connection:Exception in handler for D-Bus signal: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/dbus/connection.py", line 218, in maybe_handle_message self._handler(*args, **kwargs) File "/usr/local/lib/python3.11/dist-packages/gatt/gatt_linux.py", line 539, in properties_changed self.service.device.characteristic_value_updated(characteristic=self, value=bytes(value)) File "/home/pi/renogy-bt/renogybt/BLE.py", line 86, in characteristic_value_updated self.data_callback(value) File "/home/pi/renogy-bt/renogybt/BaseClient.py", line 74, in on_data_received self.on_read_operation_complete() File "/home/pi/renogy-bt/renogybt/BaseClient.py", line 88, in on_read_operation_complete self.on_data_callback(self, self.data) File "/home/pi/renogy-bt/./example.py", line 22, in on_data_received data_logger.log_mqtt(json_data=filtered_data) File "/home/pi/renogy-bt/renogybt/DataLogger.py", line 25, in log_mqtt publish.single( File "/usr/local/lib/python3.11/dist-packages/paho/mqtt/publish.py", line 240, in single multiple([msg], hostname, port, client_id, keepalive, will, auth, tls, File "/usr/local/lib/python3.11/dist-packages/paho/mqtt/publish.py", line 176, in multiple client.connect(hostname, port, keepalive) File "/usr/local/lib/python3.11/dist-packages/paho/mqtt/client.py", line 914, in connect return self.reconnect() ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/paho/mqtt/client.py", line 1044, in reconnect sock = self._create_socket_connection() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/paho/mqtt/client.py", line 3685, in _create_socket_connection return socket.create_connection(addr, timeout=self._connect_timeout, source_address=source) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/socket.py", line 851, in create_connection raise exceptions[0] File "/usr/lib/python3.11/socket.py", line 836, in create_connection sock.connect(sa) TimeoutError: timed out

I forgot to mention its the latest copy.

cyrils commented 11 months ago

Its a timeout, means not even able to reach the server. Its unlikely this is an issue with the code. Can you check if your ha server ip address is reachable?

lbeckingsale commented 11 months ago

Absolutely spot on 👌 i had the wrong IP address of my server. Thanks.

lbeckingsale commented 11 months ago

Can confirm it works with the "RBT200LFP12-BT" Thanks.