TheengsGateway Docker container doesn’t send MQTT messages

I can’t understand what’s going on—please help me.

I started investigating TheengsGateway using a local Python package. Everything worked fine: both BLE devices and the MQTT server were recognized, advertising data was received, and MQTT messages were sent.

Then, I ran TheengsGateway as a Docker container. Everything seemed to work: both BLE devices and the MQTT server were recognized, and advertising data was received…

But MQTT messages are not sent at all. The MQTT server receives the “active” event from the gateway, but that’s it.

I’m using the latest version of the Docker container. Running the pip list command shows that package versions are the same in both the container and the local host.

I’ve double check container and local debug logs for the gateway parameters - they are the same.

What could be wrong?

Log from local host:

INFO:BLEGateway:Starting BLE scan
INFO:BLEGateway:Connected to MQTT broker
INFO:BLEGateway:Subscribed to home/+/BTtoMQTT/undecoded
.........
DEBUG:BLEGateway:F4:FC:00:00:13:1D:AdvertisementData(local_name='ThermoBeacon', manufacturer_data={16: b'\x00\x00\x1d\x13\x00\x00\xfc\xf4\xe0\x0b@\x01e\x04\x86D\x07\x00'}, service_uuids=['0000fff0-0000-10
INFO:BLEGateway:publishing device `{'name': 'ThermoBeacon', 'id': 'F4:FC:00:00:13:1D', 'rssi': -56, 'brand': 'GENERIC', 'model': 'ThermoBeacon', 'model_id': 'WS02/WS08', 'type': 'THB', 'tempc': 20, 'tempf76294, 'mac': 'F4:FC:00:00:13:1D'}`
DEBUG:BLEGateway:Sent `{"stat_t": "+/+/BTtoMQTT/F4FC0000131D", "dev_cla": "voltage", "unit_of_meas": "V", "state_class": "measurement", "name": "WS02/WS08-volt", "uniq_id": "F4FC0000131D-volt", "val_tpl":": {"ids": ["F4FC0000131D"], "cns": [["mac", "F4FC0000131D"]], "mf": "GENERIC", "mdl": "WS02/WS08", "name": "ThermoBeacon-00131D", "via_device": "TheengsGateway"}}` to topic `homeassistant/sensor/F4FC0000
DEBUG:BLEGateway:Sent `{"stat_t": "+/+/BTtoMQTT/F4FC0000131D", "dev_cla": "temperature", "unit_of_meas": "\u00b0C", "state_class": "measurement", "name": "WS02/WS08-tempc", "uniq_id": "F4FC0000131D-tempc" }}", "device": {"ids": ["F4FC0000131D"], "cns": [["mac", "F4FC0000131D"]], "mf": "GENERIC", "mdl": "WS02/WS08", "name": "ThermoBeacon-00131D", "via_device": "TheengsGateway"}}` to topic `homeassistant/se
DEBUG:BLEGateway:Sent `{"stat_t": "+/+/BTtoMQTT/F4FC0000131D", "dev_cla": "humidity", "unit_of_meas": "%", "state_class": "measurement", "name": "WS02/WS08-hum", "uniq_id": "F4FC0000131D-hum", "val_tpl":  {"ids": ["F4FC0000131D"], "cns": [["mac", "F4FC0000131D"]], "mf": "GENERIC", "mdl": "WS02/WS08", "name": "ThermoBeacon-00131D", "via_device": "TheengsGateway"}}` to topic `homeassistant/sensor/F4FC000013
DEBUG:BLEGateway:Sent `{"stat_t": "+/+/BTtoMQTT/F4FC0000131D", "name": "WS02/WS08-time", "uniq_id": "F4FC0000131D-time", "val_tpl": "{{ value_json.time | is_defined }}", "device": {"ids": ["F4FC0000131D"]ERIC", "mdl": "WS02/WS08", "name": "ThermoBeacon-00131D", "via_device": "TheengsGateway"}}` to topic `homeassistant/sensor/F4FC0000131D-time/config`
DEBUG:BLEGateway:Sent `{"stat_t": "+/+/BTtoMQTT/F4FC0000131D", "dev_cla": "temperature", "unit_of_meas": "\u00b0C", "state_class": "measurement", "name": "WS02/WS08-tempc_max", "uniq_id": "F4FC0000131D-te| is_defined }}", "device": {"ids": ["F4FC0000131D"], "cns": [["mac", "F4FC0000131D"]], "mf": "GENERIC", "mdl": "WS02/WS08", "name": "ThermoBeacon-00131D", "via_device": "TheengsGateway"}}` to topic `home
.........
INFO:BLEGateway:Sent 15 messages to MQTT

Log from the docker container:

theengs-gateway    | INFO:BLEGateway:Starting BLE scan
theengs-gateway    | INFO:BLEGateway:Connected to MQTT broker
theengs-gateway    | INFO:BLEGateway:Subscribed to home/TheengsGateway/commands
.........
theengs-gateway    | DEBUG:BLEGateway:F4:FC:00:00:13:1D:AdvertisementData(local_name='ThermoBeacon', manufacturer_data={16: b'\x00\x00\x1d\x13\x00\x00\xfc\xf4l\x01\x9f\x00\x00\x00\x1e\x01^\xb3\x06\x00'}, 9b34fb'], tx_power=0, rssi=-64)
theengs-gateway    | DEBUG:BLEGateway:4F:65:2C:7B:A9:F6:AdvertisementData(manufacturer_data={76: b'\x07\x19\x01\x0f +\x99\x8f\x00\x00\x08\xa0\xce\xee\xc5\x06\x10\x17\xafs\xce\x16V\xf4\x16I\n'}, rssi=-74)
theengs-gateway    | DEBUG:BLEGateway:B4:0E:CF:4E:13:F2:AdvertisementData(local_name='TL-B40ECF4E13F1', manufacturer_data={256: b'@\x00'}, rssi=-84)
.........
INFO:BLEGateway:Sent 0 messages to MQTT

Hi again @xmlIgor

Good to hear you got things working with the Python package of Theengs Gateway.

Why the Docker image does behave differently for you though I really can’t say, and not having used the Docker image myself.

From your log however, it appears that the BLE broadcasts are received correctly, but no decoding is happening, hence no decoded MQTT messages are being published.

As TheengsGateway Docker v1.5.0.2 has only been released very recently, can you see if v1.4.0.1 is still available. Your WS02/WS08 was already available in that version.

Hi!

Unfortunately there is only one version - ‘latest’

Not necessarily the preferred way, but when you search for Theengs on Docker Hub you will also find several other Docker images from Theengs Gateway :wink:

Sorted by recently Updated, you might want to try on of these, just to see if they might be have differently to our current container.

Let us know how you get on

I prefer to use a Docker image from the official developer, but at least this one is working:

fmunsch/theengsgateway-docker:1.5.0.1

Thanks! I’ll keep going and still wait for a good image from theengs.io :wink:

1 Like

Hi @xmlIgor

The Docker image has just been updated to v1.5.0.4. You can get

docker pull theengs/gateway

Thanks, it’s working now.

May I suggest a small improvement for the start.sh script? I’d like to use an external config file for the TheengsGateway package. Currently, the configuration file ($HOME/theengsgw.conf) is created every time the Docker container starts, which is not very convenient when modifying parameters. In the current implementation, you have to recreate the container after changing parameters.

It would be more convenient to have .config outside the Docker container. This way, you would only need to restart the container instead of recreating it.

Here’s an example implementation:

CONFIG="${CONFIG_FILE:-$HOME/theengsgw.conf}"

cd $VIRTUAL_ENV

# If the configuration file doesn't exist, create it by reading environment variables
if [ ! -f "$CONFIG" ]; then
    createconf
fi

cat "$CONFIG"

if [ "$CONFIG_FILE" ]; then
    PARAMS="$PARAMS -c $CONFIG_FILE"
fi

python3 -m TheengsGateway $PARAMS

and a docker-compose.yaml example

    environment:
      - CONFIG_FILE=/opt/venv/config.json
    volumes:
      - /opt/tgateway/config.json:/opt/venv/config.json

Disclaimer – I’m not a pro at Bash scripting