Hi Ronny,
Thnx for your reply, I have the modbus working an hour ago.![]()
The problem was in my tags in the Jmobile software.
What would be the fastest way when i hit a button on my HMI that homey starts a flow?
Hi Ronny,
Thnx for your reply, I have the modbus working an hour ago.![]()
The problem was in my tags in the Jmobile software.
What would be the fastest way when i hit a button on my HMI that homey starts a flow?
Modbus can only be polled.
You can create a flow with a time based trigger (every xx seconds). Then read the Modbus register and use logic cards to check the value. Then you can use action cards to do something.
If you want to react on a change, you can create variables to remember a register state. Set the variable in your modbus flow.
Then I suggest to create a second flow to react on the “variable changed” trigger to do something.
Are you inside a “standard” flow? You have to use AdvancedFlow to combine several flow cards in a line to use the read value in the next card(s).
Hello RonnyW,
I want to say THANKS for your MODBUS application since it has helped me already a lot. I never could believe that I would achieve the things that I’ve achieved now by using this application. It started around X-mass 2025 when I tried to get my Mennekes Amtron Charging station to become CONTROLLABLE via MODBUS. Before I knew this application, I found out that within Home Assistant is was possible. So I installed HA on a older computer and started to work. Together with ChatGPT and Google-AI I’ve managed to get a grip via MODBUS from my charging station from within HA. Then I’ve created a connection between my Homey and HA end from that moment onwards I could control my charging station from within Homey. Great achievement, somewhere early Jan 26. Then,… I found your application and thought, … OK. Together with my yaml-file from HA end how it worked there, together with your nice MODBUS-app en I agree, again ChatGPT and Google-AI I managed fairly quickly, to control my Charging station directly from within Homey. Then I removed my HA application since it was only there for that reason… That same computer is now a Homey-SHS ==>
. Recently, my Mennekes Amtron charging station died on me. The controller inside ( a known … bug ) has stopped its function. That controller was no longer available so, I could trow it away. Now ( today arrived ) replaced by a new one, via a special deal with Mennekes ( thanks for that ). That one I still need to re-install and then connect again with my Homey via MODBUS. Should be possible without to many hassle. The MAIN reason for this writing is my achievement from today, this evening. A whole day searching , reading, trying, checking … but I succeeded to get my SMA SB5.0 Storage Home-Battery Manager that has 3 batteries ( 30kWh capacity in total ) , that also has MODBUS, to control its charging. My SMA Home Manager 2.0 controls all, so in fact, all works well. But I wanted to control my Battery Manager to be able to CHARGE or DIS-CHARGE the batterij at my wish or command.
And, I achieved it today.
So my SMA SB5.0 Storage Home Battery is now able to charge and dis-charge at MY command, to the power-levels I want. This is important to BETTER control the Capacity Tarif in Belgium, to allow my battery NOT to charge yet in the morning when the SUN shines and I produce solar-energy when the Dynamic Power tarifs are still high. Only when I want my batterij to charge, I allow it to charge via the SMA Manager. I charge my CAR. But when I have my home battery full, from today onwards, I will also be able to DIS-charge my home-battery even to the leven that I start to dump energy on the GRID. This will allow me my still almost full battery, in the early morning-hours, just before the sun starts shining, to DUMP that energy to the GRID exactly at the moments the Dynamic Electricity prices are still high.
So, its working.
Here a short overview :
This is naturally only a first version, for Test. By now I’ve created newer and nicer Advanced flows per specific needm, using a Variable to define the power level, a variable that I can CALCULATE out of different and many values I have within my Homey. Since I MEASURE and by that I KNOW a lot ![]()
This is a Thank-you to Ronny.
Success with your further developments. They are APPRECIATED.
Walter
Many Thanks, Walter.
Nice to hear your feedback and experience ![]()
Hi Ronny,
Thanks for this great app.
I have been tinkering with Sungrow iHomeManager to try to make it work with my Homey Pro Mini.
Specifically I am trying to set the “charge/discharge power” (register 8026).
From Sungrow’s documentation:
But I am pretty sure there are some bugs or weird implementation on Sungrow’s side, using a Modbus TCP client on my PC to try different combinations to get it to work, I have found out that using function 6 didn’t work for this register (getting error code 3), but using function 16 works.
This is the only combination that I have found to be working (setting charge / discharge power to 40 aka 4.0kWh)
So my question is, is there any chance you could implement support for function 16?
On another note, I also found that if I try to send a write command via Homey, if I use (U)INT16, sending value “32” is literally sent as “32” to iHomeManager which actually expects “00 32”, but I am unable to make the app send “00 32”.
Any assistance would be greatly appreciated. I have also emailed Sungrow to ask why using function 6 to write that register doesn’t seem to work for me.
The Homey device a a device setting to use “Write multiple registers” (FC 16) instead of “Write single register” (FC 6).
About “32”: The app is using a module for low level Modbus communication. As far as I know, for (U)INT16, the integer value is sent as bytes, not a string with “0032”. An integer value 32 is sent as UINT with value 00 20.
dec: 32
hex: 0x0020
You can use the “test” option in the flow card and write the result (byte string) to the timeline.Then you can see what’s sent as bytes (used to get the correct byte order for all the big/low endian variants).
@RonnyW with great thanks, all sorted now.
I set “write multiple registers” to “yes”, and for some reason I had to use Int32-LE(16bit word LE) to make it work, as long as it works I am not gonna question it.
This is the flow I created to start forced mode and charge at x kW on iHomeManager, in case anyone needs a reference. The flow starts with a numeric value, which is then passed onto the flow to set the charge power. The flow “IHM Get EMS Status” basically reads the register to confirm that it has been set successfully, and then sets a numeric variable on Homey. Before I start charging, I will check that value to make sure it’s not already charging.
Sungrow also got back to me saying the value type for register 8026 is U32, hence it needs to write 2x 16-bit registers, so it needs fc 16.
Thanks for your prompt response again.
As the Refluxion app had its functionality removed, I"ve now switched to the Modbus app to control my Sungrow inverter and battery. However, I am encountering some issues;
If I set the inverter to ‘Keep connection’, I get very occasional “no connection to modbus server” (ignore the number, that’s just a way for me to troubleshoot the exact moment the flow aborts):
If I set the inverter to ‘Manual’ (and then use Connect/Disconnect cards), I get an occasional “Req timed out” error.
Any suggestions on how to deal with this, or how to fix this?
Some devices can handle only one connection and some are closing the connection after a while. It’s device/manufactor specific.
But if you get errors also for single connects, then it would be good to split your flows.
Make every task (connect, read/write, disconnect) as one flow. Use the “flow has started…” card as start point (you can also pass variables into the flow).
Then make a “manager” flow around. Start your task-flows from there. Use the error output from this flow card to do an error handling. The easy way is to start the flow a second time. If this also errors, perhaps write to timeline or send you a message so you can check, how often this occours. Hopefully this erorr are only on-time issues and the second try solves it.
Hello everyone,
i made a separate topic but according smarthomesven i should post it here.
I’m looking for some help getting a stable Modbus TCP connection between my Growatt inverters and Homey Pro 2023.
System setup
What works
After rebooting the EW11, everything works perfectly:
The problem
After running for some time (typically within an hour), communication becomes unstable and I start receiving the following error “Connection to modbus server closed” on write and read commands
What I have already tried
Questions
Goal
My goal is to dynamically control inverter output based on hourly electricity prices:
Any suggestions or experience with a similar setup would be greatly appreciated.
Thanks!
EW11 settings
Protocol: Tcp server
Socket settings:
Local port: 502
Buffer size:512
Keep alive: 60s
Timeout: 30s
Protocol settings max accept: 3
Security: disable
Route: Uart
Serial port settings:
Baud rate 9600
Data bit 8
Stop bit 1
Parity None
Buffer settings
Buffer size:512
Gap time:50
Flow control settings:
Flow control: disable
Cli settings
Cli: Serial string
Serial string: +++
Waiting time: 300
Protocol settings:
Protocol: Modbus
Advanced settings in homey Modbus TCP app:
IP address 192.168.1.246
Port:502
ID 1,2 or 3 (depending on which inverter)
Modbus options:
Use write multiple registers function for sing register: no
Prevent writing unchanged data: no
Hi,
I think that’s only a TCP connector issue. Some devices keep the connection active, some arw closing it.
You can try the different connection settings in Modbus device:
Please try if this works for your device ![]()
Hello Ronny,
Thanks for your swift reply.
I believe you are referring to the Connection Type setting in the Modbus device configuration within Homey. (see snap 1)
I have already tested both Single Connect and Keep Connecting, and switched between them several times. Unfortunately, neither setting appears to resolve the issue completely.
To investigate further, I created the following test flow (see snap 2).
The flow reads Holding Register 3 from each inverter every 30 seconds, with a 2-second delay between inverter #1 and #2 and another 2-second delay between inverter #2 and #3.
I let this test run for approximately 2 hours, resulting in roughly 240 read attempts per inverter.
Each time a read operation failed, an error counter was incremented. The final counters are shown in Picture 3:
What I find interesting is that one inverter completed all reads successfully, while the other two experienced a significant number of communication failures.
Does this pattern suggest anything specific to you?
Could this still be related to the TCP connection handling in Homey, or would you suspect an issue on the RS485 side (EW11 configuration, bus timing, missing termination resistors, etc.)?
Thanks again for your help.
snap 1
snap 2
snap 3
If one inverter is working fine, it doen’t seem to be a TCP/IP issue. So your IP dongle seems to keep up the connection. Else you would get connect errors or timeouts - especially using “keep connection” option.
And "Connection to modbus server closed” sounds line an error message from the used NodeJS module or from the dongle itself. I would say it’s an issue between the dongle and the inverters.
I don’t have experience with such dongles. My Fronius has built in LAN access. How are your inverters connected to the dongle? Serial bus (2 wires)? In a line or as star?
Something to check:
If it’s variant 1, you could try the manual connection mode and use the “connect” flow card, then your readings and as last the “close connection” card. This wax, a new connection is done for every flow start. Perhaps this reconnects all devices again. Then you should connect all flow cards in a line, not parallel from the trigger.
Hello Ronny,
The inverters are connected to the EW11 via an RS485 bus using two wires in a UTP cat6 cable. The wiring follows a daisy-chain (DC chain) topology:
EW11 → Inverter 1 → Inverter 2 → Inverter 3
The total cable length is less than 2 meters.
Regarding your questions, the behaviour seems to match variant 1.
When an inverter starts returning errors, all subsequent requests to that same inverter also fail with:
“Connection to modbus server closed”
However, what is strange is that after some time the inverter sometimes starts responding again without any intervention. No reboot of the EW11, Homey or the inverter is required.
I have tried you’re suggestion on the inverter that is currently showing the “Connection to modbus server closed” error constantly since my last post, the MIN 4600TL-XH (Modbus ID 1).
Instead of using a keep connection, I changed the connection mode to Manual and modified my flow to:
So the flow now explicitly opens and closes the TCP connection for every action.
Unfortunately, the inverter is giving the same error: “Connection to modbus server closed”.
at the moment communication between the other 2 inverters is stable for the last 4 hours.
Hm, so the commication to the dongle is ok, only the inverter does not respond?
Then a reconnect from Homey app does not help, right?
But…how do you control the inverters without Homey? With a manufacturers app also via dongle? Does this work while you have the error in Homey?
Hello gents,
Thanks for the support and reactions.
I have replaced the EW11 by a waveshare Waveshare RS232/485/422 naar PoE Ethernetgateway | Elektronica voor jou now all is working good. reading register 3 ever 30 seconds and if needed, price below zero, write register 3 (based on current home consumption) and if price is below tax prices write register 3 to 0.
al 3 inverters are functioning now like it should on 1 modbus and no errors: “Connection to modbus server closed”.
system is now up and running for 2 days and no faults received.
see below the flow im using.