| 1 |
# Home Assistant |
| 2 |
|
| 3 |
## Overview |
| 4 |
|
| 5 |
This example demonstrates how to configure the Shoutrrr `generic` service to send notifications to Home Assistant via its webhook API. |
| 6 |
|
| 7 |
## Usage |
| 8 |
|
| 9 |
Configure the `generic` service URL to target Home Assistant's webhook endpoint. The URL requires the Home Assistant IP address, port, and webhook ID. |
| 10 |
|
| 11 |
=== "HTTPS (Default)" |
| 12 |
|
| 13 |
```url title="Generic Service URL for HTTPS" |
| 14 |
generic://<HA_IP_ADDRESS>:<HA_PORT>/api/webhook/<WEBHOOK_ID>?template=json |
| 15 |
``` |
| 16 |
|
| 17 |
=== "HTTP" |
| 18 |
|
| 19 |
```url title="Generic Service URL for HTTP" |
| 20 |
generic://<HA_IP_ADDRESS>:<HA_PORT>/api/webhook/<WEBHOOK_ID>?template=json&disabletls=yes |
| 21 |
``` |
| 22 |
|
| 23 |
!!! Note |
| 24 |
Replace `<HA_IP_ADDRESS>`, `<HA_PORT>`, and `<WEBHOOK_ID>` with your Home Assistant instance details. In Home Assistant, use `{{ trigger.json.message }}` to extract the message from the JSON payload sent by Shoutrrr. |
| 25 |
|
| 26 |
## Example |
| 27 |
|
| 28 |
<!-- markdownlint-disable --> |
| 29 |
### Send Notification to Home Assistant |
| 30 |
|
| 31 |
!!! Example |
| 32 |
```bash title="Send Command to Home Assistant" |
| 33 |
shoutrrr send --url "generic://192.168.1.100:8123/api/webhook/abc123?template=json" --message "Hello, Home Assistant!" |
| 34 |
``` |
| 35 |
|
| 36 |
```text title="Expected Output" |
| 37 |
Notification sent |
| 38 |
``` |
| 39 |
|
| 40 |
### Send Notification with HTTP and Verbose Output |
| 41 |
|
| 42 |
!!! Example |
| 43 |
```bash title="Send Command with HTTP and Verbose" |
| 44 |
shoutrrr send --url "generic://192.168.1.100:8123/api/webhook/abc123?template=json&disabletls=yes" --message "Hello, Home Assistant!" --verbose |
| 45 |
``` |
| 46 |
|
| 47 |
```text title="Expected Output" |
| 48 |
URLs: generic://192.168.1.100:8123/api/webhook/abc123?template=json&disabletls=yes |
| 49 |
Message: Hello, Home Assistant! |
| 50 |
Notification sent |
| 51 |
``` |
| 52 |
<!-- markdownlint-restore --> |
| 53 |
|
| 54 |
## Notes |
| 55 |
|
| 56 |
- **Webhook Setup**: Create a webhook in Home Assistant to obtain the `WEBHOOK_ID`. |
| 57 |
- **Template**: The `template=json` query parameter ensures the message is sent as a JSON payload. |
| 58 |
- **Accessing Message**: Use `{{ trigger.json.message }}` in Home Assistant automations to retrieve the message. |
| 59 |
- **Credit**: Example inspired by [@JeffCrum1](https://github.com/JeffCrum1), [Issue #325](https://github.com/containrrr/shoutrrr/issues/325#issuecomment-1460105065). |