So I am using the openhabian on my RPI. I have a multiplexer relay board connected to my computer, as the board is created by the company for internal use, so it is not available to the outside public. However, the board is being controlled by the command line. I have connected my board to my computer through a com port and then I have accessed it serially through putty and I can control it on my computer through the command line there. However, I was hoping I can integrate and control this command line through my openhabian simple GUI. Would it be possible somehow?
I know that I need to install the exec binding, but how can I access this specific command line of this multiplexer board, that is something I would need some ideas on.
Thank you for your attention. All help is greatly appreciated.
Hello,
Based on my little experience you have a couple of ways to manage it:
First Option: Create an exec command on openhab for every specific command you would use (hard to mantain e fills your openhab of specific exec things)
Second Option: You can create a script that supports arguments so you can manage all the commands you need to use based on the argument passed, then in openhab you can create
a single exec command thing with /path/to/my/script/myscript %2$s
The final part â%2$sâ allows openhab to pass arguments.
So you can dynamically call the exec binding with a rule passing the argument you want (or create dummy items/switches to trigger the command you like manually).
ps. if your board already support just one command with arguments you donât even need to create a script but just use that command.
Hope it helps.
A.
2 Likes
MDAR
(Stuart Hanlon, UK importer of Velbus hardware)
3
The Exec binding is easy enough to configure in PaperUI.
Have you tried adding a Exec Binding Thing and seeing how you get on?
As long as the permissions are set correctly within your raspberry pi, the command should work.
Keep in mind, you / openHAB2 canât interact with the command once itâs running. (Because there isnât a TTY console for the openHAB âuserâ)
you can send variables to the Thing command by using the input channel and putting %2$s in the command line instruction
I.E. sh test_script.sh content=%2$s
You canât use sudo to elevate commands because the openHAB2 user is not part of the sudoer group (you canât enter the password anyway)
The output channel will capture the output from the command, so could be used in rules
I.E. I have a generic TCP command for a multi output ethernet relay board, which returns the current state of every relay channel, regardless of what command is send.
So a simple rules splits the output to update switch states.
But it does not really do anything to be honest. Do you think I am doing something wrong? I am SSH-ing in to the openhabian through putty and connecting the board serially to my computer. Just stating it for reference. The COM port is 11 and baudrate which I am using is 115200. And u1 and u0 are the commands to switch between two modes of USB, one is the USB Host, which I switch to by sending u1 as the command in the terminal window and u0 makes it off. This is how I control the board on my pc.
I donât think itâs clear what is running where. You are talking about com ports which are a Windows only concept. And you are talking about sshâing to an openHABian machine through putty which is a Linux machine.
So where is this serial device? If itâs plugged into a Windows machine then it is not plugged into the same machine that openHAB is running on, which was an important stipulation I made in my original reply.
Thanks a lot. That was the problem. I needed to connect my board to the raspberry pi. Now the binding works correctly and I am able to send the commands to the command line.