diff --git a/docs/api/server-sent-events.md b/docs/api/server-sent-events.md deleted file mode 100644 index 3fb44233..00000000 --- a/docs/api/server-sent-events.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -title: "Server-sent events" ---- - -The [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events) feature is a one-way channel from your Home Assistant server to a client which is acting as a consumer. For a bi-directional streaming API, check out the [WebSocket API](external_api_websocket.md). - -The URI that is generating the data is `/api/stream`. - -A requirement on the client-side is existing support for the [EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) interface. - -There are various ways to access the stream. If you have not set an `api_password` in the [`http`](https://www.home-assistant.io/components/http/) section of your `configuration.yaml` file then you use your modern browser to read the messages. A command-line option is `curl`: - -```shell -$ curl -X GET -H 'Authorization: Bearer ABCDEFGH' \ - -H "Content-Type: application/json" http://localhost:8123/api/stream -``` - -:::caution -Will no longer work with the new Authentication system. -::: - -You can create a convenient view for this by creating an HTML file (`sse.html`) in the `www` folder of your Home Assistant configuration directory (`.homeassistant`). Paste this snippet into the file: - -```html - - - -

Getting Home Assistant server events

-
- - - -``` - -Visit [http://localhost:8123/local/sse.html](http://localhost:8123/local/sse.html) to see the stream of events. - -## Examples - -A simple way to consume server-sent events is to use a command-line http client like [httpie](https://httpie.org/). Installation info is on the site (if you use Homebrew, it's `brew install httpie`). Once installed, run this snippet from your terminal: - -```shell -$ http --stream http://localhost:8123/api/stream 'Authorization:Bearer ABCDEFGH' content-type:application/json -``` - -### Website - -:::caution -Will no longer work with the new Authentication system. -::: - -The [home-assistant-sse](https://github.com/fabaff/home-assistant-sse) repository contains a more advanced example. - -### Python - -If you want to test the server-sent events without creating a website, the Python module [`sseclient` ](https://pypi.python.org/pypi/sseclient/) can help. To install (assuming Python and pip3 are already installed): - -```shell -$ pip3 install sseclient -``` - -A simple script to consume SSE in Python looks like this: - -```python -from sseclient import SSEClient - -auth = {"Authorization": "Bearer ABCDEFGH"} -messages = SSEClient("http://localhost:8123/api/stream", headers=auth) - -for msg in messages: - print(msg) -``` diff --git a/docusaurus.config.js b/docusaurus.config.js index 7e517bde..c481829f 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -52,7 +52,6 @@ module.exports = { items: [ { label: "REST-API", to: "docs/api/rest" }, { label: "WebSocket API", to: "docs/api/websocket" }, - { label: "Server Sent Events", to: "docs/api/server-sent-events" }, { label: "Native App Integration", to: "docs/api/native-app-integration", diff --git a/sidebars.js b/sidebars.js index e4f5ec89..7a2ac441 100644 --- a/sidebars.js +++ b/sidebars.js @@ -9,7 +9,6 @@ module.exports = { API: [ "api/rest", "api/websocket", - "api/server-sent-events", { type: "category", label: "Native App Integration", diff --git a/static/_redirects b/static/_redirects index f6729124..f1ada06d 100644 --- a/static/_redirects +++ b/static/_redirects @@ -9,7 +9,6 @@ /docs/app_integration_setup /docs/api/native-app-integration/setup /docs/app_integration_webview /docs/api/native-app-integration/webview /docs/external_api_rest /docs/api/rest -/docs/external_api_server_sent_events /docs/api/server-sent-events /docs/external_api_websocket /docs/api/websocket /docs/internationalization_backend_localization /docs/internationalization/core /docs/internationalization_custom_component_localization /docs/internationalization/custom_integration