Skip to content

fix: refresh HASS services once Home Assistant has started - #2680

Open
k2iuh wants to merge 1 commit into
AppDaemon:devfrom
k2iuh:fix/refresh-services-after-ha-start
Open

k2iuh wants to merge 1 commit into
AppDaemon:devfrom
k2iuh:fix/refresh-services-after-ha-start

Conversation

@k2iuh

@k2iuh k2iuh commented Oct 18, 2026

Copy link
Copy Markdown

The Problem

When AppDaemon connects while Home Assistant is still starting, it fetches the service list right away. Services that Home Assistant registers later in its startup, such as weather/get_forecasts, are missing from that list. call_plugin_service uses the list to decide whether to send return_response=True, so apps that call such a service right after startup get it rejected until the next periodic refresh, which runs every services_sleep_time (60 s by default):

WARNING HASS: Error with websocket result: service_validation_error: Validation error: The action requires responses and must be called with return_response=True: request={'type': 'call_service', 'domain': 'weather', 'service': 'get_forecasts', ...}

The Solution

In __post_auth__, after the plugin has waited for Home Assistant to start, it fetches the service list once more. This happens before notify_plugin_started, so apps start with the full list. If Home Assistant is already running when AppDaemon connects, the plugin does not wait, and no extra request is sent.

What to Review

  1. appdaemon/plugins/hass/hassplugin.py: the get_hass_services() call inside the if not self.is_ready: block.
  2. tests/unit/test_hass_startup.py: a new unit test. It calls __post_auth__ on a mock plugin and checks the order of calls in both cases. In the first case, Home Assistant is still starting: wait, then fetch services, then report started. In the second case, Home Assistant is already running: report started, with no extra fetch.
  3. docs/HISTORY.md: a new entry under 4.5.14 Fixes.

Services registered while Home Assistant starts are missing from the
list fetched on connect. Fetch them again after waiting for startup,
before the plugin reports it started.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant