Skip to content

a daemon to decode LT Thermometer devices and send through MQTT to Domoticz / Home Assistant

License

rpeyron/blelt2mqtt

Repository files navigation

blelt2mqtt : Bluetooth LE LT Thermometer 2 MQTT

This software is a simple gateway to publish on MQTT for use with Home Assistant or Domoticz temperature data from cheap bluetooth LT Thermometer sensors.

Supported devices

Currently, protocol versions 3 and 4 are supported. Other versions might be supported as well, as there seems to be little to no changes in between 3 and 4.

Note for V3 users:
It is very likely V3 users will experience a battery drain issue which seems to be fixed in V4 devices. This is the main reason the workarounds in blelt2mqtt attempting to resolve this issue have been removed. Please feel free to file an issue in case you are using a V3 device and experiencing the battery drain mentioned.

Device Protocol Version Article # Model # Photo Where to find (examples)
LT Thermometer v3 V3 LT Thermometer AliExpress
Mebus Digitales Thermo- und Hygrometer mit drahtloser Übertragung V4 11332 ATN0148 Mebus LT Thermometer Kaufland supermarkets
Mebus Group

These devices are supported by an android application named "qaqa" which is, among other place, available here:

Installation

Prerequisites:

  • Linux, Windows or MacOS (only tested on Linux / Raspberry Pi and Windows 11)
  • Bluetooth LE compatible device (with installed stack)
  • Python3 with pip3

blelt2mqtt can be installed and ran in multiple ways. Two of those methods are explained below. The first being a simple daemon running as your current user. The second, preferred way, as a systemd service running as a dedicated system user.

Method 1: User daemon

Installation steps:

1. Optional: Create a virtual environment (venv)

Debian users will need to install python-venv first if not installed! Python will warn you about that.

First, create a virtual environment:

# Create the venv
python3 -m venv .venv
# Activate the venv
source .venv/bin/activate

To be sure, let's first upgrade PIP in our fresh venv:

python3 -m pip install --upgrade pip

2. Install needed Python modules (bleak, paho-mqtt)

pip3 install -r requirements.txt

3. Configure your sensor and MQTT server in the configuration file

Please take a moment to review and set up the configuration. Your devices and (optional) MQTT broker setup is done here.

blelt2mqtt comes with a default (example) configuration file config-default.yaml. Although you can edit this file directly, it is recommended to copy it to config.yaml and make your changes there. blelt2mqtt will first look for config.yaml and, in case that fails, load config-default.yaml as a last resort.

4. To ensure the software is launched at startup :

crontab -e

@reboot bash /path/to/blelt.sh

Method 2: System service

1. Create system user

First, let's create a dedicated system user with a home directory. The home directory will be user for by example caching and log files.

# Add dedicated system user and group with home (for caching etc)
sudo useradd -rm blelt2mqtt

2. Create directory and set permissions

# Create directory and set permissions
sudo mkdir /opt/blelt2mqtt
sudo chown blelt2mqtt:blelt2mqtt /opt/blelt2mqtt

3. Download blelt2mqtt

Either download the latest release of blelt2mqtt in your preferred way or clone the git repository:

cd /opt/blelt2mqtt
git clone https://github.com/rpeyron/blelt2mqtt.git .

4. Setup venv and requirements

4.1 Switch to our dedicated user, create a venv and activate it
# Switch to dedicated user
sudo -u blelt2mqtt -H -s
# Create venv
cd /opt/blelt2mqtt
python -m venv .venv
# Activate venv
source .venv/bin/activate
4.2 Upgrade pip
python -m pip install --upgrade pip
4.3 Install requirements
pip install -r requirements.txt

5. Configure blelt2mqtt

Please take a moment to review and set up the configuration. Your devices and (optional) MQTT broker setup is done here.

blelt2mqtt comes with a default (example) configuration file config-default.yaml. Although you can edit this file directly, it is recommended to copy it to config.yaml and make your changes there. blelt2mqtt will first look for config.yaml and, in case that fails, load config-default.yaml as a last resort.

6. Install and start service

An example, ready-to-use service file is bundled with blelt2mqtt and located in the installation directory. In case you diverged from the given path by, for example, changing paths, please edit blelt2mqtt.service before continuing.

# Copy the service file
sudo cp /opt/blelt2mqtt/blelt2mqtt.service /etc/systemd/system
# Reload services
sudo systemctl daemon-reload
# Start the blelt2mqtt service
sudo systemctl start blelt2mqtt.service

In case you want the service to always be enabled, for example after a reboot, simply enable the service:

sudo systemctl enable blelt2mqtt.service

Configure Domoticz / Home Assistant

This should not require extra configuration for use with MQTT auto-discovery.

Domoticz

If you want to have a domoticz sensor with temperature and humidity, you need to follow these steps:

  1. Configure a virtual sensor Temperature+Humidity through the Dummy hardware in Hardware menu
  2. Read the idx of the created device in the Devices menu
  3. Add the idx in the configuration file as 'domoticz_idx'

You should now see the sensor (native sensor on the left, auto-discovered on the right) : Example of sensor in domoticz

Home Assistant

By default, the auto-discovered device is a MQTT device with the components temperature, humidity and battery.

Extracting attributes as entities

In case you want to extract data from the attributes as separate entities (and possibly manipulate the extracted data) follow the steps below. This gives an example of manipulating the temperature entity and creating a separate humidity entity.

  1. Open configuration.yaml
  2. Add the following. Replace <DEVICE.NAME> with your device's bluetooth name.
# blelt2mqtt sensor example
mqtt:
  - sensor:
    - name: "My Area - Temperature"
      state_topic: "lt_temp/<DEVICE.NAME>>/state"
      suggested_display_precision: 1
      unit_of_measurement: "°C"
      value_template: "{{ value_json.temperature }}"
    - name: "My Area - Humidity"
      state_topic: "lt_temp/<DEVICE.NAME>/state"
      unit_of_measurement: "%"
      value_template: "{{ value_json.humidity }}"
  1. Check the configuration and reload Home Assistant.

Using sensor cards

  1. Edit dashboard
  2. Add to dashboard > by card
  3. Choose Sensor
  4. Configure the sensor data you want to display as desired.

Protocol

The reverse-engineered protocol is described in protocol.md and the process is described in this article (in french)

Useful links

License & Credits

GPL-3.0

2022 - Remi Peyronnet

Contributions:
Maghiel Dijksman

About

a daemon to decode LT Thermometer devices and send through MQTT to Domoticz / Home Assistant

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •