Summary
As you might know, Home Assistant contains a Modbus integration.
I’d like to present an alternative approach to integrate Modbus devices using mobugen, a Modbus configuration generator. Modbus handling is left to mqmgateway, an adapter between Modbus & MQTT. All Modbus devices are represented as MQTT entities managed by the MQTT integration.
Screenshot dashboard:
Motivation
My task was to monitor and control a Buderus heatpump (containing Dimplex components) via a Smart Home system. Main goals:
-
Monitor and control the heat pump
-
Possibility to integrate with different Smart Home systems. Nice to have: use more than one system at a time (simplifies testing and migration)
-
Appealing user experience: use proper names instead of raw numbers, take advantage of units, limits, categories, etc.
-
Efficient handling of Modbus communication (e.g. bulk requests, notification on changes only)
The existing Modbus integration is not a perfect fit for these requirements:
-
Home Assistant-exclusive
-
Provided entities have limited domains, e.g.
select
andnumber
are missing -
Read & write require different ways of configuration: entity vs. action
-
State changes for switches are reported only when pressed within HA (at least as per the docs)
-
Little control over Modbus communication
In a past project I discovered mqmgateway, an adapter between Modbus and MQTT. The idea was born to let mqmgateway handle the Modbus part and communicate to Home Assistant (or another system) via MQTT.
Downside of this approach: there’s another player in the game, demanding one more configuration. To minimize manual management via UI or editing YAMLs, which is tedious and cumbersome, I chose to write a generator for the configurations.
Result
Result of these efforts is mobugen, a generic project to translate a modbus definition (CSV format) into text-based configuration files. The CSV contains all infos about the modbus entities (e.g. register number, display name, data type, limits) in a compact and system-agnostic format. The generators create configuration files for mqmgateway and Home Assistant.
Currently, the project contains a CSV for Dimplex-based heat pumps (RTU), and generators for mqmgateway and Home Assistant. It is extensible to support other Modbus devices and Smart Home systems, though. The Dimplex CSV has been carefully filled with official information from the RTU section of the Dimplex Wiki.
All involved components are containerizable (Docker): generators, mqmgateway and MQTT broker.
The project contains documentation with screenshots and examples.