[APP][Pro] Modbus

For battery time out: I have the same problem. The battery doesn’t have it’s own ID. I don’t know how to get the data from battery itself. But you can ask the sdongle for SOC. Just set up S-Dongle as Modbus master device with ID 100. After that you set up Modbus device as slave with the id of the inverter who is connected to the battery. Than you have to set up a flow to the inverter with adress 37004 with size 1 and type uint16 and #0.


I can’t tell you enough: even in the documentation of the Modbus definitions there is always written that the Modbus interface only works if all devices are updated! The Huawei specialist told me that’s most important thing to do first.

New test version 0.5.1:

  • restored previous timeout for socket access
1 Like

Hi Ronny,
thanks for this app, it’s already great help to connect my heatpump.
I was already trying to create an app on my own. Can you maybe tell how i can extend your app to read some registers directly without using flows? so i can see the value in the app?

If you want to build your own app specific for your device, you can take every modbus app as example. Just take this or another modbus app and check the code ob Github how to use it.
Most apps are usign teh jsmodbus npm module as base.

hi Ronny,
I already tried. but for me it’s hard to find how to combine multiple apps
I have some code to read registers ( used as example nibe app) but it was hard to connect my heatpump.
Your app helped me to connect. I’am searching how to modify code of device.js to start reading registers. i found an option as:
this.pollingInterval = setInterval(() =>
Promise.all([
And tried to combine but without results So i hoped you could give some advise how to setup this.

Ronny,
I have Modbus installed and it is connected to my Fronius Primo Inverter. Next step I was going to try and read the registers I need to eventually write to reduce output power (40365).
Here is my first attempt. I have written the Homey Script as per your example:

// Calculate Scale Factor
let json = JSON.parse(args[0]);
let value = Number(json.value);
let exp. = Number(json.exp);
return parseInt(value * Math.pow(10, exp));

Here is the Flow:

And here is the error message I get when I test the Homeyscript:
Screenshot 2024-03-18 at 4.40.09 pm
Could this be because of the test data I entered. I entered -2 and 10000.

No, you have an invalid JSON as argument.
{ value: -2, exp 10000 }
Should be:
{ value: -2, exp: 10000 }
You are missing a colon.

And in your code remove the point ( . ) after the “exp” variable name:
let exp. =let exp =

The information is a but scattered over the thread.
There is a type SCALE to read rergisters as scale factor. So you don’t need the script, try this instead. It’s the same content but you can use the factor directly in the flow.

Here is an example to reduce battery output power to a fixed value. I use this to reduce battery usage to intermediate Watt level if the wallbox starts charging from the grid.

And the reset if charging is stopped.

As trigger I use the Fronius Wattpilot integration in HomeAssistant synced with Homey.

Btw…This app is only a tool to read registers. It has no automations. If you want to read periodially, just use flow cards like “every xx minutes”.
I use other apps to read data From fronius (the Homey Fronius app or HA integration that can only read data based on the REST API). I use this tool only to write registers.

Hi Ronny,

today your App was automatically updated on my homey to version 0.5.1. Since then I have an issue with the App. Before the update I was able to read the SoC and Grid Power and also Text from my OpenEMS system via Modbus. Now I have some issues. SoC is uint16 and still works fine (after I removed and added the modbus device again). But I’m not able to read text (only tried for testing) and also not the Grid Power. The Grid Power is FLOAT32 and with the old version I got totally wrong results using FLOAT32 already but when I used just FLOAT and length of 2 it was right. I guess this is because of the Endian where in your implementation it is using little and I need big (the order of the bytes). And when I used FLOAT with length 2 instead of FLOAT32 it was reading the register in correct order. Now there is no FLOAT anymore (only FLOAT16 and FLOAT32) and length only for STRING and no option for setting the endian. Would it be possible to add an option of the endian or making the length and FLOAT available again?

Thank you so much in advance and best regards,
Rico

I have Fenecon / Fems Solarsystem.
The reading of UNIT16 works fine.
With Float32 I get a Number wich is “very” low (7.120509626259812e-15) instead of the real 16W.
I tried it to read as holding and input register with length 2.
Is it possible that to create the Number it is necessary to change the sequence of the registers? Little versus Big Endian Byte order?
The Float64 Values are also wrong,
Nevertheless, thanks for creating this tool.

Nothing has changed for text. Set the size and type STRING shoudl work.

It seems you took a wrong register. FLOAT was only renamed to FLOAT16. FLOAT was 16bit value in the past, too. So you read a 32bit buffer (2 registers) and converted to 16bit Float.
Now FLOAT16 is reading 16bit (1 register). That’s all. So it seems you have been 1 register off. You should check whether your manual is using address (starting at 0) or register (starting at 1) values. Then you can select the reading option e.g. to register to use register values in the flow card.

The app uses Float32BE (most used values). Do you have details about the type (BE or LE)?

As far ay I know I have LE. I have read the registers with LabVIEW, where I got the right results.

Thanks. I will add LE options in addition.

Ronny,
I have tried the first part, a read, as per your example and I got this when I tested the Flow. I don’t know how to “See Response Body”.
My Fronius Inverter is a 6kW Primo 6.0-1, although the 6.0-1 probably only means 6kW device 1. I tried your search but I had trouble finding a register map for the Primo.
Modbus Error

The body is added in […].
It seems the register is not valid for your device. Has the Primo another Modbus reference?

Hallo Peter you ca choose between holding Register and Input Register. One includes the Adresses with numbers starting from 40000
the other woth 30000. If your Register is 40056 you have only to type 56 as Register. If your Adresses start with 40001 you have to set the starting with #1.

Sorry Ronny, not sure what you mean by Modbus reference.

The official Modbus reference from Fronius.

What I think I need is a reference for my Primo so I can see what registers to use.