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] TypeError: 'bool' object is not iterable #449

Closed smartwizint closed 3 years ago

smartwizint commented 3 years ago

Describe the bug From a [Round Switch Widget] on Dashboard, Turn on switch -> RPC Call "setValue" -> an error occurred on the Gateway.

dashboard

=== modbus connector settings (modbus.json) === "rpc": [ { "tag": "setValue", "type": "bits", "wordOrder": "LITTLE", "byteOrder": "BIG", "functionCode": 5, "objectsCount": 1, "address": 31 }, { "tag": "getValue", "type": "bits", "wordOrder": "LITTLE", "byteOrder": "BIG", "functionCode": 1, "objectsCount": 1, "address": 31 } ]

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

Error traceback (If available): ""2020-12-21 17:29:13" - ERROR - [modbus_connector.py] - modbus_connector - 215 - 'bool' object is not iterable" Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/thingsboard_gateway-2.5.4-py3.7.egg/thingsboard_gateway/connectors/mod bus/modbus_connector.py", line 213, in on_attributes_update self.__process_rpc_request(to_process, attribute_updates_command_config) File "/usr/local/lib/python3.7/dist-packages/thingsboard_gateway-2.5.4-py3.7.egg/thingsboard_gateway/connectors/mod bus/modbus_connector.py", line 340, in process_rpc_request rpc_command_config["payload"] = self.devices[content["device"]]["downlink_converter"].convert(rpc_command_confi g, content) File "/usr/local/lib/python3.7/dist-packages/thingsboard_gateway-2.5.4-py3.7.egg/thingsboard_gateway/connectors/mod bus/bytes_modbus_downlink_converter.py", line 71, in convert builder_functions"bits" File "/home/pi/.local/lib/python3.7/site-packages/pymodbus/payload.py", line 161, in add_bits value = pack_bitstring(values) File "/home/pi/.local/lib/python3.7/site-packages/pymodbus/utilities.py", line 91, in pack_bitstring for bit in bits: TypeError: 'bool' object is not iterable

Versions (please complete the following information):

imbeacon commented 3 years ago

Hi @smartwizint ,

The gateway expects an array with bits to write them, you may try to set return in the round switch widget to [0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0], where: 1 - value that you want to change.