Lutron OH2 binding

Thanks. Hopefully there’s a reasonable amount in common with both GRX and QS. I’m new to both OH and programming a Lutron system (and my house is only half wired) so it might take a little while…

I think I can see why the binding doesn’t work for Homesworks QS systems.

Looking at the code for the binding, it seems to expect that the telnet session prompt is “GNET>”. In fact the Homeworks QS prompt is “QNET>” - so presumably the binding should be watching for either variant?

If my knowledge of Github and creating bindings was greater than zero then I’d try to change this myself - perhaps someone else is knowledgeable/kind enough to do so?

Dan

Hi Allan, I added a new handler to the binding to allow for the use of phantom (or Virtual) buttons on the repeater. This allows you to set your scenes using RadiaRa2 Config studio and activate them using OH2. Currently, I only have it for the phantom buttons 1-10.

My main reason to add this handler was to turn on/off lights all at the same time instead of using a rules where OH2 has to process each light individually. I found this led to a “stagged” action when turning on a series of lights in the same area. (This was really noticable on Raspberry pi).

I’ll work on a PR later this week. (I’ll be honest…I have never done use Git before, so that is new to me!)

Thanks for making this binding, I use it daily!

Does this binding work with the Smart bridge? I only have the smart bridge not the pro.

No, it does not work with the non-pro version. Only the Smart Bridge Pro allows for telnet integration which is what the binding uses to communicate with and control the Lutron lights.

I started using OpenHab this evening, mostly to mess around with MQTT.

HOWEVER

When looking through the available bindings, I stumbled across this one.

I am a professional Lutron dealer/installer/programmer based in the UK. I mainly focus on Homeworks QS.

I have only recently started looking at java, and I would love to write something for openhab to control HWQS.

I have developed something similar for Crestron systems (using SIMPL+, Crestron’s programming language loosely based around C++, except it’s called a module rather than a binding). This module primarily makes it easy for programmers to add sliders and buttons to their user interfaces, and have the status of those items displayed back from HWQS in real time.

So I am familiar with Crestron, C++, VERY familiar with the Lutron integration protocol but lacking in the OH department (Java mostly)

I would love to get into this, and learn more java, so if anyone can give me any tips or pointers on developing for OH that would be great, and I want to help as much as I can on this, particularly getting it to work on HWQS so ask me anything.

Also can confirm, will not work for HWQS.

I am also surprised there is not a user-configurable telnet client already built into openhab?

Right now I have got it controlling HWQS but I am going from OH2 to Crestron (via http post) then to Lutron

(which will help nobody and I dont like it, too cumbersome. I am trying to find a replacement for the Crestron)

Would be great if someone smarter than me could confirm if making the binding work for HWQS really is as easy as changing the expected Telnet prompt…

You know, I imagine it would be.(but need to double check that). when I get
home I will send a link to the prospective integration protocols.

I have also written a couple of python scripts doing the same thing, will
send over when I get a chance, might be tomorrow evening though

Were you able to make progress on this, @dwbro1? I also am new to Caseta and OpenHAB. I successfully have two dimmers and two pico remotes configured with the Lutron OH2 binding.

Have you been able to add your Pico remotes to your OpenHAB system, @Dansker? I have the Caseta system with the SmartBridge Pro 2 using this Lutron binding. My Pico remotes show up as a “seeTouch Keypad” in the PaperUI. They work perfectly fine with the following channels:

(note: replace nameofpico with the name of your pico Thing)
lutron:keypad:nameofpico:button2 = top button (100%/ON button)
lutron:keypad:nameofpico:button3 = middle button (favorite button)
lutron:keypad:nameofpico:button4 = bottom button (0%/OFF button)
lutron:keypad:nameofpico:button5 = raise button (increase/UP button)
lutron:keypad:nameofpico:button6 = lower button (decrease/DOWN button)

The remaining channels are unused (as far as I can tell). This includes button1.

Something to note when making rules for these Pico remotes, the Lutron hub recognizes both the button press and the button release. So each time a button is used, there are two communications:

~DEVICE,2,3,3
~DEVICE,2,3,4
(Output from my Lutron SmartBridge Pro 2 when I press (and of course release) the middle button on my Pico which is ID 2 in the hub.)

David

easily found on google:

Homeworks QS definitely spits out QNET

my .py script went a little like this:

import xml.etree.ElementTree as ET
import telnetlib

Hostname = "192.168.1.2"
Username = "user1"
Password = "user1"
commandString = "#DEVICE,7,70,3"

def starter():
Feedback = True
tn = telnetlib.Telnet(Hostname)

tn.read_until('login: ')
tn.write(Username + '\r\n')
tn.read_until('password: ')
tn.write(Password + '\r\n')

tn.read_until("QNET> ")
tn.write(commandString + '\r\n')

if Feedback:
    response =  tn.read_until("\n", 1)
    tn.write('\x1d' + '\r\n')
    tn.close()
    if response == 'QNET> ':
        return False
    else:
        return response
else:
    tn.read_until("QNET> ")
    tn.write('\x1d' + '\r\n')
    tn.close()

starter()

But I had to have one of these per command (replicating a keypad button)

Was using this for tasker integration on android phone.

Do we know if anyone who can develop these bindings is working on this?

It is making me want to pick up binding development, but I need to learn how first!

Just an update in case anyone cares.
I have rewritten the python code so that it takes the command in the form of 4 arguments passed from the exec binding.

This is working for me to control homeworks QS for now…

#!/usr/bin/python


import xml.etree.ElementTree as ET
import telnetlib
import sys


Hostname = "192.168.1.11"
Username = "user2"
Password = "user2"
commandString = "#" + sys.argv[1] + "," + sys.argv[2] + "," + sys.argv[3] + "," + sys.argv[4]
 
def starter():
Feedback = True
tn = telnetlib.Telnet(Hostname)

tn.read_until('login: ')
tn.write(Username + '\r\n')
tn.read_until('password: ')
tn.write(Password + '\r\n')

tn.read_until("QNET> ")
tn.write(commandString + '\r\n')

if Feedback:
    response =  tn.read_until("\n", 1)
    tn.write('\x1d' + '\r\n')
    tn.close()
    if response == 'QNET> ':
        return False
    else:
        return response
else:
    tn.read_until("QNET> ")
    tn.write('\x1d' + '\r\n')
    tn.close()

starter()

thanks, Tom. I’ve been using something similar (but with Expect scripts). The really useful thing would be to be able to monitor Lutron keypads/scenes/etc too. I’m toying with scripts that achieve that, but it all gets a bit messy - clearly a case where a binding is the better approach.

agreed.

I have yet to pull the trigger and download eclipse and start hacking away with java but have not had time.

Will update when I have!

Sorry for taking so long. I’ve built a jar that should account for the different prompt in HomeWorks QS, though I can’t test it myself. It’s available here if anyone wants to try it.

Many thanks, that’s brilliant.

Have started testing - getting somewhat confusing results which I’m trying to get on top of, but there is one more immediate issue.

The binding starts working fine - autodiscovery works as it should, and I can then add keypads as Things. But after a while the binding fails with an error and the bridge Thing goes offline. A few minutes later the bridge is autodiscovered again and appears in the inbox (but the original bridge Thing remains offline).

The logs look like this:

2017-02-09 18:24:27.197 [DEBUG] [nding.lutron.handler.IPBridgeHandler] - Sending command ?SYSTEM,10
2017-02-09 18:24:27.197 [ERROR] [nding.lutron.handler.IPBridgeHandler] - Communication error, will try to reconnect
java.io.IOException: Could not write to stream
	at org.openhab.binding.lutron.internal.net.TelnetSession.writeLine(TelnetSession.java:218)[211:org.openhab.binding.lutron:2.1.0.201702082009]
	at org.openhab.binding.lutron.handler.IPBridgeHandler.sendCommands(IPBridgeHandler.java:198)[211:org.openhab.binding.lutron:2.1.0.201702082009]
	at org.openhab.binding.lutron.handler.IPBridgeHandler.access$2(IPBridgeHandler.java:190)[211:org.openhab.binding.lutron:2.1.0.201702082009]
	at org.openhab.binding.lutron.handler.IPBridgeHandler$3.run(IPBridgeHandler.java:176)[211:org.openhab.binding.lutron:2.1.0.201702082009]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_121]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_121]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]
2017-02-09 18:24:27.198 [DEBUG] [nding.lutron.handler.IPBridgeHandler] - Keepalive timeout, attempting to reconnect to the bridge
2017-02-09 18:24:27.200 [DEBUG] [nding.lutron.handler.IPBridgeHandler] - Disconnecting from bridge
2017-02-09 18:24:27.200 [ERROR] [nding.lutron.handler.IPBridgeHandler] - Error disconnecting
java.net.SocketException: Socket closed
	at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:118)[:1.8.0_121]
	at java.net.SocketOutputStream.write(SocketOutputStream.java:155)[:1.8.0_121]
	at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)[:1.8.0_121]
	at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)[:1.8.0_121]
	at java.io.FilterOutputStream.close(FilterOutputStream.java:158)[:1.8.0_121]
	at org.apache.commons.net.telnet.TelnetClient._closeOutputStream(TelnetClient.java:86)[186:org.apache.commons.net:3.2.0]
	at org.apache.commons.net.telnet.TelnetOutputStream.close(TelnetOutputStream.java:155)[186:org.apache.commons.net:3.2.0]
	at org.apache.commons.net.telnet.TelnetClient.disconnect(TelnetClient.java:127)[186:org.apache.commons.net:3.2.0]
	at org.openhab.binding.lutron.internal.net.TelnetSession.close(TelnetSession.java:116)[211:org.openhab.binding.lutron:2.1.0.201702082009]
	at org.openhab.binding.lutron.handler.IPBridgeHandler.disconnect(IPBridgeHandler.java:235)[211:org.openhab.binding.lutron:2.1.0.201702082009]
	at org.openhab.binding.lutron.handler.IPBridgeHandler.reconnect(IPBridgeHandler.java:245)[211:org.openhab.binding.lutron:2.1.0.201702082009]
	at org.openhab.binding.lutron.handler.IPBridgeHandler.sendCommands(IPBridgeHandler.java:206)[211:org.openhab.binding.lutron:2.1.0.201702082009]
	at org.openhab.binding.lutron.handler.IPBridgeHandler.access$2(IPBridgeHandler.java:190)[211:org.openhab.binding.lutron:2.1.0.201702082009]
	at org.openhab.binding.lutron.handler.IPBridgeHandler$3.run(IPBridgeHandler.java:176)[211:org.openhab.binding.lutron:2.1.0.201702082009]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_121]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_121]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]
2017-02-09 18:37:07.508 [DEBUG] [RadioRA2MainRepeaterDiscoveryService] - Scanning for RadioRA2 main repeaters
2017-02-09 18:37:08.522 [DEBUG] [RadioRA2MainRepeaterDiscoveryService] - Discovered main repeater lutron:ipbridge:00DE1DFF

Any help you can provide would be much appreciated!

Yeah, the reconnect logic when the binding loses connection to the bridge needs some TLC. The log output helps, thanks. I’ll see what I can do to make that more robust.

The log shows that the binding lost communications with the bridge. I made new version of the binding that should hopefully allow it to recover from this situation. Note it only tries to reconnect once every 5 minutes.