Tradfri Gateway not discovered

I run Openhab 2.40 as docker container on my RPi3 and the Tradfri binding 0.10.0.oh240 does not discover my Tradfri Gateway v1.8.25 if

  • I use the addons.cfg for installing the binding and if
  • I create a tradfri.things for configuring the host address and security code and adding several Tradfri devices to my system

I use the following configuration:

addons.cfg

binding = zwave,icloud,astro,openweathermap,chromecast,tradfri

tradfri.things

Bridge tradfri:gateway:gwa0c9a0d93fe7 "Tradfri Gateway" [ host="192.168.0.121", code="fy6RrG" ] {
    0220 traColorTempBulbLiv1 "TradFri WZ Leuchte 1" [ id=65562 ]
    0220 traColorTempBulbLiv2 "TradFri WZ Leuchte 2" [ id=65564 ]
    0220 traColorTempBulbLiv3 "TradFri WZ Leuchte 3" [ id=65565 ]
    0830 traRemoteControlLiv1 "TradFri WZ Fernbedienung 1" [ id=65561 ]
}

Once the binding is installed and started I got the following error

[hingStatusInfoChangedEvent] - ‘tradfri:gateway:gwa0c9a0d93fe7’ changed from UNKNOWN to OFFLINE (COMMUNICATION_ERROR)

Checking the logs reveals an error in the establishment of a connection to the Tradfri Gateway as follows

20:31:58.032 [WARN ] [discovery.TradfriDiscoveryParticipant] - Discovered Tradfri gateway doesn't have an IP address: [ServiceInfoImpl@29124738 name: 'gw-a0c9a0d93fe7._coap._udp.local.' address: '(null):5684' status: 'NO DNS state: probing 1 task: null', has NO data, empty]
20:31:58.050 [DEBUG] [org.eclipse.smarthome.binding.tradfri] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={service.id=407, service.bundleid=266, service.scope=bundle, component.name=org.eclipse.smarthome.binding.tradfri.internal.TradfriHandlerFactory, component.id=245} - org.eclipse.smarthome.binding.tradfri
20:31:58.277 [DEBUG] [org.eclipse.smarthome.binding.tradfri] - ServiceEvent REGISTERED - {org.eclipse.smarthome.config.discovery.DiscoveryService}={service.id=408, service.bundleid=266, service.scope=singleton} - org.eclipse.smarthome.binding.tradfri
20:31:58.549 [DEBUG] [ng.tradfri.internal.TradfriCoapClient] - CoAP GET request
uri: coaps://192.168.0.121:5684/15011/15012
20:32:58.630 [DEBUG] [ng.tradfri.internal.TradfriCoapClient] - CoAP GET request
uri: coaps://192.168.0.121:5684/15011/15012
20:33:10.972 [DEBUG] [g.tradfri.internal.TradfriCoapHandler] - CoAP onError
20:33:17.652 [DEBUG] [g.tradfri.internal.TradfriCoapHandler] - CoAP onError

The installation and setup of the Tradfri binding over the UI works as expected. The binding finds the Tradfri GW and once I set the security code the binding connects to the Tradfri GW and gets the list of known Tradfri devices. But this is not the way I want to add my devices to my system.

I am not able to run Tradfri binding by using the configuration file. Any ideas what could cause the error (CoAP onError)?

There are several threads and bugs on github WRT tradfri communication errors.
You may want to try an approach discussed at:

Thanks for the hint. Using the below configuration file for the binding solved it, also after I restarted the Tradfri Gateway.

Bridge tradfri:gateway:gwa0c9a0d93fe7 "Tradfri Gateway" [ host="192.168.0.121", identity="7270d", preSharedKey="Sqdg" ] { 
    0220 traColorTempBulbLiv1 "TradFri WZ Leuchte 1" [ id=65562 ]
}