Reads Stiebel Eltron Heatpump CAN Bus data and transmits it over MQTT
This project provides a Python script (can_reader.py
) to read CAN messages from the socketcan
interface, interpret them using an Elster-specific lookup table (elster_table.py
), and optionally publish the interpreted values to an MQTT broker (only if the messages indicate a response/answer).
- Reads CAN data from the
can0
interface on Linux-based systems (like a Raspberry Pi). - Interprets specific data fields called Elster indexes, using an external table
elster_table.py
. - Publishes interpreted data to an MQTT broker (if desired).
- Allows various command-line parameters to customize behavior, including verbosity level, MQTT server credentials, and more.
- Differentiates CAN telegram types (e.g., Request, Answer, Change) and only publishes Answers to MQTT by default.
- Python 3.7+ recommended.
- SocketCAN properly configured on your Linux system (e.g.,
can0
). - pip installed to handle Python packages.
python-can
library:pip install python-can
paho-mqtt
library (for MQTT support):
pip install paho-mqtt
- The elster_table.py file, which contains:
- lookup_elster_index(index): returns a dictionary with fields like "Name", "EnglishName", "Type", etc.
- interpret_elster_value(raw_value, elster_type): returns a properly interpreted Python value from the raw data.
- Clone this repository:
git clone [https://github.com/michaelhenningersrb/Stiebel-Eltron-CAN-Bus-to-MQTT-Reader](https://github.com/michaelhenningersrb/Stiebel-Eltron-CAN-Bus-to-MQTT-Reader)
cd Stiebel-Eltron-CAN-Bus-to-MQTT-Reader
- Install the required dependencies:
pip install -r requirements.txt
Alternatively, install them manually as per the prerequisites above.
- Configure your socketcan interface (can0):
# Example: set up can0 at 500 kbit/s
sudo ip link set can0 up type can bitrate 500000
sudo ifconfig can0 up
- Run the script with your desired parameters:
python can_reader.py \
--mqtt-server 192.168.1.50 \
--mqtt-user myuser \
--mqtt-pass secret \
--mqtt-prefix home/elster/ \
--verbosity 2
Adjust the above command to match your environment (e.g., different mqtt-server, no user/password, etc.).
- Observe the output:
With --verbosity 2
, each CAN message displays essential details (telegram type, Elster index, interpreted value, etc.).
If --verbosity 3
, you see more debug info (raw data, message details).
0
= none
1
= minimal
2
= standard
3
= debug
MQTT messages are published only for answers (telegram_type == 2), unless you modify the code.
Parameter Description Default
- Minimal logs, only show short output on answered messages:
python can_reader.py --verbosity 1
- Debug logs, with full MQTT config:
python can_reader.py \
--mqtt-server 192.168.1.50 \
--mqtt-port 1883 \
--mqtt-user user123 \
--mqtt-pass p4ssW0rd \
--mqtt-prefix hvac/elster/ \
--verbosity 3
-
can_reader.py
Main script. Handles:- Parsing command-line arguments.
- Connecting to the can0 interface.
- Reading CAN messages in a loop.
- Determining if a message is a request, answer, or change.
- Looking up the Elster index and interpreting the raw value.
- Optionally publishing via MQTT (if type == answer).
-
elster_table.py
External file containing:
- A dictionary or function to map Elster indexes to metadata (like Name, Type, etc.).
- A function (interpret_elster_value) to convert raw integer data into human-readable values (e.g., temperature, pressure, etc.).
-
requirements.txt (optional) If present, it might contain:
python-can paho-mqtt
- Fork the repository on GitHub.
- Create a new branch for your features or bug fixes.
- Commit your changes with clear messages.
- Push your branch to your forked repository.
- Open a pull request on GitHub.
MIT
Enjoy reading the Elster data from your CAN bus! If you have any questions, feel free to open an issue or PR.