Modbus support for transformations, roller shutter items, read-only items, write-only items, and others

Personally nothing. I just tried the example from the first post and checked what is happening. So I recognized that no event was triggered …


Good thing we sorted this out. This is by design. It does not generate events, the configuration just tells which commands to process and how to do it. If you do not send MOVE, then that part of item configuration is not activated. Essentially the MOVE is handled exactly the same way as STOP or UP, for example.

Hope this clarifies it!


1 Like

This feature is now merged, and is part of standard 1.10.0 (SNAPSHOT).


Hi @ssalonen,
first of all many thanks for the great extensions, they are beautifying a lot!

Second I’m testing the extended config format of the 1.10. Snapshot artifact #1457 with OH2 and I’m receiving the following config-parsing error.

Am I missing something? Could you copy?


Switch nilan_onoff "Device main power" {modbus="nilan_modes:0"}
Number nilan_user_tempset "Target air temp [%d °C]" {modbus="<[nilan_modes:3]"} 


2017-04-16 23:25:19.686 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'nilan.items'
2017-04-16 23:25:19.698 [ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type 'modbus' of item 'nilan_user_tempset' could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: For input string: "3]"
	at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration([177:org.openhab.core.compat1x:]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings([124:org.eclipse.smarthome.model.item:]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings([124:org.eclipse.smarthome.model.item:]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.processBindingConfigsFromModel([124:org.eclipse.smarthome.model.item:]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.modelChanged([124:org.eclipse.smarthome.model.item:]
	at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.notifyListeners([123:org.eclipse.smarthome.model.core:]
	at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.addOrRefreshModel([123:org.eclipse.smarthome.model.core:]
	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.checkFile([123:org.eclipse.smarthome.model.core:]
	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.processWatchEvent([123:org.eclipse.smarthome.model.core:]

P.s. If I should rather open an issue next time, please let me know.

Hi @nickma82!

Unfortunately I cannot reproduce the issue you mentioned. Perhaps you have old binding installed? Try running bundle:list |grep -i modbus

Or perhaps you are suffering from this openHAB2 issue?


Hi @ssalonen,

You were right, sorry, my fault.
It wasn’t enough to just move the jar to ./userdata/tmp/mvn/org/openhab/binding/org.openhab.binding.modbus/1.10.0-SNAPSHOT/org.openhab.binding.modbus-1.10.0-SNAPSHOT.jar and to restart.
Re-installing the binding via the gui worked, after downloading the new snapshot .jar.

bundle:list now says:

openhab> bundle:list |grep -i modbus
218 | Active   |  80 |   | openHAB ModbusTCP Master Binding

and before the re-installation:

openhab> bundle:list |grep -i modbus
210 | Active   |  80 |   | openHAB ModbusTCP Master Binding

Thanks a lot!

1 Like

Hi @ssalonen,

I want to thank you for the great work with the transformation integration.
If you have a paypal account I would like to offer you a beer!


This is perhaps one for @ssalonen to ponder

Background: I have a number of motion/presence detectors, which I represent in OpenHAB as Contact items. Due to being hooked up in different ways to different devices they are not all acting the same way, i.e. CLOSED can be the inactive (rest) state for some, and the active (detection) state for others. Obviously, it would be good to rationalise for consistency.

So, I have some Contact items read from Modbus discrete inputs I would like to “invert”, and the new Transformation feature looked promising.

Contact Standard "sensor [%s]" {modbus="slave1:0"}
Contact Inverted "sensor [%s]" {modbus="<[slave1:1:trigger=OPEN,transformation=CLOSED],<[slave1:0:trigger=CLOSED,transformation=OPEN]"}

That seems to work - but it generates a stream of Item updates for each poll. I guess because we are working outside the scope of the updateunchangeditems=false slave setting. Given a dozen Items it generates lots of unnecessary bus activity and logs.

Using the trigger=CHANGED would work around that … but then I would not be able to achieve the inversion effect by acting differently on different inputs. Aargh!

Any thoughts on how to do this?

Yeah you are correct, it’s not possible with the current syntax.

Perhaps it was not sensible to copy the trigger logic from the other bindings as is… If there would be separate item configuration parameter for updateunchanged, would that make sense?


I suppose, but it seems to be yet more clutter and complexity.

Thinks; I have not played with script transforms because I’m not very confident. But would a script triggered off CHANGE achieve the desired result, i.e. update Item on change only? That would be a good enough workaround for oddball cases like mine.

Else, is it possible to extend the scope of the existing slave-defined updateunchanged to apply after transforms? Or rather, avoid triggering tranforms when unchanged.
It seems unlikely anyone would want different behaviour across a modbus slave but the workaround for that would be splitting virtual slaves.

CHANGED in rules should work. The original reason for the updateunchangeditems was to resolve high CPU usage issue with lot of updates – at least on openhab 1.


I had a chance to play, my first grown-up transform :smile:

To invert the sense of a Modbus discrete input:

Create the following javascript, call it mbinvert.js
(placed in /configurations/transform in OH1)

// function to invert Modbus binary states
// input variable i contains data passed by OpenHAB binding
(function(i) {
    var t = i ;      // allow Undefined to pass through
    if (i == 'OPEN') {
    	t = 'CLOSED' ;
    } else if (i == 'CLOSED') {
    	t = 'OPEN' ;
    return t ;      // return a string 

Note the ‘input’ to the script is pre-processed by the Modus binding into OPEN or CLOSED, suitable for the Contact Item it is bound to. The ‘input’ is not the raw 0 or 1 from the Modbus read.

Item defintion

//        This default Contact shows OPEN for Modbus discrete=1
Contact Standard "sensor [%s]" {modbus="slave1:0"}
//        This inverted Contact shows CLOSED for Modbus discrete=1
Contact Inverted "sensor [%s]" {modbus="<[slave1:1:trigger=CHANGED,transformation=JS(mbinvert.js)]"} 

This generates logs and bus events only when the state changes.

1 Like

Modbus transformation is not working for me.


Number zelena_temperatura_modbus "Number [%.1f]" <temperature> {modbus=">[slave1:0:transformation=JS(multiply10.js)],<[slave1:0:transformation=JS(divide10.js)]"}

In console i get error:

2017-06-20 11:16:34.637 [ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type 'modbus' of item 'zelena_temperatura_modbus' could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: Invalid number of registers in item configuration

@KJan, are you sure you have the correct version of the binding?


I installed binding from Paper UI. Is there any other way?


The feature is not available in 1.9.0. Already commented here, I believe: Modbus transformation not working

You need to install 1.10.0 (I have now higlighted this better in the opening post), please refer to this thread for the instructions how to install the binding and how to avoid possible pitfalls.



Where can i find version 1.10?

Thanks for your help :slight_smile:


Since 1.10.0 is not released yet, it is generally recommended to use the latest development version. You can find these “snapshot” versions here:


Everything is working and SetPoint in sitemap is now also working just fine :slight_smile:

Thank you again!


I’ve been playing around with these modbus bindings and have ran in to a problem.
First some context: There’s a program in my PLC which uses certain register to switch an output on or off (there’s an on and off register). In addition I’ve programmed in the PLC the possibility to configure a “PRIO high” and “PRIO low” input to switch the output on or off with priority ignoring any other inputs (including the registers). This allows the possiblity to wire an alarm system into the PLC (high reliability) and when the alarm goes of the “PRIO high” comes high and all lights switch on…

To switch the PLC from openhab using the registers i’m using the item configuration below. Note that i’m using polling on the ouput to update the item state (in case the output is switched from the logic in the PLC);

Switch DO_01_1 “Kitchenlight”

Don’t look to much at the addresses, the item has been tested and is working; meaning I can switch the output on and off.

Now here comes my problem: when the output is low and the “PRIO high” becomes high the output is made high and as long “PRIO high” is high all other inputs are ignored (including the registers used by Openhab as in the item example above). At this moment the output is high and correctly displayed as high in Openhab. However when I push switch the item to off using the habpanel the item gets the off state while the PLC output is actually high/on… It seems that the polling doesn’t update the item after the modbus command triggered by “trigger” in the item configuration.

I’ll go trough the scenario one more time step by step to make sure everything is clear:

  1. PLC output off (status openhab: off => correct)
  2. PLC output on due to “PRIO high” trigger in PLC program (status openhab: on => correct)
  3. OFF command send by openhab
  4. PLC output stays high as “PRIO high” trigger in PLC program is still high (status openhab: off => wrong)

I’m currently looking for a solution to correct this behaviour, would anyone have some input?
EDIT: forgot to mention; I’m using modbus binding 1.10.0

Thank you!