Home Assistant as a Modbus TCP Slave: A New Custom Integration, and Why to Lock It Down

Home Assistant as a Modbus TCP Slave: A New Custom Integration, and Why to Lock It Down. AutoMatter

A Home Assistant community member has shared a custom integration that turns Home Assistant into a Modbus TCP slave. Most of us know Modbus the other way around, with Home Assistant polling an inverter or heat pump. This flips it: other devices ask Home Assistant for values, with no gateway in between.

What was announced

The author wanted other devices on the network to read their Home Assistant entities, and since most of those devices speak Modbus TCP, they built the slave side themselves. According to the post, setup works like this:

  • Add the integration and set a slave ID and a port (default 502).
  • Pick any entity and give it a register address.
  • The data type is detected automatically: on/off entities become a bit, numbers with a fixed range become int16 or uint16, and sensors become float32. You can override it (uint32, int32, scaled16).
  • Registers follow the entity state immediately, with no polling.

A few details matter if you plan to use it. Holding and input registers return the same values, and so do coils and discrete inputs, because many masters only support function code 3. Mappings are read-only by default. If you tick "Writable", the master can switch entities or set numbers, and values outside the entity’s minimum and maximum are rejected with a proper Modbus exception. 32-bit values are big-endian, high word first (ABCD). The author asks for feedback, especially from people whose PLC, SCADA system or energy manager reads things differently than expected.

Why it matters for an installed system

This is aimed at a fairly specific crowd: people with a PLC, a building management system, or an energy manager that can only talk Modbus. Instead of buying a protocol gateway, Home Assistant itself becomes the data source. That could suit a mixed install where a commercial controller needs room temperatures, occupancy or a switch state that already lives in Home Assistant.

Security: read this before you open port 502

The author points out that Modbus has no authentication. The integration offers an allowlist of master IP addresses and a listen address setting. We would treat both as mandatory, not optional. Keep the writable option off unless a controller truly needs to switch things, and if you do enable it, think about which entities you expose. A writable register on a lock, alarm or garage door is not something to hand to an unauthenticated protocol. If your network uses VLANs, keep the Modbus master and Home Assistant on a path you control and do not forward the port outside the house.

What to check first

  • Byte and word order. The integration uses ABCD for 32-bit values. If your master expects a different order, readings will look wrong even though the link works.
  • Function codes. Confirm your master can read the register type you need. The same-values design means FC3 is enough for most.
  • Scaling. Floats and scaled integers are not the same to every device, so test with a known value.
  • Maturity. This is a one-person custom integration with no reader reports yet. Try it on a test instance or with read-only mappings before relying on it for anything that controls heating, power or safety.

We have not tried it ourselves, and the post does not say how it behaves under heavy load or across many masters. If you only need to read from a Modbus device into Home Assistant, this is not what you want; the built-in direction is a different tool. But if the reverse is your problem, it is worth watching, and worth giving the author the feedback they are asking for.

Sources