Theengs Gateway: Bindkeys and docker

Hi again,

currently, I can run Theengs Gateway only in a Docker container. I have a hard time passing bindkeys though.

The docs do not list these as one of the environment parameters for the container at all. The start.sh script inside the container evaluates BINDKEYS, if it exists in the environment though.

I’m not a Python expert regrettably so I failed to simply inject it into the config so far.

If I pass something like

    -e BINDKEYS="<MAC> <bindkey>" \

on container creation the whole thing implodes because the script itself writes a malformed config file:

Malformed configuration file /root/theengsgw.conf: Expecting value: line 29 column 18 (char 878)

What’s the intended way to do it in my case? Or does anyone have a valid sample config line? (there’s like 0 google results for a config with a non-empty bindkeys entry)

Thanks!

Admittedly not having any personal experience with the Docker version myself, have you tried

-e BINDKEYS={"MAC":"bindkey"} \

Now I did. Doesn’t work either but gives a different error message probably from the cmdline argument parser

Malformed configuration file /root/theengsgw.conf: Expecting property name enclosed in double quotes: line 29 column 19 (char 879)

Hm. I actually wanted to avoid polluting the Docker host with the Python environment just to see how the script then writes out the config file :rofl:

I’ll have another look over the code.

Best for someone with more Docker image experience to have a look into and comment this :slight_smile:

Okay, I can answer this myself now!

The config file needs the following format for this:

    "bindkeys": {
        "<MAC>": "<bindkey>"
    },

This leaves open the question how to feed it properly into a docker run command though.

This does not work?

docker run --rm \
    --network host \
    -e MQTT_HOST=<host_ip> \
    -e MQTT_USERNAME=<username> \
    -e MQTT_PASSWORD=<password> \
    -e MQTT_PUB_TOPIC=home/TheengsGateway/BTtoMQTT \
    -e MQTT_SUB_TOPIC=home/TheengsGateway/commands \
    -e PUBLISH_ALL=true \
    -e TIME_BETWEEN=60 \
    -e SCAN_TIME=60 \
    -e LOG_LEVEL=DEBUG \
    -e HASS_DISCOVERY=true \
    -e DISCOVERY=true \
    -e DISCOVERY_TOPIC=homeassistant/sensor \
    -e DISCOVERY_DEVICE_NAME=TheengsGateway \
    -e DISCOVERY_FILTER="[IBEACON,GAEN,MS-CDP]" \
    -e SCANNING_MODE=active
    -e ADAPTER=hci0 \
    -e TIME_SYNC: "[]" \
    -e TIME_FORMAT: 0 \
    -e BINDKEYS: "{\"00:11:22:33:44:55:66\":\"0dc540f3025b474b9ef1085e051b1add\",\"AA:BB:CC:DD:EE:FF\":\"6385424e1b0341109942ad2a6bb42e58\"}" \
    -e ENABLE_TLS: false \
    -e ENABLE_WEBSOCKET: false \
    -e IDENTITIES: "{\"00:11:22:33:44:55:66\":\"0dc540f3025b474b9ef1085e051b1add\",\"AA:BB:CC:DD:EE:FF\":\"6385424e1b0341109942ad2a6bb42e58\"}" \
    -v /var/run/dbus:/var/run/dbus \
    --name TheengsGateway \
    theengs/gateway

Alternative that works for me:

docker run --network host --privileged -e MQTT_HOST=192.168.1.17 -e ADAPTER=hci0 -e MQTT_USERNAME=user -e MQTT_PASSWORD=password -e LOG_LEVE=INFO -e IDENTITIES="{\"CC:AA:CC:DD:CC:CC\": \"keykeykeykeykeykey==\"}" -v /var/run/dbus:/var/run/dbus --name theengsgateway theengs/gateway

Thanks for that, works as well.

I humbly suggest to update the website part regarding the Docker setup with these two parameters as well.

1 Like

I added the example.

1 Like