Skip to content

Forward requested event type in Home Assistant event subscriptions - #1471

Merged
helto4real merged 3 commits into
mainfrom
copilot/fix-subscribe-to-home-assistant-events
Oct 3, 2026
Merged

helto4real merged 3 commits into
mainfrom
copilot/fix-subscribe-to-home-assistant-events

Conversation

Copilot AI commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

SubscribeToHomeAssistantEventsAsync(eventType, ...) was constructing subscribe_events commands without event_type, causing every non-cached subscription to become an all-events subscription. For non-admin tokens this can fail as unauthorized; for admin tokens it silently over-subscribes.

  • Behavior change

    • HomeAssistantConnection.SubscribeToHomeAssistantEventsInternalAsync now forwards the requested eventType onto SubscribeEventCommand.EventType.
    • This preserves the existing optimized cached path for null/empty event types and only changes the specific-event subscription path.
  • Regression coverage

    • Added a focused HassClient unit test that verifies subscribing to "state_changed" sends a SubscribeEventCommand with EventType == "state_changed".
  • Result

    • Specific event subscriptions now produce the expected websocket payload instead of omitting event_type.
await connection.SubscribeToHomeAssistantEventsAsync("state_changed", cancellationToken);

// now sends:
new SubscribeEventCommand
{
    EventType = "state_changed"
};

Co-authored-by: FrankBakkerNl <13922018+FrankBakkerNl@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix SubscribeToHomeAssistantEventsAsync to send requested event type Forward requested event type in Home Assistant event subscriptions Sep 25, 2026
Copilot AI requested a review from FrankBakkerNl September 25, 2026 12:57
@helto4real

Copy link
Copy Markdown
Collaborator

I think this look pretty good but will do a proper reivew when it is out of draft

@FrankBakkerNl
FrankBakkerNl marked this pull request as ready for review September 30, 2026 13:02
@FrankBakkerNl

Copy link
Copy Markdown
Contributor

Fix is solid. This was clearly forgotten as the argument is never used. Our own code never passes a value other than null here (except for some tests) so it would not break.

@codecov

codecov Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83%. Comparing base (250a6f8) to head (5bade2b).

Additional details and impacted files
@@         Coverage Diff          @@
##           main   #1471   +/-   ##
====================================
  Coverage    83%     83%           
====================================
  Files       201     201           
  Lines      4173    4176    +3     
  Branches    477     477           
====================================
+ Hits       3480    3483    +3     
  Misses      496     496           
  Partials    197     197           
Flag Coverage Δ
unittests 83% <100%> (+<1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@helto4real
helto4real enabled auto-merge (squash) October 3, 2026 14:48
@helto4real
helto4real merged commit 7fe0582 into main Oct 3, 2026
7 checks passed
@helto4real
helto4real deleted the copilot/fix-subscribe-to-home-assistant-events branch October 3, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SubscribeToHomeAssistantEventsAsync never sends the requested event_type

3 participants