Rollershutter serial binding with individual commands


I have a working setup of roller shutters via serial port. There are 3 commands: UP, DOWN, STOP. But I want to have another one which moves the shutter to desired percentage openness. I’ve tried to do this many ways using rules but nothing works. So, can you help me?


Rollershutter Kitchen_shutter "Kitchen [%d %%]" { serial="/dev/ttyUSB1@19200,REGEX(POS.*11 04 (\\d*)\\d FFFF FF),UP(CMD 11 04 05\r),DOWN(CMD 11 04 04\r),STOP(CMD 11 04 03\r)" }

The REGEX gives me the percentage position of the shutter (11 is the number/address of the Kitchen shutter) and the answer from the controller looks like this (for 100% open):

POS * 11 04 1000 FFFF FF

What I want to achieve:

  1. check the current shutter position, the command for it:

POS < 11 04 FFFF FFFF FF\r

With bash it works like:

echo -ne ‘POS < 11 04 FFFF FFFF FF\r’ > /dev/ttyUSB1

  1. set the shutter to desired percentage position (70% for example):

POS > 11 04 0700 FFFF FF\r

With bash it works like:

echo -ne ‘POS > 11 04 0700 FFFF FF\r’ > /dev/ttyUSB1

Any suggestions are welcome :slight_smile:

PS. Another thing regarding items file with serial binding is that, every time I change something i’ve got an error:

Binding configuration of type ‘serial’ of item ‘Kitchen_shutter’ could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: Could not open serial port /dev/ttyUSB1: Serial port ‘/dev/ttyUSB1’ could not be found. Available ports are:

And I have to restart entire VM. Then it works just fine. It’s really pain in the ass with this. Regular OH restart does not work - the same error. Anyone?

I think I’d be inclined to manage this with a rule based “binding”, it is generally easier to work with once you get beyond on/off conditions.

Have a dummy virtual Item to represent your rollershutter, and a linked String Item to send/receive on serial.
One rule can listen for commands to your dummy, and build the string you need to command to serial.
Another rule listens for updates from serial and decodes to update dummy position state.

Thanks. I think I found something (a running example code) you are writing about. Like a proxy item.
I’ll try to implement it and post my findings.