# \[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:** 12

<div class="post-metadata">

**Author:** ![freki](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/freki/32/7111_2.png) [@freki](https://community.homey.app/u/freki)\
**Post date:** [April 17, 2024, 7:15pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/221 "2024-04-17T19:15:45Z")

</div>

Hi,

Yes it can certainly be a misunderstanding on my behalf but since it is working flawless to read data I cannot understand what is going wrong when writing. 🙂

The ModBus RTU port is for my heatpump convectors are configured like this:

 ![Daikin Serial port features](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/0/b/0b44b1a97af5e5180bd2da39c5d0b51a26e17e3f.png)

Which I read as to be 8 bits and not 16, but maybe I’m mixing bits and bytes here… 😃

But when thinking about it again, it cannot really by single 8 bit words, it must be 2 x 8-bit words, as you suggested, otherwise the number space will be too small for the numbers I can read out. 🙂

As an example of what type of values I’m trying to read and write:

 ![Daikin Modbus register example](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/d/6/d65bb4695e635ef194fa5a50d9dfd809066ab8cd.png)  
(Decimal values are multiplied by 10, so the number 16,5 would be read/written as 165.)

Good thinking about the LE/BE possibility but I tried to write with all the types available from the “Write Holding Register”-card but none of them works I’m afraid. The all give the same error code: “Encountered an unexpected error value: ‘[object Object]’”

I tried to create a diagnostics report: 4363fc10-3928-4af0-9ebf-8bf558158818

I hope we can solve this and again, thanks for all your effort with this app!

---

<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:** [April 18, 2024, 6:23pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/222 "2024-04-18T18:23:45Z")

</div>

The log is showing a lot of connects/disconnects. You have set “single connect”, right?  
But when the app tries to write the register, it get’s a **“Req timed out” error**.

The app uses the writeMultipleRegisters function to write a byte array. Do you have documentation what the converter is able to read/write? Perhaps it can only handle singe register updates?

The error you got is a bit irritating. I think the used module is returning an invalid error object (perhaps a string or JSON instead). I added **additional error handlings** in **new test version 0.7.5** to get a valid message (hopefully).

Edit:  
The converter or your RTU device supports functions 03 and 06 (read single/write single register).  
The app uses 16 (write multiple registers) to use a generic write function where the amount of written registers depends on the data type.  
I can only try to add a “write single register” action for 16bit data.

---

<div class="post-metadata">

**Author:** ![freki](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/freki/32/7111_2.png) [@freki](https://community.homey.app/u/freki)\
**Post date:** [April 18, 2024, 7:31pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/223 "2024-04-18T19:31:26Z")

</div>

Hi,

Thanks for your hard work with this!

But I think your conclusion might be correct, since my RTU device only supports single registers!

Yes I’ve used Single connect but have now altered to Keep connection.

I’m afraid I cannot find any good spec on the converter regarding supported RTU functions, hopefully it supports them all but and my problem will be solved by a SingleRegisterWrite-action! 🙂

More info about the converter can be found here:

> **[RS485 TO ETH (B) - Waveshare Wiki](https://www.waveshare.com/wiki/RS485_TO_ETH_(B)?amazon#Introduction)**

I just tried the new test version, 0.7.5, and the error log came out like this:  
{“err”:“Timeout”,“message”:“Req timed out”,“request”:{“\_id”:2,“\_protocol”:0,“\_length”:9,“\_unitId”:2,“\_body”:{“\_fc”:16,“\_address”:“203”,“\_values”:{“type”:“Buffer”,“data”:[1,24]},“\_byteCount”:8,“\_numberOfBytes”:2,“\_quantity”:1,“\_valuesAsBuffer”:{“type”:“Buffer”,“data”:[1,24]},“\_valuesAsArray”:[280]}}}

But my guess is that a new single register write-action will do the trick!

---

<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:** [April 19, 2024, 8:08am UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/224 "2024-04-19T08:08:29Z")

</div>

Hi @RonnyW. May I ask to add FLOAT32-LE to the write flow card? I have some registers in my inverter that are stored as FLOAT32-LE; I can read them without problems, but can’t write to them.

---

<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:** [April 19, 2024, 2:04pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/225 "2024-04-19T14:04:17Z")

</div>

New **test version 0.7.6** :

- Splitted writing registers into single (16bit) and multi register action (\>16bit)

If your are writing 16bit values (1 register), the “write single register” function is used (#06).  
If you are writing longern values (\>1 register), the “write multiple registers” function is used (#16).

@freki FYI and test 🙂

---

<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:** [April 19, 2024, 2:05pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/226 "2024-04-19T14:05:52Z")

</div>

> [@CaptainVoni](#):
>
> FLOAT32-LE to the write

I will take a look at it shortly.

---

<div class="post-metadata">

**Author:** ![freki](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/freki/32/7111_2.png) [@freki](https://community.homey.app/u/freki)\
**Post date:** [April 19, 2024, 5:56pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/227 "2024-04-19T17:56:59Z")

</div>

Great job Ronny!

The new writing works! 🙂

So the writing goes through and when I read the same register I get the expected value, so your solution is correct. Great!  
BUT unfortunately the writing action card also fails with the following error code:

“Cannot destructure property ‘bytes’ of ‘(intermediate value)’ as it is undefined.”

BR, Fredrik

---

<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:** [April 19, 2024, 6:49pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/228 "2024-04-19T18:49:08Z")

</div>

> [@freki](#):
>
> “Cannot destructure property ‘bytes’ of ‘(intermediate value)’ as it is undefined.”

That can only happen if the conversion from input value into byte buffer doesn’t work.  
What value/type are you writing?

---

<div class="post-metadata">

**Author:** ![freki](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/freki/32/7111_2.png) [@freki](https://community.homey.app/u/freki)\
**Post date:** [April 19, 2024, 7:17pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/229 "2024-04-19T19:17:21Z")

</div>

Hmm, strange.  
I tried many different numbers, all as INT16, for instance; 0, 280, 120 and -120 and all of them were written correct since I could read the same values back from the device.

Could it be a return status value that is not returned or interpreted correct?

Den fre 19 apr. 2024 20:59Ronny Winkler via Homey Community Forum \<[notifications@athom.discoursemail.com](mailto:notifications@athom.discoursemail.com)\> skrev:

---

<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:** [April 19, 2024, 7:29pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/230 "2024-04-19T19:29:06Z")

</div>

> [@freki](#):
>
> Could it be a return status value that is not returned or interpreted correct?

Exactly, it’s the returned Byte string that’s passed back as result token (the token you can use after teh flow card is finished).  
I just wonder how this can be undefined.  
I can write INT16 values without problems and I get the correct token.  
Do you get the error every time or only for some values? Can you please send me a diagnostic report? I would like to check the log. Thanks 🙂

---

<div class="post-metadata">

**Author:** ![freki](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/freki/32/7111_2.png) [@freki](https://community.homey.app/u/freki)\
**Post date:** [April 19, 2024, 7:51pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/231 "2024-04-19T19:51:20Z")

</div>

I get this error every time I try to write to a register, regardless of the value unfortunately.

The log is here:  
fab88896-3f32-481a-9435-baaad2ac6159

Den fre 19 apr. 2024 21:39Ronny Winkler via Homey Community Forum \<[notifications@athom.discoursemail.com](mailto:notifications@athom.discoursemail.com)\> skrev:

---

<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:** [April 19, 2024, 9:25pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/232 "2024-04-19T21:25:05Z")

</div>

There are no error in your log. The result (byte string) is correct.  
On my Homeys (19+23) all is working and the bytes string is returned as token.  
Currently I have no idea why you get errors 🤷‍♂️  
I added an additional log line. Let’s try again with the new version. Please check and create a new report. You don’t need to post the ID. I get a mail with the log.

---

<div class="post-metadata">

**Author:** ![freki](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/freki/32/7111_2.png) [@freki](https://community.homey.app/u/freki)\
**Post date:** [April 20, 2024, 7:16am UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/233 "2024-04-20T07:16:20Z")

</div>

Strange!  
I’ve tried a couple of things here but cannot get any other result than before. I hope the log I just sent gives any more clues! 🙂

---

<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:** [April 20, 2024, 8:14am UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/234 "2024-04-20T08:14:03Z")

</div>

The app returns a valid token. The last log line is just before returning it to Homey.  
 ![Screenshot_20240420_101012_Email](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/0/b0bb5efffeec56f350d292dc53bac5b08c3ab97b.jpeg)

Last idea…are you using AdvancedFlow od StandardFlow? I added this token to the action card but I think this will only work for AdvancedFlows. So if you already added this card before I released the update including the token, this could be a reason.

---

<div class="post-metadata">

**Author:** ![freki](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/freki/32/7111_2.png) [@freki](https://community.homey.app/u/freki)\
**Post date:** [April 20, 2024, 11:36am UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/235 "2024-04-20T11:36:47Z")

</div>

Hmm, yes it certainly looks correct. I have no idea why the card “fails” but since the actual writing works I happy with that. 🙂

I’m using an Advanced Flow for this.

But I just to try one more thing; I removed the app from Homey, restarted Homey and reinstalled the app and added the actioncards again, unfortunately with the same result as before…

Let me know if you want me to test something else, for now I’m totally happy with just ignoring that the card fails since the action itself is actually performed. 🙂

I will send you a donation for all your hard work, this is an extremely important and very awaited app! Thanks Ronny!

---

<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:** [April 20, 2024, 6:02pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/236 "2024-04-20T18:02:54Z")

</div>

Hi again,  
with help from robertklep (thanks again!) I think the flow action should work now without errors.  
I think you used the slave device, right? I couldn’t see this in the logs because the modbus action is performed by the master device.  
Can you please check the latest test version 0.7.9? Thanks.

---

<div class="post-metadata">

**Author:** ![freki](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/freki/32/7111_2.png) [@freki](https://community.homey.app/u/freki)\
**Post date:** [April 20, 2024, 6:18pm UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/237 "2024-04-20T18:18:37Z")

</div>

Now it works! Almost…

No errors and all writing works as expected! 🙂  
(And yes, I’m using a modbus RTU slave device.)

Thanks to you and to @robertklep! 🙂

But now I get an errorcode when trying to read registers instead.  
The actioncard “Read Holding Register” now returns error: “registerType is not defined”  
(I have used Type INT16, same as before, strange!)

---

<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:** [April 21, 2024, 8:31am UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/238 "2024-04-21T08:31:41Z")

</div>

> [@CaptainVoni](#):
>
> Hi @RonnyW. May I ask to add FLOAT32-LE to the write flow card? I have some registers in my inverter that are stored as FLOAT32-LE; I can read them without problems, but can’t write to them.

I forgot the “16bit Word LE” - it is “FLOAT32-LE (16bit Word LE)”. The manufacturers definitively use too many different types. ☹

---

<div class="post-metadata">

**Author:** ![Sasan\_Khandanpour](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/sasan_khandanpour/32/79941_2.png) [@Sasan\_Khandanpour](https://community.homey.app/u/Sasan_Khandanpour)\
**Post date:** [April 21, 2024, 9:59am UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/239 "2024-04-21T09:59:14Z")

</div>

Hi, since last update the app doesn’t work anymore. I get the error:“registerType is not defined”. It comes with all queries.

---

<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:** [April 21, 2024, 10:29am UTC](https://community.homey.app/t/app-pro-modbus-connect-every-modbus-devices/104497/240 "2024-04-21T10:29:56Z")

</div>

I’m running the latest test version here (0.7.9) and can successfully access three different devices with different register types. If you provide some more information, it might be easier to track down any issues.

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

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