# \[APP\]\[Pro\] Modbus - Connect every Modbus devices

**URL:** <https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497>\
**Category:** Apps\
**Tags:** app, homey-pro, advancedflow\
**Created:** [February 20, 2024, 7:13pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497 "2024-02-20T19:13:05Z")\
**Posts on this page:** 20\
**Page:** 15

<div class="post-metadata">

**Author:** ![bischowski](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bischowski/32/16864_2.png) [@bischowski](https://community.homey.app/u/bischowski)\
**Post date:** [May 26, 2024, 6:57am UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/281 "2024-05-26T06:57:04Z")

</div>

Hi Ronny,

reading DiscreteInput is not working.

![InvalidToken_value_boolean](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/3/a38cb1069de22385acbf08c22d414a1364a05792.png)

i changed

```auto
                case 'BOOL':
                    valueBoolean = res[0];
                    break;

```

to

```auto
                case 'BOOL':
                    valueBoolean = res.response.body.valuesAsArray[0] == 1;
                    break;

```

in device.js and at least for my usecase (reading digital inputs of Siemens LOGO!) it’s fine now.

also changed from

```auto
this.log("Response: String: ", valueString, ", Number: ", valueNumeric);

```

to

```auto
this.log("Response: String: ", valueString, ", Number: ", valueNumeric, ", Boolean: ", valueBoolean);

```

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [May 26, 2024, 1:47pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/282 "2024-05-26T13:47:13Z")

</div>

Hi,  
thanks for the hint. It seems I never adaptedt the old example with a real coding 🙃

I took over your coding (just changed the bool check into !=0).  
A new test version is ready. You can try if it’s ok now.

---

<div class="post-metadata">

**Author:** ![Valentin\_Ciopei](https://avatars.discourse-cdn.com/v4/letter/v/6bbea6/32.png) [@Valentin\_Ciopei](https://community.homey.app/u/Valentin_Ciopei)\
**Post date:** [June 1, 2024, 6:23pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/283 "2024-06-01T18:23:33Z")

</div>

Hello,

Starting with last updates I’m getting some errors from time to time “rejecting because of earlier OutOfSync error”

The app still works and after a retry the value is correct.

Maybe this helps finding the issue: 91e53736-640f-4052-a98c-3afa42ca4b0f

I’m using the test version 0.9.2

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [June 2, 2024, 11:21am UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/284 "2024-06-02T11:21:20Z")

</div>

Based on the log it seems you send 3 or 4 requests at the same time. Perhaps the Modbus device can’t process the calls in correct order.  
If you have flows in parallel, try to call the flow actions in sequence, if needed with a 1sec delay and check it this solves the issue.

---

<div class="post-metadata">

**Author:** ![Rmb](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rmb/32/79135_2.png) [@Rmb](https://community.homey.app/u/Rmb)\
**Post date:** [June 2, 2024, 9:11pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/285 "2024-06-02T21:11:14Z")

</div>

> [@RonnyW](#):
>
> Create a flow and use the dvice flow actions to read a register.

Although I managed to create a normal flow, I should use advanced flows?  
As I am unable to get the tag with the result.

 ![IMG_3296](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/6/5690b1bac8eef4e25fa01a031e85667e5fd7488b.jpeg)

---

<div class="post-metadata">

**Author:** ![Valentin\_Ciopei](https://avatars.discourse-cdn.com/v4/letter/v/6bbea6/32.png) [@Valentin\_Ciopei](https://community.homey.app/u/Valentin_Ciopei)\
**Post date:** [June 3, 2024, 6:12am UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/286 "2024-06-03T06:12:22Z")

</div>

> [@RonnyW](#):
>
> Based on the log it seems you send 3 or 4 requests at the same time. Perhaps the Modbus device can’t process the calls in correct order.  
> If you have flows in parallel, try to call the flow actions in sequence, if needed with a 1sec delay and check it this solves the issue.

You are right!  
I had a few flows set to “every X hours” or “every Y minutes”. Probably they conflicted from time to time. I added some random delays and it looks ok now.

thanks!

---

<div class="post-metadata">

**Author:** ![Rmb](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rmb/32/79135_2.png) [@Rmb](https://community.homey.app/u/Rmb)\
**Post date:** [June 3, 2024, 10:23am UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/287 "2024-06-03T10:23:26Z")

</div>

Yes it requires advanced flows. I just did not know I had this feature.😁

---

<div class="post-metadata">

**Author:** ![Rmb](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rmb/32/79135_2.png) [@Rmb](https://community.homey.app/u/Rmb)\
**Post date:** [June 3, 2024, 10:40am UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/288 "2024-06-03T10:40:18Z")

</div>

I like your solution and want to use it for NIBE SMO S40.  
Could you give a clue how to get multiple text and values in the tile?  
And maybe make the heat pump icon available?

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [June 3, 2024, 3:17pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/289 "2024-06-03T15:17:45Z")

</div>

> [@Rmb](#):
>
> Yes it requires advanced flows. I

Yes. with advanced flow you can process a flow card and await the result you get back as a token that you can use in following cards (write to virtual devices …).  
In a standard flow, you can only process a flow action (fire and forget) without being able to get a result back.

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [June 3, 2024, 3:19pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/290 "2024-06-03T15:19:24Z")

</div>

You can create ab advanced flow.  
Then insert the time trigger card.  
Then insert the Modbus action cards one after another connected in line.  
This way, the second cards starts after the previous one is completed.

---

<div class="post-metadata">

**Author:** ![CaptainVoni](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/captainvoni/32/3549_2.png) [@CaptainVoni](https://community.homey.app/u/CaptainVoni)\
**Post date:** [June 4, 2024, 11:18am UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/291 "2024-06-04T11:18:33Z")

</div>

Sorry, I’m a bit low on time lately. I answered your question in the other [thread](https://community.homey.app/t/app-pro-advanced-virtual-device-device-capabilities-app-with-unique-text-status-indicator/68198/580).

---

<div class="post-metadata">

**Author:** ![Rmb](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rmb/32/79135_2.png) [@Rmb](https://community.homey.app/u/Rmb)\
**Post date:** [June 6, 2024, 5:50pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/292 "2024-06-06T17:50:13Z")

</div>

> [@CaptainVoni](#):
>
> I have multiple registers with a documented size of 6

Did you eventually manage to read these registers with size 6?  
I have a NIBE SMO-S40 with several [registers](https://github.com/yozik04/nibe/blob/master/nibe/data/smos40.csv) of size 6 like

> Hot water, compressor only MODBUS\_INPUT\_REGISTER 1583 10 kWh **6** 0 9999999 0]

I can read it with size 4, but it shows the same value all the time, with very little variations.  
Maybe I can try to read 1582, 1583 and 1584 with size 1 as bytes, and see how the behave during some time.

---

<div class="post-metadata">

**Author:** ![CaptainVoni](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/captainvoni/32/3549_2.png) [@CaptainVoni](https://community.homey.app/u/CaptainVoni)\
**Post date:** [June 7, 2024, 9:58am UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/293 "2024-06-07T09:58:12Z")

</div>

> [@Rmb](#):
>
> Did you eventually manage to read these registers with size 6?

Yes, I usually read them as “INT32-LE (16bit Word LE)”. I have no idea what the variable size mean, it just doesn’t make any sense.

> [@Rmb](#):
>
> I can read it with size 4

The “size” isn’t used for anything else than STRING and BYTE. For numbers it’s just ignored, i.e. it doesn’t make any difference whatever value you put there.

---

<div class="post-metadata">

**Author:** ![Rmb](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rmb/32/79135_2.png) [@Rmb](https://community.homey.app/u/Rmb)\
**Post date:** [June 7, 2024, 1:02pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/294 "2024-06-07T13:02:06Z")

</div>

It looks like NIBE counts the size in bytes (8 bits) en the Modbus app in 16 bits. Indeed in the Modbus app size only matters when reading bytes.  
NIBE register 1489 (number of compressor starts) reads:  
Size 4 registers shown in BYTES (so 64 bits) : 02 14 00 00 01 BD 00 00  
INT16: 532  
INT16-LE:5122  
INT32-LE: 5122  
INT32-LE (16 bit word LE): 532  
UINT32/ACC32: 34865152  
UINT32: 5122  
UINT32-LE(16 bit word LE): 0

02 14 = 532  
14 02 = 5122

and 34865152 = 02 14 00 00

So the value 01 BD is nowhere taken into account.  
Trying to read UINT64 gives no response, not even an error, the card hangs.  
As 64 bits can always be presented in UINT64, it might be that when reading 4 registers and presenting them in bytes, results in **4 times reading 1 register** , as reading 4 registers and representing them as UINT64 results in 1 time **1 time reading 4 registers** at once.  
As I can also read 3 registers and present them in BYTES.

As the NIBE heatpump is operational for almost one year, I would expect the number of starts to be 150 days x 10 starts a day makes 1500.  
It would be nice if I had some register with a well known value😉

Or wait for a compressor start and see the difference.

Edit: from the overlap of values, it looks that Nibes size 6 means 6 HEX characters? Like 0 2 1 4 0 0 ?

 ![Foto 07-06-2024 om 15.19](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/0/c/0c27acfa613555a002f282929896ca560f95e123.jpeg)

---

<div class="post-metadata">

**Author:** ![CaptainVoni](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/captainvoni/32/3549_2.png) [@CaptainVoni](https://community.homey.app/u/CaptainVoni)\
**Post date:** [June 7, 2024, 1:41pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/295 "2024-06-07T13:41:52Z")

</div>

> [@Rmb](#):
>
> It looks like NIBE counts the size in bytes (8 bits)

My though also, but Modbus registers are always 16 bit wide. So a variable of size 5 would use two and a half registers. That doesn’t make much sense to me.

> [@Rmb](#):
>
> the Modbus app in 16 bits.

That’s how it should work in my opinion.

> [@Rmb](#):
>
> Size 4 registers shown in BYTES (so 64 bits) : 02 14 00 00 01 BD 00 00

In my opinion those are two separate values: 00 00 02 14 (reordered) and another 00 00 01 BD (reordered). I would use INT32-LE (16 bit word LE) to read that.

> [@Rmb](#):
>
> So the value 01 BD is nowhere taken into account.

Because it’s another value IMHO.

> [@Rmb](#):
>
> As the NIBE heatpump is operational for almost one year, I would expect the number of starts to be 150 days x 10 starts a day makes 1500.

That would be quite a lot of starts for just one year. During winter we average zero starts on our heat pump, because it never stops. During spring and autumn we have 2-3 starts each day, and in summer time exactly one (heating water). So my guess would be that 532 is the correct value for you.

---

<div class="post-metadata">

**Author:** ![Rmb](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rmb/32/79135_2.png) [@Rmb](https://community.homey.app/u/Rmb)\
**Post date:** [June 7, 2024, 2:15pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/296 "2024-06-07T14:15:16Z")

</div>

I think I understand, is a documentation failure from NIBE.  
When I compare the files [SMO40.CSV](https://github.com/yozik04/nibe/blob/master/nibe/data/smo40.csv) and [SMOS.CSV](https://github.com/yozik04/nibe/blob/master/nibe/data/smos40.csv) I see the following values in the table size:

 ![Scherm­afbeelding 2024-06-07 om 15.40.20](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/c/c/cc22d43b5863d25f8248318264b98827eef4bcca.png) ![Scherm­afbeelding 2024-06-07 om 15.40.59](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/6/1/616ba747e300c4050ad68cde070277091972be14.png)

In the SMO 40 the biggest size is Signed or Unsigned 32. Signed is mostly used for temperature.  
kWh in SMO 40 is UINT32, IN SMO-S40 size is 6.  
The numbers 1…6 might just be a reference number to the s16…u8.

So I stick to the value 532, so INT32-LE (16 bit word LE).

@RonnyW That UINT32-LE(16 bit word LE) results in 0 must be a bug?

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [June 8, 2024, 7:46am UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/297 "2024-06-08T07:46:37Z")

</div>

Sorry, had no time to check this.  
I’ll check the code later if something is wrong with UINT32-LE.

Else you have still questions or did you get all the needed information from CaptainVoni?

---

<div class="post-metadata">

**Author:** ![Rmb](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rmb/32/79135_2.png) [@Rmb](https://community.homey.app/u/Rmb)\
**Post date:** [June 8, 2024, 9:19am UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/298 "2024-06-08T09:19:24Z")

</div>

I am fine and now reading even more NIBE Registers 👍.  
As the number are not big yet, signed integers will do, so don’t hurry.

---

<div class="post-metadata">

**Author:** ![Rmb](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rmb/32/79135_2.png) [@Rmb](https://community.homey.app/u/Rmb)\
**Post date:** [June 12, 2024, 10:51am UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/299 "2024-06-12T10:51:04Z")

</div>

@RonnyW appearently the IP-adres has changed of the SMO-S40.  
Of course that ip-address shall be a fixed ip-address. As I am not on location, I tried to change the ip-address in the app, but when saving the new address it gives a time out on the old address and did not change. I restarted Homey, the app and thisabled the app, but no luck. Any ideas?

Edit: using the “Net Scan” app I see the new address, mailed to me, is also wrong. So no wonder I cannot change the ip-address. I have to be on site, or test 256 ip-addresses 🤨

Edit: I have been on location and the SMO-S40 has both WiFi and Ethernet, so two ip-adreses. So I switched of WiFi. Using the Homey app “Net Scan” shows the SMO is not available, but pingable. This is because “Net Scan” uses a different way to test availability. As @Adrian_Rockall explains at GitHub:

> The app tries to connect to the device via the specified port. If the device connects or refuses the connection, the app reports the device is online. If there is no response, it reports it is offline.  
> Unfortunately, ping is a low-level system function that a Homey app doesn’t have access to.

The IPad app “Mtcp” also shows no response from the SMO-S40. I might have to restart that thing. But as it controls a heatpump, I want to be sure to know the right procedure.

So the problem of not being able to change the IP-address in the ModBus app is not a bug.

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [June 14, 2024, 9:05am UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/300 "2024-06-14T09:05:39Z")

</div>

New **test version 0.9.3** :

- added a 10sec delay for auto reconnect to prevent crash caused by high CPU usage while trying to auto-reconnect. The app still tries to reconnect if that’s activated in device settings until the device is reachable again. Please make sure to use a static IP.
- added error handling for changed settings to prevent using a wrong IP adress.

@Rmb FYI. I added a delay to prevent the auto reconnect is using the whole CPU time. And settings view is using the old IP is the new is not recheable. So your IP issue was showing possible enhancements 🙂

[Previous page](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497.md?page=14)

[Next page](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497.md?page=16)
