Dispatch LEVEL_CHANGED event on set_level for QNET controllers#125
Open
GitDakky wants to merge 1 commit into
Open
Dispatch LEVEL_CHANGED event on set_level for QNET controllers#125GitDakky wants to merge 1 commit into
GitDakky wants to merge 1 commit into
Conversation
HomeWorks QS processors (QNET protocol) do not echo back ~OUTPUT state changes on the same telnet connection that sent the command. This means the LEVEL_CHANGED event was never dispatched after set_level(), causing Home Assistant to revert the UI state. GNET controllers (original HomeWorks) echo the state change as a monitoring event, so the event was dispatched via handle_update(). On QNET, handle_update() is never called for self-initiated changes. This fix dispatches the event immediately after updating the internal level, ensuring HA (and any other consumer) gets notified regardless of controller protocol. Tested on Lutron HomeWorks QS Gulliver processors (firmware 15.10.0) at Longueville Hall, Jersey — 558 entities, lights/switches/shades.
Collaborator
|
Wow... HomeWorks QS is just a pile of odd behavior and poorly documented gems. This could result in some odd behavior. With RadioRA2, we get back that actual levels/state and update that before dispatching an event. On HomeWorks QS, we'll report a level that may not be accurate/correct. For example, if we try to set a motor to 50%, HomeWorks QS will just refuse if it's not supported by the motor, but we'd just silently report to the user that we changed the level successfully. Querying the controller right away won't make things better either, as a device could be mid-state-transition. There are 2 paths I could see going down:
I'm somewhat inclined to attempt number 2. |
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.
Problem
HomeWorks QS processors (QNET protocol) do not echo back
~OUTPUTstate changes on the same telnet connection that sent the#OUTPUTcommand. This means theLEVEL_CHANGEDevent was never dispatched afterset_level(), causing Home Assistant to revert the UI toggle state.Observed behaviour: Toggle a light on → light turns on → UI reverts to off. Toggle again → sends off command but light was already on, so nothing visible happens.
Root Cause
GNET controllers (original HomeWorks) echo the state change as a monitoring event (
~OUTPUT,id,1,level), which triggershandle_update()→_dispatch_event(). On QNET,handle_update()is never called for self-initiated changes because no echo is sent on the same connection.Fix
Dispatch
Output.Event.LEVEL_CHANGEDimmediately after updatingself._levelinset_level(). This is safe for both GNET and QNET:handle_update(), dispatching a second event with the same level. This is harmless as consumers (like HA) are idempotent for same-value updates.Testing
Tested on Lutron HomeWorks QS Gulliver processors (firmware 15.10.0) — 558 entities (lights, switches, shades, occupancy sensors). Light toggles now correctly reflect state in Home Assistant.
Related: PR #122 added QNET prompt support. This PR completes QNET compatibility for state management.