You can use Ariela in combination with Home Assistant in order to receive notifications directly on your Android device. What can you do more is using those notifications to send custom commands back to the server. One cool example: receive notification that someone opened your front door, and using the notification you can start the home protection mode (blinking lights, siren etc).
1. Setup
- Install Ariela (if not already done that)
- Have Home Assistant version at least 0.92 or later and mobile_app component enabled
2. Usage
2.1 Sending the notification
The android actionable notifications are set up the same as the html5 notifications. The following parameters can be sent:
title message data: url actions color message_type tag dismiss image icon force_image stream_source
Parameter | Required | Description |
---|---|---|
message | Required | Body of the notification |
title | Optional | Title for the notification, default value: Home Assistant |
data | Optional | Extra parameters for the notification |
Parameters for the data section of the notification. Everything here is optional.
Parameter | Description |
---|---|
color | A hex color such as #FF0000, default value is a blue |
message_type | ‘notification’ or ‘data’, defaults to ‘data’. This is the type of FCM that is sent. Notification has higher priority, but can’t include actions or be dismissed by Home Assistant. |
tag | Must be an integer. Tag is the ‘id’ of the notifications. Sending a new notification to the same tag will overwrite the current notification instead of creating a separate one. |
dismiss | true or false, requires a tag parameter. If true, the notification will be dismissed. |
actions | Array of objects (up to 3) with an ‘action’ and ‘title’. The title will be the button text on the notification, the action is what is sent back in the callback |
image | A URL of an image to send. The image overwrites the BigTextStyle so longer texts will be truncated. The image will also be smaller if actions are included |
icon | A URL of an icon to use for the notification. Only on >= SDK 26. Careful to choose icon with transparent background to follow Android guidelines. |
url | An URL that you want to be opened with the implicit browser when clicking the notification (added in version 1.3.3.7) |
force_image | boolean, default false. Put this to true to force images to be downloaded. Useful when you are putting an image url that its from your HA server (added in version 1.3.4.2) |
stream_source | A camera entity id (eg: camera.ffmpeg) or http / https video file url to stream. Note that this option is ignored if url option is set. Added in version 1.3.4.9 |
In order to send a “regular” notification without actions, all you have to do is not include them in the call to the service, such as below.
- service: notify.mobile_app_galaxy_s8 data: message: Anne has arrived home
This will send a simple push notification without any action buttons.
If you want to include some actions, something like this will work:
- service: notify.mobile_app_galaxy_s8 data: message: Anne has arrived home data: actions: - action: open title: Open Home Assistant - action: open_door title: Open door
This will have two buttons, one that says “Open Door” and one that says “Open Home Assistant”. The action for each button (“open” or “open_door” in this example) will be returned in the callback.
Example sending push notification and when clicking on the notification, camera.ffmpeg will be streaming on the phone.
Example streaming a video file when pressing notification:
{ "message": "video streaming", "title":"test", "data": { "stream_source":"http://surodev.com/ariela/ariela-camera-streaming.mp4" } }
2.2 Handling the callback
The callback is pushed to the event bus. It can be accessed via ariela_notification_clicked. The “action” of the button that was pressed is included in the event_data. So an automation would looks something like:
- alias: TEST RESPONSE trigger: - event_data: action: open_door event_type: ariela_notification_clicked platform: event condition: [] action: - data: entity_id: light.front_door service: light.turn_on