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

[BUG] Problem with the new version 3.5.2 BAcnet #1541

Open Isac-enerlab opened 1 month ago

Isac-enerlab commented 1 month ago

the bug Testing the new version it stopped reading the variables that we pulled from the operation that runs with version 3.5.1.1. It reports an error on line 53 of the file (thingsboard_gateway/connectors/bacnet/bacnet_uplink_converter.py", line 53, in convert). As we have 23 Units with version 3.5.1, we need to fix this bug.

Bacnet Connector

Sep 25 16:41:55 python3[433368]: fn(self, *args, *kwargs) Sep 25 16:41:55 python3[433368]: File "/var/lib/thingsboard_gateway/venv/lib/python3.10/site-packages/thingsboard_gateway/connectors/bacnet/bacnet_utilities/tb_gateway_bacnet_application.py", line 167, in __iam_cb Sep 25 16:41:55 python3[433368]: value = self.__connector.default_converters["uplink_converter"]("{}", self._log).convert(None, apdu) Sep 25 16:41:55 python3[433368]: File "/var/lib/thingsboard_gateway/venv/lib/python3.10/site-packages/thingsboard_gateway/gateway/statistics/decorators.py", line 31, in inner Sep 25 16:41:55 python3[433368]: result = func(args, **kwargs) Sep 25 16:41:55 python3[433368]: File "/var/lib/thingsboard_gateway/venv/lib/python3.10/site-packages/thingsboard_gateway/connectors/bacnet/bacnet_uplink_converter.py", line 53, in convert Sep 25 16:41:55 python3[433368]: count=len(dict_result["attributes"])) Sep 25 16:41:55 python3[433368]: TypeError: string indices must be integers

Versions

jurkov commented 1 month ago

I can confirm the bug. I also got "missing asyncore package". Asyncore is deprecated with Python 3.12. Python 3.12 comes with the latest base docker image. After installing the package by hand (docker compose exec tb-gateway /bin/bash and pip install pyasyncore) I got the same error message.

imbeacon commented 2 weeks ago

Hi @Isac-enerlab,

Thank you for your interest in ThingsBoard IoT Gateway. You are right, this issue exists. At the moment we have images based on python 3.10 and going to rewrite BACnet connector, to use Bac0 library instead of Bacpypes due to issues like you described and other.