Has anybody succesfully integrated the Airlab in HomeAssistant using the modbus integration? Modbus integration is based on pymodbus, so any help integrating Airlab using pymodbus is also welcome.
Below is the configuration I tried, but I get an error back from pymodbus. I know for sure the IP address is correct and T3000 can connect with the Airlab over IP.
I would set up a PC in the middle and log the data to see what’s going on. Wireshark is good for Ethernet based debugging. MBPoll or similar is good for modbus RTU polling.
T3000 has a built in rudimentary MBPoll, access that from T3000 → tools → Modbus Poll.
Yes, but for a start it would help to know the very least like: does the Airlab speak modbus over tcp, udp or rtuovertcp? It’s details like this that help a lot diagnosing the problems.
DEBUG:pymodbus.logging:Connection to Modbus server established. Socket ('192.168.1.111', 43052)
DEBUG:pymodbus.logging:Current transaction state - IDLE
DEBUG:pymodbus.logging:Running transaction 1
DEBUG:pymodbus.logging:SEND: 0x0 0x1 0x0 0x0 0x0 0x6 0x0 0x3 0x0 0x1 0x0 0xa
DEBUG:pymodbus.logging:New Transaction state "SENDING"
DEBUG:pymodbus.logging:Changing transaction state from "SENDING" to "WAITING FOR REPLY"
DEBUG:pymodbus.logging:Transaction failed. (Modbus Error: [Invalid Message] No response received, expected at least 8 bytes (0 received))
DEBUG:pymodbus.logging:Processing:
DEBUG:pymodbus.logging:Getting transaction 1
DEBUG:pymodbus.logging:Changing transaction state from "PROCESSING REPLY" to "TRANSACTION_COMPLETE"
Hmm… Transaction identifier 0102, Protocol identifier 0304 and length 0506 looks a bit suspicious to be very honest. Are you sure T3000 and the Airlab speak proper modbus?
The airlab is a mature product integrated into many environments over the years… since before the pandemic in fact. It uses plain old modbus RTU on the '485 port and regular Modbus TCP on the Ethernet and WiFi ports, this is well documented in the Modbus protocol.
Yes, and the documention clearly states that protocol identifier should be 0 for modbus (Modbus - Wikipedia) which the T3000 packet clearly doesn’t honour (it sends 0304)? Is there anything else that needs to be diverted from the standard for the Airlab to answer modbus over TCP requests?
Before diving in with a Python script it would be best to get some packets moving using a generic Modbus tool like MBPoll or our built in T3000 → tools → register viewer. There you can see all the registers, the description and the current value. You can jump back and forth from the graphical T3000 UI, change parameters there, then jump back to the register viewer to see the changes. Once you have all that working you can graduate on up to the Python scripts.
Fandu can comment better than I on the ‘protocol identifier’, we wouldn’t change it just to be different.
You are reading a device with a modbus ID of 0, and 0 is not a valid ID, I believe you can read the data if you change to normal modbus ID from 1 - 254.
The top half of the image below is my test using Modbus ID 1.
@Fan_Du Yes, you’re right, I initially used the wrong unit. I corrected that in my code and now I’m stupified. I expiremented with mbpoll and that works (Yes!):
Thank you, but the goal is to get Airlab values in HomeAssistant and the HA integration is based on pymodbus, so I’m looking for a solution in pymodbus… I’ll investigate further and report back when I found the problem.
And it turns out it is timing critical, because on restart it fails to read the registers. So I do need to insert a small timeout after client.connect() after all:
Glad you figured it out. If we can add some features to make your integrating go better you can let us know. For RTU we have a delay parameter, if you need one for IP polling we can work on it. I am not clear what you mean with “It turned out the be the slave after all” but we’re listening and anxious to make HA integrating go smoothly.
It turned I was looking at two problems (and one remaining). I misconfigured HA by omitting slave:1, but now even with delay: 1 I still see failing responses in the HA logs, so apparently the integration doesn’t insert the delay where it’s needed to be fail-safe?
The Airlab generally replies pretty quickly, a few milliseconds under RS485/RTU which is why we needed to introduce the delay parameter for the RS485 communications. Wireshark could tell you more about the timing and possibly we need to introduce a delay with IP as well for HA.