KNXD add-on: convert your KNX-USB interface into an IP interface that can be used by HA

how do you use the interface on your laptop. Also via knxd? It might be a good idea to try to get the USB interface running with knxd on your laptop first. If you manage to get it working I can see what I can do to get your required settings into the add-on

Hi,

well, i have found that other have similar problems with KNXd and some newer KNX interfaces - maybe the ones that supports large frames. It seems these interfaces needs to be put in a ready state in a different way than some older interfaces does.

I have found this patch that needs to be applied to the KNXd software, and then re-compiled - and put in your add-on. then it should work.

diff --git a/src/libserver/cemi.cpp b/src/libserver/cemi.cpp
index 08cd591…7297729 100644
— a/src/libserver/cemi.cpp
+++ b/src/libserver/cemi.cpp
@@ -72,6 +72,7 @@ void CEMIDriver::cmdClose()

void CEMIDriver::started()
{

  • sent_comm_mode = false;
    after_reset = true;
    reset_timer.start(0.5,0);
    sendReset();
    @@ -87,9 +88,32 @@ void CEMIDriver::do_send_Next()
    {
    if (after_reset)
    {
  •  after_reset = false;
    
  •  reset_timer.stop();
    
  •  EMI_Common::started();
    
  •  if (!sent_comm_mode)
    
  •    {
    
  •      sent_comm_mode = true;
    
  •      // Set the comm mode to "Data Link Layer" (0x00)
    
  •      CArray set_comm_mode;
    
  •      set_comm_mode.resize (8);
    
  •      set_comm_mode[0] = 0xf6; // Message Code (MC), M_PropWrite.req
    
  •      // Interface Object Type = cEMI Server Object
    
  •      set_comm_mode[1] = 0x00; // IOTH
    
  •      set_comm_mode[2] = 0x08; // IOTL
    
  •      set_comm_mode[3] = 0x01; // Object Instance (OI)
    
  •      set_comm_mode[4] = 0x34; // Property ID (PID), PID_COMM_MODE (52)
    
  •      // number of elements (NoE) = 0x1
    
  •      // start index (SIx) = 0x001
    
  •      set_comm_mode[5] = 0x10; // NoE, SIx
    
  •      set_comm_mode[6] = 0x01; // SIx
    
  •      set_comm_mode[7] = 0x00; // Data (0x00 is "Data Link Layer")
    
  •      send_Data (set_comm_mode);
    
  •    }
    
  •  else
    
  •    {
    
  •      after_reset = false;
    
  •      reset_timer.stop();
    
  •      EMI_Common::started();
    
  •    }
    

    }
    else
    EMI_Common::do_send_Next();
    diff --git a/src/libserver/cemi.h b/src/libserver/cemi.h
    index f5e758e…ea3896c 100644
    — a/src/libserver/cemi.h
    +++ b/src/libserver/cemi.h
    @@ -59,6 +59,7 @@ private:
    void sendLocal_done_cb(bool success);

    bool after_reset = false;

  • bool sent_comm_mode = false;

    ev::timer reset_timer;
    void reset_timer_cb(ev::timer &w, int revents);

My problem is, that i am not good in this - so i guess it needs to be put in the KNXd upstream for a new release - and then after that you will get it and can add it in your add-on?

Dennis

while I probably could patch it for the add-on, I would prefer if the patch went upstream.

Yes, it would be of great help if you could. I understand you would like it to be upstream - however it seems that nothing has been released for the past 6 months from the project - and i guess it will not happen anytime soon :frowning:

Dennis

patching will also not happen any time soon since my sparetime is limited atm and I would also need to work on a system that allowed patching during the creation of the docker image. I could simply fork the knxd repo, apply the patch there and use my repo instead of the orignal one, but I won’t open that can of worms (yet another thing to maintain).
Also, were you able to verify that the patch actually works for you or is it just a guess that the patch fixes things?

@Chaospilot since another user had issues with his USB interface, I went the extra mile and create a beta repo where I added an add-on with a patched knxd version. It would be great if you could test the version from this repo GitHub - da-anda/hass-io-addons-beta: Beta testing channel of HomeAssistant add-ons and report back if this fixes the issue for you.

Anybody else is also welcome to test this build if it causes issues with your USB-interface, so that I know if I can add this patch to the official version of the add-on (although I am not really keen on the extra work required to keep the necessary knxd fork up to date)

@da-anda Just FYI there is a second addon enabling Knx Usb and Uart Devices to be used by HA based on Calimero. I have not tested it myself but it might be worth a try - especially if you don’t want to maintain this.

I have no problem keeping the knxd add-on up2date and maintain it (since I use it myself), but I’m not keen on providing and maintaining patched version of knxd via the add-on. Providing the patched version was just a try to see if it fixes things and that maybe upstream knxd would merge the patch into master once confirmed working by more users.

Thanks for the headsup about calimero - hadn’t heard of that before. Not a big fan of running a JavaVM in a docker container just for a KNX bridge though. But good to see there is an alternative if development of knxd stalls.

An Addon is a docker container anyway so I guess that’s no big deal running Java 🤷

It’s also used for OpenHAB as Knx driver so there is quite a user base I guess.

But of course, if knxd works fine and you like to keep maintaining the addon, all power to you :+1::muscle:

Java remains java, no matter where it’s running :wink: Also, Calimero using Java should have more overhead than running a native C library like knxd.

But if everything fails or sucks in the end, I’ll just grab an IP interface and be done :slight_smile: (should have spent those extra 30 bucks right away on hindsight)

Hi, I found your post. i would like ask, if you have working solution to connect synco living to home assistant ?

not familiar with Synco living, but since it appears to be KNX based, likely any KNX interface might work. Ideally go for an IP interface for the protocol you are using (RF or TP) since you won’t need this add-on in that case.

But it appears as if Synco also has some webserver components, so if you already have one of those, you might be able to integrate these somehow. You would have to read the documention of those webserver components to see if they have an API you could use in HomeAssistant

edit: how do you currently interact with this system?

Got this message trying to start up KNXD today in home assistant

Failed to start add-on

Image Package hass-io-addons-armv7-addon-knxd · GitHub does not exist for addon_ecaeb50e_knxd

From my understanding it seems like is it just a matter of the docker image deployed on GitHub not being in sync with the repo?

Anyone experienced anything similar before?

wait, does HA expect the image to match the SHA of the GIT repo? All that happened in the meantime is that docker scripts got updated to their latest version, but nothing changed that would require a new image.

I’m unfortunately burried in work and super stressed out to look into this, but if anybody knows what the root cause might be, I certainly can push a fix or do a quick version bump that triggers the build of a new image

I am unsure if it is a SHA checksum issue with the repo or not but I was able to get the add-on to run again by pulling the docker image down manually.

docker pull ghcr.io/da-anda/hass-io-addons-armv7-addon-knxd:0.4.4

Hopefully this helps if someone else is experiencing the same issue

Anyone else having problems with the add-on after the last update?
At the moment I’m not able to use KNX…
The add-on log is full with these messages:
Assertion failed: !is_local (lowlevel.cpp: send_Local: 57)

Ok nevermind, I now bought an KNX IP Interface which will safe me some pain. Thanks for providing the add-on

Hi,
I have also some trouble but I think I am just too stupid for this. :frowning:

I have an MDT USB interface and my config looks like this:

    "address": "0.0.245",
    "client_address": "0.0.246:5",
    "interface": "usb",
    "device": "/dev/ttyAMA0",
    "usb_filters": "single",
    "custom_config": ""

I have not set any IP address.

The logs look good too me too:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 2-init-config: executing... 
[18:32:09] INFO: Interface:      usb
[18:32:09] INFO: Device:         /dev/ttyAMA0
[18:32:09] INFO: Address:        0.0.245
[18:32:09] INFO: Client Address: 0.0.246:5
[18:32:09] INFO: Filters:        single
[18:32:09] INFO: Log-Level:      debug
[18:32:09] INFO: IP-Address:     
[18:32:09] INFO: Dest-Port:      99
[cont-init.d] 2-init-config: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
I00000131: [ 1:main] 0.14.53: knxd /etc/knxd.ini
I00000129: [ 1:main] Connected: cfg:interface-usb.
I00000129: [ 1:main] Connected: cfg:A.tcp.
I00000129: [ 1:main] Connected: cfg:server.
W00000126: [ 1:main] knxd should not run as root
libusb: error [get_usbfs_fd] libusb couldn't open USB device /dev/bus/usb/001/004, errno=1
N00000127: [23:router.pace_] The 'pace' filter without a queue acts globally.

But how do I add sensors and stuff like that now?
I have configured the normal KNX integration with all the group addresses and stuff like that like this:

# configuration.yaml
knx: !include knx.yaml

# knx.yaml
sensor: !include knx_sensors.yaml

# knx_sensors.yaml
- name: 'Kitchen Temp'
  state_address: '1/0/20'

I see all the entities on the KNX integration so the config doesn’t seem to be wrong.

But what type of connection do I have to choose here? Automatic does not work and tunnel or routing neither.

I am running a Raspberry 4 with HassOS (the image officially available from Home Assistant).

The integration version is Version: 0.4.4

Please give me some advice :confused:

Thank you for your work and time!

You’ll probably have to sort that out before you proceed with the KNX integration.
You can connect via tunnelling or routing (prefer tunnelling!) to knxd based on its configuration.

1 Like

Thank you! I have done some reseach but couldnt find anything regarding this error :frowning: