Modify pylutron

Hi. I have been working with a HassOS on a VM and several integrations flawlessly for a few months now. The only problem I have had is with the Lutron Homeworks QS. Everything mapped pretty well and seems to respond, except a few scenes (probably incompatible keypads), but the problem is that HA stops talking to Lutron every once in a while. The logs indicate a disconnect every minute or so, and “monitoring” Telnet messages it doesn’t recognize. Both the HA server and the Lutron equipment are on cable. I get the same behavior many people have mentioned, where it stops updating light states, and after toggling something it goes back, as if it didn’t get a good response from Lutron. I also tried changing the state directly or calling a toggle or on/off service, with no success, until a restart happens. Since my installation doesn’t seem to get me easy access to pylutron file I am considering:

  • Using manual telnet messages (might work but it would be alot of work to sniff all of them and code them into switches)
  • Finding a way to access the files, even though from what I understand the change from GNET to QNET is no longer needed…
  • Trying another installation of HA where I can access the needed files
  • Switching users with a device, since I am not 100% sure what users have been assigned to devices here, and thought one of them could be using the lutron/integration one, and conflicting.

The repeating pattern I get in the log is the following:

2020-08-01 21:50:38 WARNING (Thread-2) [pylutron] Disconnected
2020-08-01 21:50:38 INFO (Thread-2) [pylutron] Connecting
2020-08-01 21:50:41 INFO (Thread-2) [pylutron] Connected
2020-08-01 21:50:41 INFO (Thread-2) [pylutron] Unknown cmd MONITORING (~MONITORING,12,2)
2020-08-01 21:50:41 INFO (Thread-2) [pylutron] Unknown cmd MONITORING (~MONITORING,255,2)
2020-08-01 21:50:41 INFO (Thread-2) [pylutron] Unknown cmd MONITORING (~MONITORING,3,1)
2020-08-01 21:50:41 INFO (Thread-2) [pylutron] Unknown cmd MONITORING (~MONITORING,4,1)
2020-08-01 21:50:41 INFO (Thread-2) [pylutron] Unknown cmd MONITORING (~MONITORING,5,1)
2020-08-01 21:50:41 INFO (Thread-2) [pylutron] Unknown cmd MONITORING (~MONITORING,6,1)
2020-08-01 21:50:41 INFO (Thread-2) [pylutron] Unknown cmd MONITORING (~MONITORING,8,1)

Any help is appreciated. Thanks!

The errors you’re describing are indicative of a network issue. Dima (maintainer of pylutron) has worked to get reconnects working, but it’s proven to be a bit difficult, and doesn’t work 100% of the time. The short of it is that when your main repeater goes offline, or loses network, the ability for HA to reconnect to it is impacted. Sometimes, it’ll reconnect, but a lot of times, it won’t. I’d recommend you investigate the stability of your network because I haven’t had issues for months at a time with this integration.

1 Like

Thanks for the quick response Jon. Sorry I took this long to reply. I have been trying to pinpoint the problem for months now, with no success. I can connect through telnet to lutron and maintain a connection indefinitely with a terminal. The commands on HA with the lutron integration also seem to work for many hours, sometimes days, even though reconnections are happening every 1-2 minutes. Then it just stops responding, and I am not even sure for how long. It just goes back to working by itself. Nothing else shows in the logs, other than the recurring reconnects. I checked all the devices here, and they all have their own unique login users. I also kept pinging the HA server, lutron, and from HA to lutron, and had no package losses… Honestly don’t know what else to try, other than the telnet integration, which would be a lot of work

So, a quick update. I am still getting the repeating:

2020-09-30 23:42:55 INFO (Thread-5) [pylutron] Connected
2020-09-30 23:42:55 INFO (Thread-5) [pylutron] Unknown cmd MONITORING (~MONITORING,12,2)
2020-09-30 23:42:55 INFO (Thread-5) [pylutron] Unknown cmd MONITORING (~MONITORING,255,2)
2020-09-30 23:42:55 INFO (Thread-5) [pylutron] Unknown cmd MONITORING (~MONITORING,3,1)
2020-09-30 23:42:55 INFO (Thread-5) [pylutron] Unknown cmd MONITORING (~MONITORING,4,1)
2020-09-30 23:42:55 INFO (Thread-5) [pylutron] Unknown cmd MONITORING (~MONITORING,5,1)
2020-09-30 23:42:55 INFO (Thread-5) [pylutron] Unknown cmd MONITORING (~MONITORING,6,1)
2020-09-30 23:42:55 INFO (Thread-5) [pylutron] Unknown cmd MONITORING (~MONITORING,8,1)
2020-09-30 23:45:52 WARNING (Thread-5) [pylutron] Disconnected
2020-09-30 23:45:52 INFO (Thread-5) [pylutron] Connecting
2020-09-30 23:45:55 INFO (Thread-5) [pylutron] Connected
2020-09-30 23:45:55 INFO (Thread-5) [pylutron] Unknown cmd MONITORING (~MONITORING,12,2)
2020-09-30 23:45:55 INFO (Thread-5) [pylutron] Unknown cmd MONITORING (~MONITORING,255,2)
2020-09-30 23:45:55 INFO (Thread-5) [pylutron] Unknown cmd MONITORING (~MONITORING,3,1)
2020-09-30 23:45:55 INFO (Thread-5) [pylutron] Unknown cmd MONITORING (~MONITORING,4,1)
2020-09-30 23:45:55 INFO (Thread-5) [pylutron] Unknown cmd MONITORING (~MONITORING,5,1)
2020-09-30 23:45:55 INFO (Thread-5) [pylutron] Unknown cmd MONITORING (~MONITORING,6,1)
2020-09-30 23:45:55 INFO (Thread-5) [pylutron] Unknown cmd MONITORING (~MONITORING,8,1)
2020-09-30 23:47:26 WARNING (Thread-5) [pylutron] Disconnected
2020-09-30 23:47:26 INFO (Thread-5) [pylutron] Connecting
2020-09-30 23:47:35 INFO (Thread-5) [pylutron] Connected

This pattern happens every 2 minutes, approx. I now have the HA server connected directly to the same switch as Lutron. I don’t see how instability in the network would cause such evenly spaced problems (but I am no network expert). It seems like some programmed routine, either in HA or Lutron is generating this issue, through poor socketing, or something like it. I believe the MONITORING messages shouldn’t have much to do with it, but they seem to fit perfectly in the recurring pattern. I would guess every reconnection HA receives those, and only after about 2 minutes of these messages, the connection crashes.

Any other ideas?

Thank you btw, i was about to start writing Telnet commands until i cam across this thread.

I’m using HASSIO, Where is “the list”, I’m guessing it is in pylutron but am crossing my fingers it is just in config somewhere, otherwise I guess i’m going to be forking the repo and creating a custom component.

The list I was referring to is a set of strings in init.py I believe. Can’t remember for sure. What I have tried on my test server that is working very well is this great pull from @rzulian which turns my legacy keypad buttons into scenes and can found at this thread:

@namurdock @FMG

If you want to try the current branch I’ve a repo with the Lutron custom component here

2 Likes

Hey @rzulian and @txwindsurfer , thanks for the help, suggestions and work.

I tried the custom component. I believe I did it correctly, by keeping the “lutron” part of my config file, and just adding the custom component files to the config/custom_components/lutron_custom_component-master folder. It is working exactly like before, except some of the entities, which were not useful anyways, are not available. Unfortunately the repeating disconnect pattern is still happening:

2020-11-12 18:37:39 WARNING (Thread-3) [pylutron] Disconnected
2020-11-12 18:37:40 INFO (Thread-3) [pylutron] Connecting
2020-11-12 18:37:40 INFO (Thread-3) [pylutron] Identified Lutron Controller.HOMEWORKS
2020-11-12 18:37:40 INFO (Thread-3) [pylutron] Connected
2020-11-12 18:37:40 INFO (Thread-3) [pylutron] Unknown cmd MONITORING (~MONITORING,12,2)
2020-11-12 18:37:40 INFO (Thread-3) [pylutron] Unknown cmd MONITORING (~MONITORING,255,2)
2020-11-12 18:37:40 INFO (Thread-3) [pylutron] Unknown cmd MONITORING (~MONITORING,3,1)
2020-11-12 18:37:40 INFO (Thread-3) [pylutron] Unknown cmd MONITORING (~MONITORING,4,1)
2020-11-12 18:37:40 INFO (Thread-3) [pylutron] Unknown cmd MONITORING (~MONITORING,5,1)
2020-11-12 18:37:40 INFO (Thread-3) [pylutron] Unknown cmd MONITORING (~MONITORING,6,1)
2020-11-12 18:37:40 INFO (Thread-3) [pylutron] Unknown cmd MONITORING (~MONITORING,8,1)
2020-11-12 18:41:03 ERROR (Thread-3) [pylutron] Uncaught exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/pylutron/__init__.py", line 192, in _main_loop
    line = t.read_until(b"\n", timeout=3)
  File "/usr/local/lib/python3.8/telnetlib.py", line 317, in read_until
    self.fill_rawq()
  File "/usr/local/lib/python3.8/telnetlib.py", line 526, in fill_rawq
    buf = self.sock.recv(50)
TimeoutError: [Errno 110] Operation timed out
2020-11-12 18:41:03 WARNING (Thread-3) [pylutron] Disconnected

I don’t recall being able to get this much info on the problem in the logs, but other than that, it looks like the same problem.

Any other suggestions? Do you believe outdated Lutron Homeworks QS firmware could be the cause? I am trying to contact a local company to back it up, and update it.

1 Like

Try putting the custom component files into the folder named:

config/custom_components/lutron

The custom_components folder should be the same name as the component.

Thanks for the tip. Unfortunately it didn’t seem to change anything.

Hi,
I have a Grafikeye QS that have a IP interface that I think is the same commands as homeworks QS. How ever there is only a login and no password and prompt is blank as in no QNT> just

Using putty on port 23 I get this login screen:
login: with one space after :
When I enter my login default nwk I get this prompt:

connection establised
on the line under just a blank

I have had a look at https://github.com/home-assistant/core/pull/9121/commits/efe7a5580d7bdc0e36cfd06ea8641f36d8a8745c without any success.

I have this LUA script that works:

ocal socket = require “socket”
local lutron_tcp

function connectLutron()
lutron_tcp = assert(socket.tcp())
lutron_tcp:settimeout(0.5)
lutron_tcp:connect(“192.168.0.50”, 23)
end

function sendLutron(cmd)
lutron_tcp:send(cmd … “\r”)
sleepLutron()
end

function disconnectLutron()
lutron_tcp:close()
end

function sleepLutron()
luup.sleep(500)
end

function powerOnLutron()
sendLutron(“password”)
sleepLutron()
end

connectLutron()
powerOnLutron()
sendLutron("#DEVICE,0x000b0eb9,3,14,30,1")
disconnectLutron()

Thanks in advance!

Removed an earlier post… After re-reading some of the posts above realised that there is some work done on the component that’s waiting to be approved that could work with the QS system I have… Thanks for all the amazing work everyone!

I was able to get HomeAsistant to connect to my Homeworks QS system and it pulled all of the devices and scenes.

The issue is that Lutron does not seem to report the state of the devices to HomeAssistant. Has anyone been able to get the states to work properly? If I change it in HomeAssistant it shows the change, but if a light is turned off in the house, it doesn’t update HomeAssistant.

Did anyone figure this out for a Lutron QSX system?

1 Like

did you ever figure out what the problem was?

I get exactly the same repeated errors in the log, although my Lutron shades are working stable.
Seems to come every 1,5 min.

I’m using a RadioRA Repeater on old firmware, because newer firmwares require a never version of the configuration software, that in turn requires an authorised installer code.

So could be old firmware. But I guess could also be some python settings for max connection keep alive or something?

I have been using it like that for all this time, and haven´t figured out anything else. It seems to work fine with Big Timer in Node Red resending the state messages for the timed routines, even though the errors still show in the logs.

also no problems for me either. rock stable and reacts instantaneously.
… apart from the log messages that is.

wondering could it be some default timeouts in Python or maybe even the kernel?

I’m using HA Core on a Raspberry PI 3b and latest Raspberry PI OS Bullseye. no docker, firewall or anything else.

Did you get it working with QSX processor ?

Thanks

1 Like

I also have a QSX system. I have access to the Crestron QSX modules that have the DLL files in it for communicating. if someone smarter than me can decompile the file using something .NET Reflector, they could probably get the required key from the DLL so we can talk to QSX systems. Also Radio RA3 will become more prominent now as well which will likely be the same communication using secured LEAP instead of telnet.

I haven’t done my QSX upgrade yet, but that will be done within the next few weeks. Their LEAP communication is relatively new, I’m hoping that someone smarter than me and more time on their hands will figure this out sometime :wink:

https://support.lutron.com/us/en/product/radiora3/article/integration/Lutron-s-LEAP-API-Integration-Protocol