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.76k stars 845 forks source link

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

Open jurkov opened 1 month ago

jurkov commented 1 month 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 1 month 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 1 month 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).

sanjayN4497 commented 2 weeks ago

Hi @imbeacon / @samson0v / @jurkov,

i have downgraded gateway with version 3.5.1 and replaced 174 line, but still same error reoccurring.

Line 174: if self.__logger.isEnabledFor('10'):

Error : convert count=len(dict_result["attributes"]))

image
jurkov commented 1 week ago

Try tp replace the string '10' with the integer 10.

sanjayN4497 commented 1 week ago

Hi @jurkov ,

Thanks for suggestions But you can see in below snap i change '10' with integer 10 but issue remain same as earlier:

image