I can see (not that i understand as I dont have any of these components, nor experience of them), however that still doesn't answer...
The problem I have is from my perspective, (in simple terms) I am not fully understanding what talks to what - you keep mentioning a modbus sensor, a gateway, MQTT but it is unclear what is connected to what. couple that with not knowing anything about your gateway device.
- I can help you format any message or payload - pretty much any shape object you need.
- I can help you convert binary data into nicely formatted object or string
- I can help you translate an MQTT payload into a dynamic modbus read request (for the flex-getter - at node-red)
- I can help you translate the modbus result back into any format you wish
- I can help you send that result back over MQTT
- I CANNOT help you with a gateway I have never seen unless you provide crystal clear and concise information