[SOLVED] Optoma beamer via RS232 over TCP/IP connector

Tags: #<Tag:0x00007efecce86dc8> #<Tag:0x00007efecce86c10> #<Tag:0x00007efecce86af8>

I try to get my projector (Optoma HD25) connected to OpenHAB. It has a RS232 serial port. As the projector is mounted to the ceiling and far away from my OpenHAB server, I want to use a RS232-to-Ethernet converter (I use a USR-TCP232-302). It is set up as a TCP server now.
I can connect via putty (9600bps 8N1) and it works well. I can send commands on the telnet and recieve the answer. Also if switched on/off by the remote I get the string in the telnet.
Now I look for a binding to use with openHAB. What I need are two items to switch it on/off and to get the status as a string (which I will interpret by a rule):

String Projector_Status "Beamer Status [%s]" (gTV) { ??? }
Switch Projector_OnOff "Beamer OnOff [%s]" (gTV) { ??? }

I tried to get it work with the TCP-UDP binding (without a tcp.cfg file) like

tcp="<[192.168.X.XX:YYYY:'~01150 1']"
tcp=">[ON:192.168.X.XX:YYYY:'~0100 1'], >[OFF:192.168.X.XX:YYYY:'~0100 2']"

for the ???. But this does not work. Any idea what’s wrong here and what I have to put for ???

I think the Exec Binding can solve your Problems …

rule "TV power"
	  Item TV received command ON

here is a Example for telnet in bash script

My Way is a Raspberry Pi Zero W with USB to RS232 Adapter and a little NodeJS App

Thank you. That’s not quite what I was looking for, but this gave me a new idea.
I redirected the TCP to a virtual COM port on my Openhab Sever with

sudo socat pty,link=/dev/vircom0,raw  tcp:192.168.X.XX:YYYY&
sudo chown openhab /dev/vircom0 

a local serial console to /dev/vircom0 works as before. Now I thought I can use the serial binding :slight_smile: But how to get this unusual port accessible in OH2 ? Where to add the


as described in the documentation ?

Sorry for delayed reply. I run openHAB2 from a manual installation while testing. The doc says there is no preconfigured configuration file (https://docs.openhab.org/installation/linux.html#file-locations). Unfortunately googling did not find anything useful and I have to ask again here. So how do I set up a configuration file for a manual installation?

sudo nano /etc/default/openhab2


unfortunately it is not that easy. I tried this and put the line


into the file. But OH2 gives the error

Could not open serial port /dev/vircom0: Serial port '/dev/vircom0' could not be found. Available ports are:

as soon as it tries to open the serial port for my item.
The virtual port is there, and I can read/write via putty to it.

file settings are:

-rw-r--r-- 1 openhab root 57 Jan 24 21:14 /etc/default/openhab2
lrwxrwxrwx 1 root    root 11 Jan 21 12:57 /dev/vircom0 -> /dev/pts/22
crw--w---- 1 openhab tty 136, 22 Jan 21 13:01 /dev/pts/22

any other idea?

I gave up on the virtual COM port and tried the TCP binding from scratch. It works exactly the way I posted it in the first post. I just had to make sure that the data sent end with a “/r/n”. This can be done either in the tcp.cfg or in the submitted string.

I was not really satisfied with the above solution and the TCP binding is unstable. So I did a totally other appraoch. I already have some MQTT items and why not let the projector chat with openHAB via MQTT?
My solution is a small python script that does the work. Just in case it would be handy for someone:

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    __author__ = "Jürgen Gluch"
     Copyright 2018 Jürgen Gluch
     Script:  beamer_tcp_mqtt.py
     Author:  Jürgen Gluch
     Purpose: Communicate with Projector RS232 over the TCP-RS232 bridge with MQTT messages

    import socket
    import paho.mqtt.client as mqtt

    # define the TCP conection to the beamer
    TCP_IP = '192.168.XX.XX'
    TCP_PORT = 23
    BUFFER_SIZE = 128

    # define the MQTT connection for communication with openHAB
    broker = "192.168.XX.XX"
    username = "mqtt"

    # send data to beamer
    def on_message_tobeamer(mosq, obj, msg):
      mqttmsg = str(msg.payload.decode("utf-8"))
      print("to beamer: " + mqttmsg )
      msgtcp = bytes(mqttmsg+"\r", 'utf-8')

    ### Main programm
    if __name__ == '__main__':
        # establish TCP connection
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect((TCP_IP, TCP_PORT))
        # Add message callbacks that will only trigger on a specific subscription match.
        client = mqtt.Client()
        client.message_callback_add("groundfloor/living/projector/send", on_message_tobeamer)
        # Connect to MQTT and wait for messages
        client.on_message = on_message_mqtt
        client.username_pw_set(username, password)
        client.connect(broker, 1883, 60)
        client.subscribe("groundfloor/living/projector/send", 0)
        # infinite loop ...
        print("Wait for signals:")
        while True:
          # receive data from beamer 
          data = str( s.recv(BUFFER_SIZE) )
          # cut the "b'" at front and "\r" at end
          data = data[2:len(data)-3] 
          print("Received data from beamer: " + data)
          client.publish("groundfloor/living/projector/get", data)

      except KeyboardInterrupt:
        print("Stopped by user")
        print("Exit by error")
        print("The End.") 

Thanks JGluch, that sounds like a great idea, and nice and simple script. TCP binding seems to be majorly broken, it spams reconnect or not connected messages 2. sec initially, and then after a day ups it to around 10.000 a second. And it doesn’t reconnect for me.

I tried your script, I installed python3 and ‘pip install paho-mqtt’.
I also added ‘raise’ after print(“Exit by error”).

I’m missing ‘on_message_mqtt’.


Hi Jürgen,

please can you explain me, how I can start your script. I have also an Optoma beamer and I want to switch on and off the beamer with a rule.


Sorry for the late reply. I start the python script in a console on my server and let it run there. Like this:

python3 beamer_tcp_mqtt.py