MQTT bridge for Danfoss eTRV thermostats. Supports MQTT autodiscovery in Home Assistant.
Device links are supported so Home Assistant sees all sensors as a single logical entity

- github.com/keton/etrv2mqtt: Original project from keton, archived and no longer maintained
- github.com/Cymaphore/etrv2mqtt: Actively maintained fork, various enhancements; Primary target platform: RasperryPi Zero 2 W (running RaspberryPi OS Bullseye)
- github.com/cg-ite/etrv2mqtt: Experimental fork; Primary target platform RaspberryPi 3 / dietpi with bluepy3, not yet stable
After keton discontinued development of etrv2mqtt, I (Cymaphore) forked the project and included various improvements over time. However, I didn't update the underlying bluetooth functionality for the rpi target platform yet, so my fork still relies on Debian Bullseye as a target environment for RaspberryPi. There is a fork of this repo from cg-ite that intends to perform that update, but it is still experimental/unstable and under development. Once that fork appears stable, I intend to merge it.
Install required packages (for Raspberry pi 3 and later)
sudo apt install bluez-tools bluez bluez-firmware bluez-hcidump pi-bluetoothInstall etrv2mqtt
mkdir -p ~/venv/etrv2mqtt
virtualenv ~/venv/etrv2mqtt
~/venv/etrv2mqtt/bin/pip3 install 'git+https://github.com/Cymaphore/etrv2mqtt.git'Minimal config.json example. All parameters are described here.
{
"$schema": "https://raw.githubusercontent.com/Cymaphore/etrv2mqtt/master/etrv2mqtt/schemas/config.schema.json",
"thermostats": [
{
"topic": "Room",
"address": "00:01:02:03:04:05",
"secret_key": "01020304050607080910111213141516"
},
{
"topic": "Kitchen",
"address": "02:03:04:03:04:05",
"secret_key": "11121304050607080910111213141516"
}
]
}- Scan for nearby thermostats:
sudo ~/venv/etrv2mqtt/bin/python3 -m libetrv.cli scan - Get secret key for a device:
~/venv/etrv2mqtt/bin/python3 -m libetrv.cli device --device-id 01:02:03:04:05:06 retrieve_key. Push physical button on thermostat when prompted.
~/venv/etrv2mqtt/bin/etrv2mqtt config.json
Configured devices should be automatically added to homeassistant as long as MQTT autodiscovery is enabled.
-
Create
/etc/systemd/system/etrv2mqtt@YOUR_USER.servicefile with YOUR_USER replaced by the user account that etrv2mqtt is installed to. For example default raspbian user is namedpiso the service file name is/etc/systemd/system/etrv2mqtt@pi.service. -
use following template:
[Unit] Description=etrv2mqtt After=network-online.target [Service] Type=simple User=%i Environment="LOGURU_LEVEL=INFO" ExecStart=/home/%i/venv/etrv2mqtt/bin/etrv2mqtt /home/%i/etrv2mqtt.config.json Restart=on-failure RestartSec=10s [Install] WantedBy=multi-user.target -
save your
config.jsonas~/etrv2mqtt.config.jsonor editetrv2mqtt@YOUR_USER.serviceaccordingly -
Update systemd configuration and start the service
sudo systemctl daemon-reload sudo systemctl enable etrv2mqtt@YOUR_USER.service sudo systemctl start etrv2mqtt@YOUR_USER.service
By default etrv2mqtt will emit autodiscovery messages so devices will be automatically added to Home Assistant. It will also listen to birth messages and will update thermostat values on HA restarts.
All this requires a bit of configuration on Home Assistant side. Please make sure you have following directives in your configuration.yaml:
mqtt:
discovery: true
broker: [YOUR MQTT BROKER]
birth_message:
topic: 'hass/status'
payload: 'online'