thingsboard / thingsboard-gateway

Open-source IoT Gateway - integrates devices connected to legacy and third-party systems with ThingsBoard IoT Platform using Modbus, CAN bus, BACnet, BLE, OPC-UA, MQTT, ODBC and REST protocols
https://thingsboard.io/docs/iot-gateway/what-is-iot-gateway/
Apache License 2.0
1.73k stars 838 forks source link

[BUG] BacNet connector broken in version 3.5.2, 3.5.3, 3.5.3.1 #1551

Open jurkov opened 1 week ago

jurkov commented 1 week ago

Describe the bug Starting a newly created iot-gateway with docker or native python throws the same error since version 3.5.2. Version 3.5.1 works fine.

Connector name (If bug in the some connector): BacNET Connector

Error traceback (If available):

  File "C:\projects\thingsboard-gateway-native\.venv\Lib\site-packages\thingsboard_gateway\connectors\bacnet\bacnet_uplink_converter.py", line 53, in convert
    count=len(dict_result["attributes"]))
              ~~~~~~~~~~~^^^^^^^^^^^^^^
TypeError: string indices must be integers, not 'str'

Versions (please complete the following information):

Isac-enerlab commented 3 days ago

Good morning

I'm using Ubuntu 20.04.5 LTS version

Tb_gateway 3.5.1 which was collecting data from a mall plant we have. We have 20 units with telemetry collection, the majority of which are BACnet.

After releasing release 3.5.3, three applications stopped, two we managed to reestablish but 1 presents an error, which supports what was mentioned by friend "jurkov".

follow logs.

enerlab-1@GW-SCISP-1:~$ sudo systemctl restart thingsboard-gateway && journalctl -fu thingsboard-gateway.service -- Logs begin at Sat 2024-10-05 22:31:28 UTC. -- Oct 08 08:29:48 GW-SCISP-1 python3[71546]: File "/var/lib/thingsboard_gateway/.local/lib/python3.8/site-packages/bacpypes/netservice.py", line 213, in confirmation Oct 08 08:29:48 GW-SCISP-1 python3[71546]: self.adapterSAP.process_npdu(self, npdu) Oct 08 08:29:48 GW-SCISP-1 python3[71546]: File "/var/lib/thingsboard_gateway/.local/lib/python3.8/site-packages/bacpypes/netservice.py", line 573, in process_npdu Oct 08 08:29:48 GW-SCISP-1 python3[71546]: self.response(apdu) Oct 08 08:29:48 GW-SCISP-1 python3[71546]: File "/var/lib/thingsboard_gateway/.local/lib/python3.8/site-packages/bacpypes/comm.py", line 320, in response Oct 08 08:29:48 GW-SCISP-1 python3[71546]: self.serverPeer.confirmation(*args, *kwargs) Oct 08 08:29:48 GW-SCISP-1 python3[71546]: File "/var/lib/thingsboard_gateway/.local/lib/python3.8/site-packages/bacpypes/appservice.py", line 1243, in confirmation Oct 08 08:29:48 GW-SCISP-1 python3[71546]: self.sap_request(apdu) Oct 08 08:29:48 GW-SCISP-1 python3[71546]: File "/var/lib/thingsboard_gateway/.local/lib/python3.8/site-packages/bacpypes/comm.py", line 527, in sap_request Oct 08 08:29:48 GW-SCISP-1 python3[71546]: self.serviceElement.indication(args, **kwargs)

Please help me with some idea of ​​what I can do.

jurkov commented 3 days ago

A workaround would be to downgrade to 3.5.1. I fixed line 174 in tb_client.py and replaced 'DEBUG' with 10. (To be able to use MQTTS).