openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.86k stars 3.58k forks source link

[modbus] Raw output from modbus data #13247

Open splatch opened 2 years ago

splatch commented 2 years ago

Currently modbus binding requires mapping of data to specific types such as int or float. I would like to propose a way to let modbus:data to return a raw byte array (RawType) via specific channel.

I motivate such proposal to better cover situations where values are divided through multiple registers and they require an adjustment after retrieval. Once I managed to do it with ISG energy readings which divided MWh and kWh part into two registers. I ended up reading it as uint64 and adjusting value in a profile. While working on a Wago PLC I found even worse register layout: [value_kwh][status1][gap][value_wh][status2]. It does not fit into a limit of 8 bytes of data, so I either have to create two items and merge values, or adjust a binding. I prefer to limit amount of items early on so I come with an idea of reading a chunk of byte array into a RawType to let transformation or profile produce a final value.

MarkusThur commented 1 year ago

If we are wishing things.. From the same point, having a datatype raw and especially having the datatype string would be fine. A lot of modbus devices and also devices implementing SunSpec on modbus have datafields that represent a String. In most cases i have seen a 8 register / 16 byte string. Being able to read that would be great.

openhab-bot commented 1 year ago

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/converting-int16-to-two-characters/146518/5