MODBHub – Generic Modbus TCP Driver for Hubitat [Community Release]

I started MODBHub as a small personal project to make direct Modbus TCP integration with Hubitat a little easier and more generic.

A bit of background first: I am not a Groovy developer. I do have a general understanding of programming, going back quite a few years and covering things such as C, C++, HTML, PHP, JavaScript, Node-RED, and various other technologies. I also know PLCs and Modbus reasonably well. I develop my own PLC applications and regularly make PLCs communicate with each other and with Node-RED and other systems.

For this project, however, I deliberately took a different approach.

I did not write, edit, or even verify a single line of the Groovy code myself. The coding mission was assigned entirely to ChatGPT. My role has essentially been that of project manager, system designer and beta tester: defining what the application should do, specifying the expected Modbus behaviour, building test configurations on real PLCs, deliberately trying to break things, reporting the results, challenging questionable behaviour, and deciding what should — or should not — be added.

This has been a very iterative process: define a small requirement, generate the code, test it against real hardware, find problems, understand why they occur, correct them, and test again.

The objective is definitely not to build a huge Modbus “gas factory.” Quite the opposite.

I wanted a small and friendly tool that allows Hubitat to communicate directly with Modbus TCP devices without requiring Node-RED, MQTT, custom HTML interfaces or another intermediate system. I also wanted it to be as generic as reasonably possible, rather than creating another driver dedicated to one specific Modbus device.

MODBHub currently reflects that philosophy: describe the PLC/device and its points, let the application handle the Modbus details, and expose useful values and commands to Hubitat.

My test environment includes several PLCs and Modbus devices, but obviously that represents only a tiny fraction of what exists in the real world. This is therefore where the Community Release becomes interesting.

I would very much appreciate people testing MODBHub with different PLCs, controllers and Modbus TCP devices, and reporting what works, what doesn't, and what could be improved.

Comments are equally welcome about the overall philosophy and architecture and about the AI-generated Groovy code itself. If experienced Hubitat/Groovy developers see something questionable, unnecessarily complicated, inefficient, or simply wrong, please say so. That is part of the purpose of publishing it here.

One important caveat: this is a personal project and I do not have a huge amount of free time, so I cannot promise active or immediate support. I will nevertheless do my best to answer questions, investigate useful bug reports, and incorporate improvements when they make sense.

Most importantly: **test it, challenge it, break it, and tell me what you find.
**
Before I go any further with setting up a proper distribution method for MODBHub (GitHub or otherwise), I would first like to see whether there is actually some interest in this project.

If you would like to test MODBHub, please send me a PM. I will be happy to provide the current Community Release package and installation documentation.

If enough people are interested, I will then look at setting up a more convenient public distribution method.

Could this be used to communicate between hub and backup battery instead of using Powerchute, apcupsd, nut server, etc on an external computer?

Potentially, yes — this is exactly the kind of external computer dependency MODBHub is intended to eliminate.

The requirement is that your battery/UPS system provides a Modbus TCP interface, either directly or through a Modbus TCP gateway.

If it does, and you have its Modbus register map, you should be able to define the points you need in a MODBHub CSV file and communicate directly between Hubitat and the device over the LAN — without PowerChute, apcupsd, NUT, MQTT or another computer in between.

If your battery/UPS does not provide Modbus TCP, then MODBHub is not the appropriate solution.

This is still a Community Release, so testing it with different types of Modbus devices is very welcome.

Hey there PPz, can't figure out how to PM on here. Maybe I'm too new.

I'd like to test MODBHub with a SolarEdge SE5000H using SunSpec Modbus TCP. The inverter is already responding on TCP port 1502 after I got into it and enabled the Modbus TCP. I have a brand spanking new C8 Pro. Would love to use data from inverter to decide when to crank the heat in the daytime winter days.

Thank you, from Vancouver Island, Canada.

Update — MODBHub V1.06 Community Release — September 26, 2026

A new V1.06 Community Release is now available.

Since the original Community Release, MODBHub has continued to be tested on several simultaneous PLC instances and on different hardware, including Ovarro TBox and Temco controllers.

The main addition in V1.06 is much more robust handling of PLC/network failures.

MODBHub will now:

  • automatically detect a lost Modbus TCP connection;
  • suspend normal polling while the PLC is unavailable;
  • retry the connection progressively at 5, 15, 30, 60, 120 and 300 seconds, instead of continuously hammering the Hubitat hub and the network;
  • after TCP communication is restored, wait for a 20-second stabilization period before resuming Modbus polling;
  • automatically return to normal operation if the PLC comes back during the recovery sequence;
  • if all automatic reconnect attempts fail, stop retrying, report the communication error and optionally send a Hubitat notification;
  • expose a reconnectRequired state and a manual Reconnect command for controlled recovery after automatic retries have been exhausted.

The idea is simple: recover automatically from normal temporary network problems, but don't retry forever when something is genuinely broken.

V1.06 also consolidates the current MODBHub feature set:

  • BOOL, INT16, UINT16, INT32, UINT32 and FLOAT32 point types;
  • FC01 / FC03 / FC04 reads;
  • FC05 / FC06 / FC16 writes where appropriate;
  • configurable scale, offset, decimals and 32-bit byte/word order;
  • grouped polling of compatible contiguous registers;
  • one authoritative Modbus transaction in flight per PLC;
  • write coalescing and targeted post-write readback/verification;
  • read-only (r) and read/write (rw) point protection defined in the CSV;
  • multiple independent PLC/Modbus endpoints, with one MODBHub Parent per endpoint;
  • optional bidirectional Hub Variable integration through the MODBHub Binding App.

The package has also been cleaned up so that the Parent, all six Group Child drivers, Binding App and Failure Notifier are now consistently identified as V1.06, and the archive includes the complete installation and reference documentation.

The current V1.06 package has been installed as a complete update on my Hubitat C-5 running firmware 2.5.1.183, reboot-tested, and is currently running several PLC instances simultaneously.

It has also been successfully tested on a Hubitat C-7 running firmware 2.4.3.137, providing some additional confidence that MODBHub is not limited to the latest Hubitat firmware generation.

I am still very interested in tests with other manufacturers and Modbus TCP devices. Real-world testing outside my own hardware is much more valuable at this point than adding features simply because they are possible.

So the original invitation still applies:

Test it, challenge it, break it, and tell me what you find.

Download

The current MODBHub V1.06 Community Release, including the complete documentation, can be downloaded here:

Download MODBHub V1.06 Community Release

Small MODBHub update

MODBHub has now been successfully tested by a Community user (EVOLVING.HOME) with a Moxa ioLogik E2210. Bidirectional communication was confirmed: Hubitat can control the E2210 digital outputs and correctly read its digital inputs through normal polling.

This is particularly nice to see since the E2210 was not part of my original test hardware, and provides a first external validation of MODBHub's generic CSV-driven approach.

I've also placed a small V1.06d update in the download archive. It improves recovery after a communication failure by adding a contextual manual reconnect command once the automatic reconnect sequence has been exhausted. A manual reconnect is a one-shot attempt: if it fails, MODBHub remains in the stopped state and allows another manual attempt, without restarting the complete automatic backoff sequence.

Thanks to Steve for testing it on real hardware and for the useful feedback!