Fix: return list from translate_event_code to dispatch all matching listeners - #561
Merged
rroller merged 1 commit intoMar 23, 2026
Conversation
…teners Fixes rroller#560. The previous implementation (rroller#557) returned a single event code, which meant CrossLineDetection was silently dropped when a SmartMotion* listener also existed. This change makes translate_event_code() return a list of codes so both the original CrossLine/CrossRegion sensor AND the SmartMotion* sensor fire on the same raw event. Three touch points: 1. translate_event_code() → returns list[str] instead of str 2. on_receive_vto_event() → iterates over the list 3. on_receive() → iterates over the list Behavior matrix: | Config | CrossLine + Human | Result | |----------------------------|-------------------|-------------------------------------| | Only CrossLine subscribed | ✓ | [CrossLineDetection] | | Only SmartMotion subscribed| ✓ | [SmartMotionHuman] | | Both subscribed | ✓ | [CrossLineDetection, SmartMotionHuman] | | Neither subscribed | ✓ | [SmartMotionHuman] (fallback) |
rroller
approved these changes
Mar 23, 2026
Owner
|
Thanks! |
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
Fixes #560 — regression from #557 where
CrossLineDetectionsensors stopped firing whenSmartMotionHuman/SmartMotionVehiclelisteners also existed.Root cause:
translate_event_code()returned a single event code string. When both a CrossLine and a SmartMotion listener were registered, the CrossLine event was exclusively translated to SmartMotion — the originalCrossLineDetectionsensor never fired.Fix:
translate_event_code()now returns alist[str]of event codes, and both callers (on_receive_vto_event,on_receive) iterate over the list to dispatch all matching listeners.Behavior matrix
[CrossLineDetection][SmartMotionHuman][CrossLineDetection, SmartMotionHuman][SmartMotionHuman]fallbackChanges (3 touch points in
__init__.py)translate_event_code()— returnslist[str]instead ofstr. Builds a list: always includes original CrossLine/CrossRegion if its listener exists, then appends SmartMotion* if that listener also exists.on_receive_vto_event()—codes = ...+for code in codes:loop around the existing handler body.on_receive()—event_names = ...+for event_name in event_names:loop around the existing handler body.Test plan
binary_sensor.*_crosslinedetectionandbinary_sensor.*_smart_motion_humanfire on the same event["DoorbellPressed"])