Add dual-connection support for HomeWorks QS status updates#130
Open
cdheiser wants to merge 1 commit into
Open
Add dual-connection support for HomeWorks QS status updates#130cdheiser wants to merge 1 commit into
cdheiser wants to merge 1 commit into
Conversation
HomeWorks QS (QNET) only delivers status updates to telnet sessions that did not originate the command. With a single connection, commands sent by pylutron never generate inbound status updates on that same session, breaking handle_update callbacks for the caller's own actions. When the QNET> prompt is detected after login, a second LutronConnection is opened for sending commands while the original connection is kept as a monitor-only session. This is the standard industry workaround for the HWQS protocol limitation. On RadioRA 2 / QS Standalone (GNET>), behavior is unchanged. Changes to LutronConnection: - Detect and expose the prompt type (GNET/QNET) via prompt_type property - Add enable_monitoring flag to skip #MONITORING setup on the command connection (monitoring on the send session is unnecessary and could cause duplicate dispatches) Changes to Lutron: - After connect(), open a second connection when QNET is detected - Route send() through the command connection when present - Add is_homeworks property for downstream consumers Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Collaborator
Author
|
@sergiobaiao this should make status updates in homeworks work better if you wanted to try it. |
|
i'll get into it. Sorry for the lack of presence, health issues... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HomeWorks QS (QNET) only delivers status updates to telnet sessions that did not originate the command. With a single connection, commands sent by pylutron never generate inbound
handle_updatecallbacks for the caller's own actions -- lights/shades/motors appear to not respond even though the hardware moves.This PR implements the standard industry workaround: when the
QNET>prompt is detected after login, a secondLutronConnectionis opened for sending commands while the original connection is kept as a monitor-only session. On RadioRA 2 / QS Standalone (GNET>), behavior is unchanged -- single connection as before.Changes
LutronConnection:GNETvsQNET) from the login response and exposes it via aprompt_typeproperty and class constantsPROMPT_GNET/PROMPT_QNET.enable_monitoringconstructor parameter (defaultTrue). WhenFalse, the#MONITORINGsubscription commands are skipped during login. The command connection doesn't need monitoring -- the monitor connection handles all inbound status updates.Lutron:connect()checksprompt_typeafter the initial connection. IfQNET, it creates a secondLutronConnectionwithenable_monitoring=Falseand stores it as_cmd_conn.send()routes commands through_cmd_connwhen present, falling back to_connon RadioRA 2.is_homeworksproperty for downstream consumers (e.g. Home Assistant) to detect the connection mode.self._recvas its callback so that query responses (?OUTPUT,...) are still processed -- query responses return to the requesting session even on HWQS, unlike unsolicited status updates.Wire diagram:
Reconnection: Both connections use
LutronConnection._main_loopindependently, each handling their own reconnect-on-drop cycle. Since both connect to the same host, transient network issues will typically affect both simultaneously.Test plan
tests/test_homeworks.pywith 11 tests:PROMPT_GNET, QNET setsPROMPT_QNET,Nonebefore login#MONITORINGcommands sent when enabled, 0 when disabledLutron.connect()on GNET: no_cmd_conncreated,is_homeworksisFalseLutron.connect()on QNET:_cmd_conncreated,is_homeworksisTruesend()goes to_cmd_connon HWQS,_connon RadioRA 2_recvon monitor connection fireshandle_updatetests/test_connection.py: existing QNET login test now also assertsprompt_typemypy --strictclean on all 16 source files🤖 Generated with Claude Code