Modbus binding of rollershutter

Hi,

I am wondering whether it is possible to bind a rollershutter by modbus. I have tried it and the openhab.log shows to following traces:

2015-10-12 16:29:20.642 [ERROR] [i.internal.GenericItemProvider] - Binding configuration of type ‘modbus’ of item ?myRollerShutter? could not be parsed correctly.
org.openhab.model.item.binding.BindingConfigParseException: item ‘myRollerShutter’ is of type ‘RollershutterItem’, only Switch, Contact or Number are allowed - please check your *.items configuration
at org.openhab.binding.modbus.internal.ModbusGenericBindingProvider.validateItemType(ModbusGenericBindingProvider.java:71) ~[na:na]
at org.openhab.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:347) [org.openhab.model.item_1.7.1.jar:na]
at org.openhab.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:324) [org.openhab.model.item_1.7.1.jar:na]
at org.openhab.model.item.internal.GenericItemProvider.processBindingConfigsFromModel(GenericItemProvider.java:171) [org.openhab.model.item_1.7.1.jar:na]
at org.openhab.model.item.internal.GenericItemProvider.modelChanged(GenericItemProvider.java:390) [org.openhab.model.item_1.7.1.jar:na]
at org.openhab.model.core.internal.ModelRepositoryImpl.notifyListeners(ModelRepositoryImpl.java:159) [org.openhab.model.core_1.7.1.jar:na]
at org.openhab.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:100) [org.openhab.model.core_1.7.1.jar:na]
at org.openhab.model.core.internal.folder.FolderObserver.checkFolder(FolderObserver.java:142) [org.openhab.model.core_1.7.1.jar:na]
at org.openhab.model.core.internal.folder.FolderObserver.run(FolderObserver.java:99) [org.openhab.model.core_1.7.1.jar:na]

From the log point of view only Switch, Contact or Number are allowed for Modbus binding.

Can someone comment this?
Is there any known workaround to get this working?

Many thanks ahead.
Best regards,
Jens

What are you trying to achieve by having a roller shutter control? I am able with rules to convert modbus items to percent.
Here is how I was able to use the buttons seperately

Rollershutter volume “Familyroom TV [%s]” (SF_Family, Volume, TV) {samsungtv=“UP:Familyroom:KEY_VOLUP, DOWN:Familyroom:KEY_VOLDOWN, STOP:Familyroom:KEY_MUTE”}

Hi David,

this is quite easy to understand. My aim is to create (as you did with samsungtv binding) a Rollershutter item to directly communicate to my WAGO Modbus controller.

Rollershutter myRS “RS” (livingRoom) {modbus=“slave1:<0:>1”}

As you can see in the sample code above the Modbus address 0 is used as read register to read out the actual shutter position (needed for the app-UI). The modbus write register 1 will be used for commands to control the shutter (UP, DOWN).

What I do not understand from your sample code how you could manage that the samsungtv binding can read/write Modbus registers?

In the meantime I have been able to extend the existing org.openhab.binding.modbus implementation to my demands and it works as expected.

Hello Jens,
could you please post the item/rules/persistence that you have used to manage rolling shutter ?
It would be very useful for me …
Thanks in advance

you might try something like

Rollershutter myRS "RS" (livingRoom) {modbus="UP:slave1:1, DOWN:slave1:3"}

Where I believe slave1:1 is the contact for up and slave1:3 is the contact for down

Hello, thank you for your reply.

I put in tems:
Rollershutter myRS “RS [%d %%]” (All) {modbus=“UP:slave1:6, DOWN:slave1:7”}

and in sitemap:
Switch item=myRS label=“test rollershutter”

But i do not get any effect on my Digital Outputs.

My feeling (nothing more than that) is that the use of rules is necessary to manage DO for rollershutter, therefore I’ll try to customize this solution

that was implemented through switch and not rollershutter.

Any suggestions, as usual, are very appreciated :wink:

At the moment I can control rollershutter via DI and DO with Openhab switches. I’d rather use items dimmer or rollershutter to have a visual feedback on the GUI of what is the status of the blind … (I don’t know if I was clear :frowning: )

Maybe something like this for the state

rule	"Rollershutter Position"
when
	Item Roll_1_UP_Limit received update	or
	Item Roll_1_DOWN_Limit received update
then
	if(Roll_1_UP_Limit.state==ON) {
		postUpdate(Roll_1_Position,100)
	}
		else {
			if(Roll_1_Down_Limit.state==ON) {
				postUpdate(Roll_1_Position,0)
			} 
			else {
				postUpdate(Roll_1_Position,50)
			}
		}

Directly from the wiki pages I found this:

about the “Example for binding shutter using HTTP GET commands” I try to ask what follows:

  1. The measure of the status of the RS measured with variable “newState” works only if the stop button is pushed. When someone pushes for example the UP button when the rollershutter is going DOWN then the RS is stopped but the “newState” is not updated.

Does anyone already have worked with this and have suggestions ?

Hi,

Sorry for my late reply but currently I only have limited time for this topic.

  1. When you have a look at ModbusGenericBindingProvider.java::validateItemType(...) you will see that RollershutterItem.class is not supported. That means whatever you do with Rollershutter items and Modbus binding will not work.

  2. So I took the decision to implement the modbus Rollershutter binding by my own.

  3. How does it work: The Modbus binding needs to be configured as follows:
    { modbus:slave1:>readReg:<writeReg) }

    readReg: Percent: 0-100 state of rollershutter set by MODBUS controller
    writeReg: UP/DOWN cmd (UP value++ / DOWN value–)
    writeReg+1: STOP cmd (value=1, must be reset by MODBUS controller)

As you can see I need 2 consecutive writeReg to control the rollershutter. This was the only way to have a quick and simple implementation inside the modus-binding module.
Furthermore it is important to know that both writeReg needs to be cleared with ZERO after the command has been processed by the modus controller.

  1. I have to check how I can deploy my code to the github-repository. Or am I allowed to upload my SNAPSHOT version directly here in this post?

Cheers.

Hey Jens,
thanks for your reply.

I personally have used 2 digital Output coils and 2 switches to manage my rollershutter customizing what I found here:

(Let me know if you are interested in the code)

About your question 4) which would be very interesting for me, in order to test your solution, unfortunately I cannot answer … :frowning:

MFG

Lorenzo

Hi guys

I am interested in your code.

I’m managing my shutters via MQTT, controlling a small IoT device built by myself. I have UP and DOWN commands.

I have now in place the rollershutter demo from the documentation.

But the problems that I have:

  1. The actual state doesn’t show until I press STOP
  2. It never sends the STOP command to the shutter. Is not a problem because it have its own hard stop, but would be nice to stop it anyways.
  3. I can’t send a value like 33% and expect the shutters to go to that point and stop.

Regards

@Jens_Zeidler do you have any update on this? The working rollershutter solution for Modbus is what I’m waiting for.
@lorenzo_leonelli could you put your code here?

Cheers

Hi, sorry for my late reply. I’m managing rollershutter with contacts, so I hope in future i can using a rollershutter item as well.

Config:

Lorenzo - Test Connessione con WAGO DIGITAL OUTPUT

modbus:tcp.slave1.poll=5000
modbus:tcp.slave1.connection=192.168.1.40:502
modbus:tcp.slave1.id=1
modbus:tcp.slave1.type=coil
modbus:tcp.slave1.start=512
modbus:tcp.slave1.length=52
#modbus:tcp.slave1.valuetype=bit

Lorenzo - Test Connessione con WAGO DIGITAL INPUT

modbus:tcp.slave2.poll=5000
modbus:tcp.slave2.connection=192.168.1.40:502
modbus:tcp.slave2.id=1
modbus:tcp.slave2.type=discrete
modbus:tcp.slave2.start=0
modbus:tcp.slave2.length=56
#modbus:slave2.valuetype=bit

Sitemap:

Switch item=MySwitch_T_Salotto_Grande_UP icon=“socket” label=“Tapp. Salotto Grande UP” visibility=[MySwitch_T_Salotto_Grande_DOWN==OFF]
Switch item=MySwitch_T_Salotto_Grande_DOWN icon=“socket” label=“Tapp. Salotto Grande DOWN” visibility=[MySwitch_T_Salotto_Grande_UP==OFF]

Items:

Contact MyContact_T_Salotto_Grande_UP “Pulsante Tapparella Salotto Grande UP” (All) {modbus=“slave2:2”}
Contact MyContact_T_Salotto_Grande_DOWN “Pulsante Tapparella Salotto Grande DOWN” (All) {modbus=“slave2:3”}

Switch MySwitch_T_Salotto_Grande_UP “Tapparella Salotto Grande UP” (All, G_Stanze_Salotto, gTapparelle) {modbus=“slave1:18”}
Switch MySwitch_T_Salotto_Grande_DOWN “Tapparella Salotto Grande DOWN” (All, G_Stanze_Salotto, gTapparelle) {modbus=“slave1:19”}

Rules:

// lambda expression that can be used as a function (here: with 5 parameters)
val org.eclipse.xtext.xbase.lib.Functions$Function5 rolloLogic = [
org.openhab.core.library.items.SwitchItem relayItem,
org.openhab.core.library.items.SwitchItem relayItemOpposite,
java.util.Map<String, org.openhab.model.script.actions.Timer> timers,
String timerKey, int timeout |
timers.get(timerKey)?.cancel
timers.put(timerKey, createTimer(now.plusSeconds(timeout)) [|
if (relayItem.state == ON)
relayItem.sendCommand(OFF)
timers.remove(timerKey)
])
]

// Contatti Fisici Tapparella Salotto_Grande
rule "rollo up Salotto_Grande"
when Item MyContact_T_Salotto_Grande_UP changed to OPEN then
if(MySwitch_T_Salotto_Grande_UP.state == ON || MySwitch_T_Salotto_Grande_DOWN.state == ON ) {
MySwitch_T_Salotto_Grande_UP.sendCommand(OFF)
MySwitch_T_Salotto_Grande_DOWN.sendCommand(OFF)
} else { MySwitch_T_Salotto_Grande_UP.sendCommand(ON) }
end
rule "rollo down Salotto_Grande"
when Item MyContact_T_Salotto_Grande_DOWN changed to OPEN then
if(MySwitch_T_Salotto_Grande_UP.state == ON || MySwitch_T_Salotto_Grande_DOWN.state == ON ) {
MySwitch_T_Salotto_Grande_UP.sendCommand(OFF)
MySwitch_T_Salotto_Grande_DOWN.sendCommand(OFF)
} else { MySwitch_T_Salotto_Grande_DOWN.sendCommand(ON) }
end
// Contatti Logici Tapparella Salotto_Grande
rule "up Salotto_Grande"
when Item MySwitch_T_Salotto_Grande_UP changed to ON then
rolloLogic.apply(MySwitch_T_Salotto_Grande_UP, MySwitch_T_Salotto_Grande_DOWN, rolloTimers, “Salotto_Grande”, 17)
end
rule "down Salotto_Grande"
when Item MySwitch_T_Salotto_Grande_DOWN changed to ON then
rolloLogic.apply(MySwitch_T_Salotto_Grande_DOWN, MySwitch_T_Salotto_Grande_UP, rolloTimers, “Salotto_Grande”, 17)
end

sorry for the late reply, please let me know if I can be still helpful anyhow

ciao

Hi all,

I have placed my own implementation on dropbox. The link is as follows:

Please also have a look at post 10 in this thread:
item configuration:

The Modbus configuration (openhab.cfg) shall be as shown below:

modbus:tcp.slave1.connection=192.168.178.1:502 modbus:tcp.slave1.id=1 modbus:tcp.slave1.type=holding

Important is to use the type=holding

Item-sample:

Rollershutter myRS "rollershutter" (livingRoom) {modbus="slave1:<0:>1"}

-> reg 0: is read register and keeps the actual shutter pos, must be written by WAGO controller
-> req 1: is write register, value <0 for UP command, value >0 for DOWN command, WAGO must reset this value after processing
-> reg 2: is write register, value ==1 is STOP command, WAGO must reset this value after processing

Next used Item:

Rollershutter myRS2 "rollersutter2" (livingRoom) {modbus="slave1:<3:>4"}

ciao

1 Like

Hi,

Thanks for this, can You also show wago side ? How You set up values for this and reset them.

Hi

I was just looking in implementing openHAB shutters via MQTT with an ESP8266 connected to relays.
I haven’t found any examples on how to do it (found only shutters via HTTP/GET.

Can you share your code?

Thanks
Woody

@woody4165 - Unless your ESP8266 is running Modbus, you might be better to start to start a new thread with MQTT in the title

I would be glad, please start a new thread MQTT related, or send me an email so I can show you what I did.

Hello Jens_Zeidler,

Thanks for sharing your implementation.
I have just installed openhab2.
Do you know if the new modbus binding (1.9) already include what we need for the shutter, or should we download your binding ?

Thanks