OpenHAB 3 & BenQ Binding?

Really enjoying the results after our major upgrade to OH3; curious if anyone is working on upgrading the old BenQ binding for OH3, or has anyone identified other ways to control/instrument the BenQ 1070 PJ? I utilized this binding regularly in OH2 days…

BenQProjector binding for OH3 would be the finishing touch to my current home theatre setup, and most likely many others too. :slight_smile:

I looked at the BenQ protocol and it is very simple. I would look into porting the old binding but I don’t have a BenQ projector to test with. In the meantime you can use the Serial binding and some rules to accomplish basic control of a BenQ projector. You will first create an serialBridge thing with the correct port and baud rate for your projector. Then you will create a ‘string’ item off of the serial bridge and name it ‘BenqProjector’ The create the items, rules and sitemap as described below:

benq.items

Switch ProjectorPWR "Projector Power" 
String ProjectorSource "Projector Source [%s]" 

benq.rules:

rule "BenqProjector Projector Power"
when
    Item ProjectorPWR received command
then
    if(receivedCommand==ON){
	    sendCommand(BenqProjector, "\r*pow=on#\r")
        logInfo("BenqProjector", "Projector Power ON")
    } else if(receivedCommand==OFF){
	    sendCommand(BenqProjector, "\r*pow=off#\r")
        logInfo("BenqProjector", "Projector Power OFF")
    }
end

rule "BenqProjector Change Source"
when
    Item ProjectorSource received command
then
    sendCommand(BenqProjector, "\r*sour=" + receivedCommand + "#\r")
    logInfo("BenqProjector", "Projector Source: " + receivedCommand)
end

benq.sitemap:

sitemap benq label="BenqProjector" {
    Frame label="BenQ Projector" {
        Switch item=ProjectorPWR
        Switch item=ProjectorSource label="Projector Source" mappings=[hdmi="HDMI 1", hdmi2="HDMI 2", RGB="Computer", ypbr="Component", svid="S-Video", vid="Composite"]
    }
}
1 Like

@mlobstein - Thanks a lot for having a look into this! Unfortunately I can’t easily hook up my Raspberry Pi4 directly to the Projector due to locations/cabling. Per the OH 2 BenQ binding documentation above, I was actually using a IP to Serial converter device like this to interface it with my OH server:

https://www.newegg.com/usr-tcp232-evb-enginnering-development-tools/p/285-001M-000E2?Item=9SIA2RP49N6235

Much greater level of detail found here regarding this type of setup, but for OH2:

Per the following thread, OH3 does not have a TCP Binding yet, which would likely help me find a solution here. There are some potential workarounds such as using Node Red as mentioned, but I’d prefer this was implemented natively rather than introduce another dependency for my Home Automation:

Half debating just rolling some good 'ole shell scripts to poll and control via CURL at this point, but that seems dirty too :slight_smile:

From the description of your solution, it sounds like you have a CAT 5 cable running to your projector. On my Panasonic projector I use one of these: Monoprice USB Extender over Cat5e or Cat6 Connection up to 150ft - Monoprice.com to connect a USB serial adapter from the projector to a CAT 5 cable and then to a Raspberry Pi USB port on the other end. Using that I can connect the serial port of the projector directly to Openhab and was using the serial binding with custom rules to control it as described in my first reply. The only issue was with three other USB ports in use, the addition of this adapter was drawing more power and would cause the Pi to reboot when it initialized the USB devices until I added a 1000uf 6.3v capacitor across the +5v and GND gpio pins. Since then it has been working great for years now.

1 Like

Do you have an old RPi laying around? If so, you could install your old OH2 setup on that, remove everything except the BenQ stuff, and use the Remote binding in OH3 to interface with it.

1 Like

@mlobstein - Much appreciated. Actually setup is a little different here - 10ft electric screen drops whenever the PJ gets power. The IP to RSR232 device is in the attic right above the PJ, with Cat6 running to that and the serial cable coming down through the ceiling to the PJ. My PJ doesn’t have its own ethernet connection, only serial, hence the need for this intermediary device ATM… Interesting approach with the extender + capacitor; wish my older PJ had its own ethernet jack!!! Would be ideal to remove the additional electronics in the attic from the equation here. But as my house is laid out today, this approach would require pulling a new 100ft cable from the hardest to reach parts of the attic too. ACK! :slight_smile:

@rpwong - that is definitely doable. I thought about doing this too as I came across others on the community forums here running a separate OH2 instance only for specific unsupported devices in OH3, and then bridging them into the ‘main’ OH3 server. Naturally, I’m still fishing for the cleanest solution possible; so far this is as close as it gets without developing throw away CURL scripts to poll/control it all from a single OH3 instance, or better yet just buying a new OH3 supported PJ with ethernet and call it a day. :slight_smile:

Thank you both!

What functions are you wanting to use with the binding? I finished porting the Epson projector binding into OH3 and later morphed that code into a basic binding for Panasonic projectors (so I could remove the custom rules based control from my setup). I could take a swing at morphing it again into basic binding for the BenQ protocol to enable Power On/Off, Source selection, etc. It might be a slow process for you to try out multiple test builds since I don’t have a BenQ to test with.

2 Likes

@mlobstein - Seriously, thanks for all the help here and your community contributions across the board. Personally, I am really just after Power On/Off and Source selection, as you initially suggested. Other bells and whistles are nice to haves but not needed for my setup, and probably most others with a BenQ PJ too (such as monitoring lamp hours, volume, mute, etc.). More than happy to help with any and all alpha/beta testing you might need along the way!

All - do you have interest in OpenHAB 3 BenQ Projector support as well? Please chime in here so we can better assess that this in demand for a larger user base beyond myself. I think there are others lurking here, but ‘never assume’ :slight_smile:

Cheers
.

OK here you go…

A draft binding to connect BenQ projectors to OH 3 (completely untested at this point):

https://github.com/mlobstein/mlobstein-beta-test/raw/master/org.openhab.binding.benqprojector-3.1.0-SNAPSHOT.jar

Documentation:
https://github.com/mlobstein/openhab-addons/raw/benqprojector/bundles/org.openhab.binding.benqprojector/README.md

If you receive an error about openhab-transport-serial, issue the following command in the openhab console:

feature:install openhab-transport-serial

To enable debugging output to the openhab console/log, issue the following command:

log:set DEBUG org.openhab.binding.benqprojector

Use this to see the log output in the console:

log:tail

3 Likes

@mlobstein - Awesome! I have it installed and working through initial configuration & testing now. Thanks a bunch for your efforts here!

@mlobstein - you are a wizard. First pass, zero testing as you don’t have the hardware on hand, and yet it works well already! I’ve successfully tested the following so far (over BenQ Projector TCP/IP), with OpenHAB v3.0.1:

  • Power
  • Screen Blanking
  • Source Switching

I noticed you wired in a BUNCH of commands/options that my particular PJ doesn’t have support for as well, but I will do my best to test the crap out of all available options and share my results in the coming day. In a few cases so far while playing with the Power and Source (I only have HDMI1/HDMI2 on my BenQ model 1070) selections, these items went into following ‘odd’ state:

*Block item

For Power, when it had a state of ‘Block item’ I was still able to toggle it ON and then OFF again to shut it down and roll up the screen automatically via the Main UI model. Wonderful!

Give me some time to dig in deeper all the options and play with the binding in a variety of scenarios for some strong ‘real world’ testing with OH3 (i.e. manual selections, scenes, rules, etc.).

YOU ROCK - this made my day!!! :sunglasses:

1 Like

Re: Block item; According to the protocol documentation:

If a command with correct format cannot be executed under certain condition, it will echo Block item

I think the projector is saying that it can’t process the command at the moment. For example I could see that right after powering on, there is a warm up period before commands like changing source can be processed. More code would need to be written to trap these and re-try the command. But that is beyond what I can do from this end.

Yes I did pack the source, picturemode and aspectratio drop downs with all options that were described in the documentation since there are so many variations of projectors and no easy way to tailor the options to each model.

You should look at the directcmd channel too. The examples show how to use this to send arbitrary commands to projector beyond what the main channels can do.

1 Like

@mlobstein - All points taken. The 1070 goes a bit unresponsive to even the IR remote when powering up/down, amongst other things.

Looked at that too - well done! I’ve linked this advanced channel with the equipment already as well for deeper testing. :slight_smile:

If there is anyone else here has a different/newer model BenQ PJ please help us with testing this new binding out!

@mlobstein - it seems that polling is failing for some reason. I increased the polling rate to 5s, and enabled debugging…

Seeing this repeatedly with the PJ powered OFF and ON:

15:27:47.119 [DEBUG] [rojector.internal.BenqProjectorDevice] - Query: 'pow=?'
15:27:47.223 [DEBUG] [rojector.internal.BenqProjectorDevice] - Response: '>*pow=?
*POW=ON
'
15:27:47.224 [DEBUG] [internal.handler.BenqProjectorHandler] - Error executing command 'Power', Invalid respose for command: pow=?

I also noticed that various other items such as Source do not update if they are changed manually with the PJ remote. Playing with the items via the Main UI regularly logs this:

15:31:49.163 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'NetworkDeviceBx10010192_Latency' changed from 18.0 ms to 17.0 ms
15:31:49.484 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'NetworkDeviceBx10010192_LastSeen' changed from 2021-02-27T15:30:49.140-0500 to 2021-02-27T15:31:49.480-0500
15:31:53.676 [DEBUG] [rojector.internal.BenqProjectorDevice] - Query: 'pow=?'
15:31:53.779 [DEBUG] [rojector.internal.BenqProjectorDevice] - Response: '>*pow=?
*POW=ON
'
15:31:53.781 [DEBUG] [internal.handler.BenqProjectorHandler] - Error executing command 'Power', Invalid respose for command: pow=?
15:31:53.784 [DEBUG] [rojector.internal.BenqProjectorDevice] - Query: 'sour=?'
15:31:53.886 [DEBUG] [rojector.internal.BenqProjectorDevice] - Response: '>*sour=?
*SOUR=HDMI2
'
15:31:53.889 [DEBUG] [internal.handler.BenqProjectorHandler] - Error executing command 'Source', Invalid respose for command: sour=?
15:31:53.892 [DEBUG] [rojector.internal.BenqProjectorDevice] - Query: 'appmod=?'
15:31:53.994 [DEBUG] [rojector.internal.BenqProjectorDevice] - Response: '>*appmod=?
*APPMOD=STD
'
15:31:53.996 [DEBUG] [internal.handler.BenqProjectorHandler] - Error executing command 'PictureMode', Invalid respose for command: appmod=?
15:31:53.999 [DEBUG] [rojector.internal.BenqProjectorDevice] - Query: 'appmod=?'
15:31:54.103 [DEBUG] [rojector.internal.BenqProjectorDevice] - Response: '>*appmod=?
*APPMOD=STD
'
15:31:54.105 [DEBUG] [internal.handler.BenqProjectorHandler] - Error executing command 'AspectRatio', Invalid respose for command: appmod=?
15:31:54.108 [DEBUG] [rojector.internal.BenqProjectorDevice] - Query: 'freeze=?'
15:31:54.210 [DEBUG] [rojector.internal.BenqProjectorDevice] - Response: '>*freeze=?
*FREEZE=OFF
'
15:31:54.212 [DEBUG] [internal.handler.BenqProjectorHandler] - Error executing command 'Freeze', Invalid respose for command: freeze=?
15:31:54.217 [DEBUG] [rojector.internal.BenqProjectorDevice] - Query: 'blank=?'
15:31:54.319 [DEBUG] [rojector.internal.BenqProjectorDevice] - Response: '>*blank=?
*BLANK=OFF
'

However all of the expected commands do in fact work (including DirectCMD commands). While testing everything the binding has to offer, as long as my PJ model has that feature/setting, it works well! A nicety would be have the ability to hide the many other command options for a better user experience, but no worries there… Only major problem observed so far here revolves around the failed polling of the many states, and of course the aforementioned ?*Block item issue.

Another tidbit regarding polling - I tried to inspect the TCP activity on my OH Server by running this repeatedly (filtering for the port defined in the PJ’s thing configuration), and it does show the communication is happening. I definitely did install the feature too BTW (feature:install openhab-transport-serial).

sudo netstat -nputw |grep 20108

tcp6       0      0 10.0.10.161:49310       10.X.XXX.XXX:20108         ESTABLISHED 667/java

From what I can tell the polling request is hitting the network stack, as I would expect, but is failing to properly parse the response… Because of this, when toggling Power ON via the Main UI, it quickly switches back to OFF. A rapid ON/OFF toggle is the only way to actually power it down. The other oddity is that while the Thing shows as ONLINE, making any changes to the Thing Configuration results in it changing to UNKNOWN and then getting stuck in an OFFLINE state, until another Power ON command is sent via the Main UI.

Glad to help however possible!

Best regards,
.

Thanks for posting the debug output. The polling was failing because the command sent was being reflected back as the first part the response. I wasn’t expecting it to do that. I have updated the code and pushed up an updated jar. Hopefully it will work now.

1 Like

Sure thing. Pulled down the latest JAR, stopped OH, cleared caches, and restarted the server. Unfortunately polling is still wonky. With the PJ Powered ON, the switch keeps reverting back to OFF with each poll. So I powered it OFF (quick double toggle between ON/OFF), re-enabled DEBUG and found this error happing with each attempt to poll:

19:17:39.625 [DEBUG] [rojector.internal.BenqProjectorDevice] - Query: 'pow=?'
19:17:39.729 [DEBUG] [rojector.internal.BenqProjectorDevice] - Response: 'pow=?*POW=OFF'
19:17:39.732 [DEBUG] [internal.handler.BenqProjectorHandler] - Error executing command 'Power', Invalid respose for command: pow=?

Then powered it back ON, and saw this getting logged repeatedly:

19:22:22.872 [DEBUG] [rojector.internal.BenqProjectorDevice] - Query: 'pow=?'
19:22:22.976 [DEBUG] [rojector.internal.BenqProjectorDevice] - Response: 'pow=?*POW=ON'
19:22:22.978 [DEBUG] [internal.handler.BenqProjectorHandler] - Error executing command 'Power', Invalid respose for command: pow=?

So it seems now its getting the proper response, but unfortunately its maybe not being parsed correctly ATM within the binding…

Then every once in a while it tries to poll the state of other items, and this gets logged:

19:24:48.552 [DEBUG] [rojector.internal.BenqProjectorDevice] - Query: 'pow=?'
19:24:48.657 [DEBUG] [rojector.internal.BenqProjectorDevice] - Response: 'pow=?*POW=ON'
19:24:48.660 [DEBUG] [internal.handler.BenqProjectorHandler] - Error executing command 'Power', Invalid respose for command: pow=?
19:24:48.665 [DEBUG] [rojector.internal.BenqProjectorDevice] - Query: 'sour=?'
19:24:48.769 [DEBUG] [rojector.internal.BenqProjectorDevice] - Response: 'sour=?*SOUR=HDMI2'
19:24:48.772 [DEBUG] [internal.handler.BenqProjectorHandler] - Error executing command 'Source', Invalid respose for command: sour=?
19:24:48.775 [DEBUG] [rojector.internal.BenqProjectorDevice] - Query: 'appmod=?'
19:24:48.878 [DEBUG] [rojector.internal.BenqProjectorDevice] - Response: 'appmod=?*APPMOD=STD'
19:24:48.881 [DEBUG] [internal.handler.BenqProjectorHandler] - Error executing command 'PictureMode', Invalid respose for command: appmod=?
19:24:48.885 [DEBUG] [rojector.internal.BenqProjectorDevice] - Query: 'appmod=?'
19:24:48.988 [DEBUG] [rojector.internal.BenqProjectorDevice] - Response: 'appmod=?*APPMOD=STD'
19:24:48.993 [DEBUG] [internal.handler.BenqProjectorHandler] - Error executing command 'AspectRatio', Invalid respose for command: appmod=?
19:24:48.997 [DEBUG] [rojector.internal.BenqProjectorDevice] - Query: 'freeze=?'
19:24:49.100 [DEBUG] [rojector.internal.BenqProjectorDevice] - Response: 'freeze=?*FREEZE=OFF'
19:24:49.104 [DEBUG] [internal.handler.BenqProjectorHandler] - Error executing command 'Freeze', Invalid respose for command: freeze=?
19:24:49.109 [DEBUG] [rojector.internal.BenqProjectorDevice] - Query: 'blank=?'
19:24:49.212 [DEBUG] [rojector.internal.BenqProjectorDevice] - Response: 'blank=?*BLANK=OFF'
19:24:49.215 [DEBUG] [internal.handler.BenqProjectorHandler] - Error executing command 'Blank', Invalid respose for command: blank=?

Clearly an improvement in the Responses here!

All the best,
.

@mlobstein and I worked through a couple of issues on the side; this new BenQ Projector binding for OpenHAB 3 is working great! Super happy to have my Home Theatre setup back in action with OH3 under the hood.

Thanks so much for everything here!

1 Like

Good news for those that used to use the tcp binding:
udptcp binding seems to be on its way in OH3 3.1.1 milestone
(see: OH3 tcpudp binding on github )

1 Like

I am trying to determine if BenQ protectors with built-in networking provide some means to implement discovery in openHAB. I see reference to AMX device discovery in some of the projectors’ documentation. If this is turned on the projector should send UDP broadcast packets to identify the device on the network. Attached is a wireshark showing what the AMX beacon packet generated from an Epson projector looks like. Can anyone confirm that a BenQ projector generates similar beacons?

@mlobstein - wish I could help here, however my BenQ PJ doesn’t have built in networking.