A Docker-based application that connects to Kronoterm heat pumps via Modbus TCP and publishes data to MQTT for Home Assistant integration.
Kronoterm MQTT reads data from Kronoterm heat pumps connected via Modbus TCP interface and publishes it to an MQTT broker. Home Assistant can then discover and display the sensor readings automatically.
- Connects to Kronoterm heat pumps via Modbus TCP
- Publishes sensor data to MQTT for Home Assistant integration
- Supports Home Assistant MQTT discovery
- Configurable via environment variables in a .env file
- Packaged as a Docker container for easy deployment
- Docker and Docker Compose
- Kronoterm heat pump with Modbus TCP interface
- MQTT broker (e.g., Mosquitto)
- Home Assistant with MQTT integration
-
Clone this repository:
git clone https://github.com/yourusername/kronoterm-mqtt.git cd kronoterm-mqtt -
Create a
.envfile from the example:cp .env.example .env
-
Configure the application by editing the
.envfile with your specific settings -
Build and start the container:
docker-compose up -d
-
Clone this repository:
git clone https://github.com/yourusername/kronoterm-mqtt.git cd kronoterm-mqtt -
Install Poetry (if not already installed):
curl -sSL https://install.python-poetry.org | python3 - -
Install dependencies using Poetry:
poetry install
-
Create a
.envfile from the example:cp .env.example .env
-
Configure the application by editing the
.envfile with your specific settings -
Run the application:
poetry run python main.py
Or activate the Poetry virtual environment and run:
poetry shell python main.py
The application is configured using environment variables defined in a .env file.
Environment variables are set in a .env file in the project root. This file is:
- Automatically loaded by Docker Compose using the
env_filedirective when running the container - Loaded by the application directly when running manually
The .env file approach simplifies configuration management by keeping all settings in one place and works consistently in both Docker and non-Docker environments.
The following environment variables are available:
MQTT_HOST: MQTT broker hostMQTT_PORT: MQTT broker portMQTT_USERNAME: MQTT usernameMQTT_PASSWORD: MQTT passwordMQTT_CLIENT_ID: MQTT client IDMQTT_MAIN_UID: Main device UID for Home Assistant
HEAT_PUMP_DEFINITIONS_NAME: Name of the definitions file (without .toml extension)HEAT_PUMP_DEVICE_NAME: Device name in Home AssistantHEAT_PUMP_MODEL: Heat pump model
MODBUS_HOST: Modbus TCP hostMODBUS_PORT: Modbus TCP portMODBUS_TIMEOUT: Modbus timeout in secondsMODBUS_SLAVE_ID: Modbus slave ID
POLLING_INTERVAL: Polling interval in secondsVERBOSITY: Verbosity level (0-3)
An example .env file is provided as .env.example in the repository. You can copy this file to .env and modify it with your specific settings.
- Install the MQTT integration in Home Assistant if you haven't already.
- Start the Kronoterm MQTT application.
- The heat pump should appear in Home Assistant under Settings -> Devices & Services -> MQTT.
The sensors, binary sensors, and enum sensors are defined in the definitions/kronoterm.toml file. You can customize this file to add, remove, or modify sensors.
To disable a sensor, change [[sensor]] to [[sensor_disabled]] in the definition file.
- Connection Issues: Ensure that the Modbus TCP host and port are correct and that the heat pump is accessible from the Docker container.
- MQTT Issues: Verify that the MQTT broker is running and accessible, and that the credentials are correct.
- Sensor Issues: Check the logs for any errors related to reading or publishing sensor data.
To increase verbosity for debugging, set the VERBOSITY environment variable to a higher value (1-3) in the .env file or use the --verbose command-line option.
This project is licensed under the GPL-3.0 License - see the LICENSE file for details.
- kronoterm2mqtt - The original project that this is based on
- ha-services - Home Assistant MQTT services
- pymodbus - Modbus protocol implementation