Add call_ws() method for arbitrary WebSocket messages#2563
Open
rsr5 wants to merge 1 commit intoAppDaemon:devfrom
Open
Add call_ws() method for arbitrary WebSocket messages#2563rsr5 wants to merge 1 commit intoAppDaemon:devfrom
rsr5 wants to merge 1 commit intoAppDaemon:devfrom
Conversation
- Add call_ws() method to Hass class for sending arbitrary WebSocket messages to Home Assistant - Add documentation section in HASS_API_REFERENCE.rst with usage examples - Add unit tests for validation, success responses, error handling, and namespace resolution
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.
Add call_ws() method for arbitrary WebSocket messages
Summary
Adds a
call_ws()method to the Hass API that allows apps to send arbitrary WebSocket messages to Home Assistant. This provides a generic escape hatch for accessing any Home Assistant WebSocket API command (including those that are not service calls and therefore not reachable viacall_service()).Motivation
Home Assistant exposes many useful WebSocket message types that aren't service calls, such as:
frontend/get_user_data/frontend/set_user_data: per-user server-side storagerecorder/statistics_during_period: long-term statistics queriesconfig/area_registry/list: registry listingsCurrently there is no way to reach these from an AppDaemon app without dropping down to the plugin internals.
call_ws()fills that gap with a single, general-purpose method.Usage
Design decisions
**message): mirrors the existingwebsocket_send_json()internal interface and feels natural in Python.success,result,error,ad_status,ad_duration): consistent with howcall_service()returns results.idis managed automatically by the plugin layer and is rejected if passed by the caller.namespaceparameter following the same pattern ascall_service()and other Hass API methods.@utils.sync_decorator.