mdzio / ccu-jack

CCU-Jack bietet einen einfachen und sicheren REST- und MQTT-basierten Zugriff auf die Datenpunkte der Zentrale (CCU) des Hausautomations-Systems HomeMatic. Zudem können einfach Fremdgeräte an die CCU angebunden werden.
GNU General Public License v3.0
112 stars 11 forks source link

mqtt-server address not processed correct #122

Closed paulcombuse closed 1 year ago

paulcombuse commented 1 year ago

Thanks for a great tool first of all! Though, it currently doesn't work for me having it installed as addon on a RPi3B+ with current raspmatic_rpi3 (3.67.10.20230114). My MQTT server runs on a RPi4 with Home Assistant 2023.1.7 on HASSIO 9.4 (192.168.178.35) and is successfully used by a couple of other clients in my network. I use MQTT Explorer to keep track of the topics and messages. To configure the MQTT client of your addon I stopped CCU-JACK in the described way (/usr/local/etc/config/rc.d/ccu-jack stop), edited the config file as follows and started/initialized the addon afterwards.

{
  "CCU": {
    "Address": "127.0.0.1",
    "Interfaces": [
      "BidCosRF",
      "HmIPRF",
      "VirtualDevices"
    ],
    "InitID": "CCU-Jack"
  },
  "Host": {
    "Name": "homematic",
    "Address": "127.0.0.1"
  },
  "Logging": {
    "Level": "INFO",
    "FilePath": "/var/log/ccu-jack.log"
  },
  "HTTP": {
    "Port": 2121,
    "PortTLS": 2122,
    "CORSOrigins": [
      "*"
    ],
    "WebUIDir": "webui"
  },
  "MQTT": {
    "Port": 1883,
    "PortTLS": 8883,
    "BufferSize": 0,
    "WebSocketPath": "/ws-mqtt",
    "Bridge": {
      "Enable": true,
      "Address": "192.168.178.35",
      "Port": 1883,
      "UseTLS": false,
      "CACertFile": "",
      "Insecure": false,
      "Username": "mqtt-user",
      "Password": "mqtt-pw",
      "ClientID": "Homematic",
      "CleanSession": true,
      "Incoming": [
        {
          "Pattern": "#",
          "LocalPrefix": "remote/recv/",
          "RemotePrefix": "homematic/",
          "QoS": 2
        }
      ],
      "Outgoing": [
        {
          "Pattern": "#",
          "LocalPrefix": "remote/send/",
          "RemotePrefix": "homematic/",
          "QoS": 2
        }
      ]
    }
  },
  "BINRPC": {
    "Port": 2123
  },
  "Certificates": {
    "AutoGenerate": false,
    "CACertFile": "",
    "CAKeyFile": "",
    "ServerCertFile": "/etc/config/svrcert.pem",
    "ServerKeyFile": "/etc/config/svrcert.key"
  },
  "Users": {},
  "VirtualDevices": {
    "Enable": true,
    "NextSerialNo": 0,
    "Devices": {}
  }
}

As CCU-JACK and RaspberryMatic are running on the same device I defined 127.0.0.1 for both of them in the config file. Ports 1883, 8883, 21221, 2122, 2123 are opened in the Raspberrymatic Firewall as well as the MQTT broker IP 192.168.178.35 and the 127.0.0.1 (maybe for the latter it is not necessary?). Now looking in MQTT Explorer I do not see any new topic called "homematic" - what I would have expected. Additionally I see in the logs of CCU-JACK the following:

2023-01-26 21:38:07 | INFO | mqtt-bridge | Starting MQTT bridge
2023-01-26 21:38:07 | INFO | mqtt-server | Starting Secure MQTT listener on address tcp://:8883
2023-01-26 21:38:07 | INFO | http-server | Starting HTTPS server on address :2122
2023-01-26 21:38:07 | INFO | mqtt-server | Starting MQTT listener on address tcp://:1883

Now, that's where I assume that there is some kind of bug or wrong setup somewhere, as I would have expected something like tcp://192.168.178.35:1883 which is combined in your code from 'tcp://' + MQTT address + ":" + MQTT port.

Could you take a look at my config file and give me a hint what I am doing wrong or if there really is some kind of bug in the addon code, please? I really appreciate your efforts. Many thanks!

mdzio commented 1 year ago

Please try following configuration for the MQTT bridge:

      "Incoming": [
        {
          "Pattern": "#",
          "LocalPrefix": "",
          "RemotePrefix": "homematic/send/",
          "QoS": 2
        }
      ],
      "Outgoing": [
        {
          "Pattern": "#",
          "LocalPrefix": "",
          "RemotePrefix": "homematic/recv/",
          "QoS": 2
        }
      ]

The last three log messages are OK. They refer to the network server ports of the CCU-Jack. They have nothing to do with the MQTT bridge.

paulcombuse commented 1 year ago

@mdzio Thanks - seems to work now.