A python library for Thermia Diplomat Inverter/Mega heatpumps.
This library communicates with the device using Modbus TCP. Set BMC to Modbus TCP on your heat pump to enable communication through this library.
Pool supply and return line temperatures (input-register addresses 119 and 120)
now use the documented scale of 100 for both Mega and Diplomat Inverter models.
For example, raw 1836 is returned as 18.36 °C, not 1836 °C. Signed decoding
is unchanged and runs before scaling. Register names and the async API are
unchanged; callers should use the corrected Celsius values without additional
scaling. This does not change pool setpoint writes or other temperature scales.
The public await thermia.async_update(...) and
await thermia.async_set(register, value) APIs are unchanged. Successful writes
still return None; successful updates return a dictionary.
- Failed reads raise
ThermiaReadError, including aNone, empty or short Modbus response. A failure in any requested chunk fails the whole poll.dataandfirmwareretain the last successful snapshot, rather than being replaced with partial results.availableonly indicates whether cached data exists; callers must handle the exception to track connection health. - Writes are attempted once. A failed acknowledgement (
NoneorFalse) or a raised transport error producesThermiaWriteError, with the register name, type and address. There is no automatic retry or readback comparison: a failed acknowledgement does not prove that the device did not apply the write, and devices may clamp values or implement momentary controls. - Both new exceptions inherit from
ThermiaConnectionError, which inherits fromThermiaException. Existingexcept ThermiaConnectionErrorhandlers therefore catch connection, read and write failures. Wrapped transport exceptions remain available as__cause__. Error messages are available via bothstr(error)and the existingerror.messageproperty. Local input errors are not transport failures: unknown register names raiseKeyError, and attempts to write read-only registers raiseValueError. - Sockets are closed after success, failure and coroutine cancellation. The
synchronous public
thermia.close()method can also be called repeatedly; callers no longer need to accessthermia._client. If cleanup itself fails while handling an operation error, it is logged without masking that error.
Requesting holding_fixed_system_supply_set_point automatically reads the
current coil_enable_fixed_system_supply_set_point first (documented coil
42, zero-based Modbus address 41). No cached enable value is used, and callers
need not request or expose a separate switch entity.
When the coil is false, the protected holding register is deliberately not read
and its key is absent from the returned dictionary and new data snapshot.
This is a successful conditional skip, not a failed read. Requesting only this
disabled setpoint consequently returns {}. A failed prerequisite read instead
raises ThermiaReadError and preserves the previous snapshot. The implicit coil
is returned only if explicitly requested (or included by the default model
selection); other only_registers filtering remains intact.
These coroutines still execute synchronous pyModbusTCP socket I/O internally. Run operations outside an application's event loop and serialize operations and explicit closes on the same instance. Cancellation cannot interrupt a blocking socket call; cleanup runs when control returns to the coroutine. This version does not introduce an asynchronous transport or thread-safety guarantees.
Home Assistant integrations already catching ThermiaConnectionError (and
OSError) need no exception-handler changes. They can replace private
thermia._client.close() cleanup with thermia.close(). Treat an intentionally
absent fixed-supply setpoint as unavailable rather than a transport failure;
a general empty-dictionary guard should account for a request containing only
that disabled register. Continue handling actual read/write exceptions as failed
operations, and do not automatically retry a failed write.
The Mega discrete-input block endpoints now include the documented alarm class E at address 4 and primary-unit/oil-boost statuses at addresses 84–86. Both full polls and targeted reads of these registers no longer fail during chunk construction. The gaps between blocks and the Inverter ranges are unchanged.
Use a separate development environment, not a running Home Assistant environment:
python3 -m venv /tmp/pythermiagenesis-dev
/tmp/pythermiagenesis-dev/bin/python -m pip install -e . pytest pytest-cov
/tmp/pythermiagenesis-dev/bin/python -m pytestThe regression suite uses the real library with a mocked Modbus transport. It does not connect to or write to a physical heat pump.
See the maintainer release process for automatic version-driven publishing, prerelease tags and recovery from failed uploads.
Thermia Modbus TCP documentation: https://www.tcmadmin.thermia.se/docroot/dokumentbank/Modbus%20protocol%20for%20Genesis%20platform%2010.pdf
- Be aware that some registers such for example "Compressor operating hours" will require a 32 bit read from two registers if the value is larger than 65535. This library does not handle this automatically, you will have to do this manually. This is explained in the manufacturer documentation.