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.72k stars 828 forks source link

[HELP] - RPC mqtt_connector - RPC not handled #1525

Open rosiste opened 5 days ago

rosiste commented 5 days ago

Hello, I have the Thingsboard Gateway v3.5.1 last snapshot build installed in a docker environment on a Ubuntu 24.04.1 LTS server. I have some devices connected to Thingsboard Gateway throught central MQTT broker. I'd like to control these devices throught MQTT with RPC requests, but I'm always get the following error message:

2024-09-15 23:09:29 - |INFO| - [mqtt_connector.py] - mqtt_connector - server_side_rpc_handler - 971 - Incoming server-side RPC: {'device': 'shelly-test-b1355c', 'data': {'id': 102, 'method': 'Switch.Set', 'params': 'true'}, 'id': <tb_gateway_mqtt.TBGatewayMqttClient object at 0x70bba8e46f60>}
2024-09-15 23:09:29 - |ERROR| - [mqtt_connector.py] - mqtt_connector - server_side_rpc_handler - 1008 - RPC not handled: {'device': 'shelly-test-b1355c', 'data': {'id': 102, 'method': 'Switch.Set', 'params': 'true'}, 'id': <tb_gateway_mqtt.TBGatewayMqttClient object at 0x70bba8e46f60>}

Configuration

{
  "broker": {
    "name": "Lokalni TBMQTT broker",
    "host": "10.66.50.20",
    "port": 1883,
    "clientId": "tb-gateway",
    "version": 5,
    "maxMessageNumberPerWorker": 10,
    "maxNumberOfWorkers": 100,
    "sendDataOnlyOnChange": false,
    "security": {
      "type": "basic",
      "username": "user",
      "password": "pwd"
    }
  },
  "mapping": [
    {
      "topicFilter": "shelly/+/status/switch:0",
      "converter": {
        "type": "json",
        "deviceNameTopicExpression": "(?<=shelly/)(.*?)(?=/status/switch:0)",
        "deviceTypeTopicExpression": "Shelly Plus1PM",
        "sendDataOnlyOnChange": false,
        "timeout": 60000,
        "timeseries": [
          {
            "type": "bool",
            "key": "Output",
            "value": "${output}"
          },
          {
            "type": "double",
            "key": "Current",
            "value": "${current}"
          },
          {
            "type": "double",
            "key": "Voltage",
            "value": "${voltage}"
          },
          {
            "type": "double",
            "key": "Apparent_Energy",
            "value": "${aenergy.total}"
          },
          {
            "type": "double",
            "key": "Apparent_Power",
            "value": "${apower}"
          }
        ],
        "attributes": [
          {
            "type": "bool",
            "key": "Output",
            "value": "${output}"
          }
        ]
      }
    }
  ],
  "serverSideRpc": [
    {
      "deviceNameFilter": ".*",
      "methodFilter": "Switch.Set",
      "requestTopicExpression": "shelly/${deviceName}/rpc",
      "valueExpression": "{'method':'Switch.Set',params:{'id':0,'on':${params}}"
    }
  ],
  "logLevel": "DEBUG",
  "name": "MQTT Broker - lokalni server",
  "enableRemoteLogging": false,
  "id": "0298387e-3703-4974-920a-1634cf24a6aa"
}

But I can control the device with simple mosquitto client with the following command:

mosquitto_pub -h 10.66.50.20 -p 1883 -t 'shelly/shelly-test-b1355c/rpc' -m '{"method":"Switch.Set","params":{"id":0,"on":false}}' -u 'user' -P 'pwd' -i 'tb-gateway'

Versions (please complete the following information):

rosiste commented 4 days ago

Found following line in debug log even if serveSideRpc section is present in config file. Config file checked with public online JSON validator without errors.


2024-09-16 20:08:52 - |DEBUG| - [mqtt_connector.py] - mqtt_connector - load_handlers - 323 - 'serverSideRpc' section missing from configuration