Skip to content

fix: Home Assistant event filtering closed by default#1169

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-e0e71a89
Mar 13, 2026
Merged

fix: Home Assistant event filtering closed by default#1169
teknium1 merged 1 commit intomainfrom
hermes/hermes-e0e71a89

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Problem

A user reported that every time any Home Assistant event occurs, Hermes notifies them — even for completely unrelated entity changes (CPU temp fluctuating, uptime counters, etc.).

Root Cause

In homeassistant.py _handle_ha_event(), the event filter logic was:

if self._watch_domains or self._watch_entities:
    # filter logic...

When neither watch_domains nor watch_entities was configured (both empty sets), the condition was False and the entire filter block was skipped. Every single state_changed event from HA passed through to the agent, which processed it and sent a persistent notification back.

Fix

Closed by default — events are now dropped unless the user explicitly opts in with one of:

  • watch_domains: list of HA domains to monitor (e.g. climate, light, binary_sensor)
  • watch_entities: list of specific entity IDs to monitor
  • watch_all: true (new option) — explicit opt-in to receive ALL events

A warning is logged at connect time if no filters are configured, guiding users to set up their config.

Changes

  • gateway/platforms/homeassistant.py: Added watch_all config option, added elif not self._watch_all: return guard, added connect-time warning log
  • tests/gateway/test_homeassistant.py: Updated tests to reflect new default behavior, added test_no_filters_blocks_everything, test_watch_all_passes_everything, test_watch_all_parsed

Test Results

All 49 gateway HA tests + 52 HA tool tests pass.

Previously, when no watch_domains or watch_entities were configured,
ALL state_changed events passed through to the agent, causing users
to be flooded with notifications for every HA entity change.

Now events are dropped by default unless the user explicitly configures:
- watch_domains: list of domains to monitor (e.g. climate, light)
- watch_entities: list of specific entity IDs to monitor
- watch_all: true (new option — opt-in to receive all events)

A warning is logged at connect time if no filters are configured,
guiding users to set up their HA platform config.

All 49 gateway HA tests + 52 HA tool tests pass.
@teknium1 teknium1 merged commit 6153139 into main Mar 13, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant