Skip to content

Home Assistant

Add a rest_command to Home Assistant once, and any automation can send a notification: quiet for everyday events, Critical for a water leak or a smoke alarm.

This uses an API Source.

  1. In the Pocketbell app, create a Source named Home Assistant, choose API, and copy its key.

  2. Add the key to secrets.yaml, with Bearer in front of it:

    pocketbell_auth: "Bearer pb_live_…"
  3. Add this to configuration.yaml:

    rest_command:
    pocketbell:
    url: "https://api.pocketbell.dev/v1/messages"
    method: post
    headers:
    authorization: !secret pocketbell_auth
    content_type: "application/json"
    timeout: 15
    payload: >-
    {"title": {{ title | default('Home Assistant') | tojson }},
    "message": {{ message | tojson }},
    "priority": {{ priority | default('normal') | tojson }},
    "tags": {{ tags | default(['home-assistant']) | tojson }}
    {%- if replace is defined %}, "replace": {{ replace | tojson }}{% endif %}}
  4. Restart Home Assistant. After that, a change to the command can be reloaded from Developer tools → YAML without a restart.

A leak sensor that sends a Critical notification, repeating until you acknowledge it:

alias: Water leak
triggers:
- trigger: state
entity_id: binary_sensor.kitchen_leak
to: "on"
actions:
- action: rest_command.pocketbell
data:
title: Water leak
message: "{{ trigger.to_state.name }} is wet"
priority: critical
replace: kitchen-leak

A door left open, as Time Sensitive:

alias: Front door left open
triggers:
- trigger: state
entity_id: binary_sensor.front_door
to: "on"
for: "00:10:00"
actions:
- action: rest_command.pocketbell
data:
message: The front door has been open for 10 minutes.
priority: important

In the automation editor, choose Add action → RESTful Command: pocketbell and fill in the same fields.

  • priority is one of silent, quiet, normal, important and critical. Leave it out for normal.
  • replace names the event. Send a second automation with the same key when the leak sensor dries, such as message: Dry again and priority: normal, and it takes the alert’s place and stops the repeats.
  • | tojson turns each value into a JSON string, so a sensor name with quotes in it still makes a valid request.

Home Assistant logs a failed request as a warning, but the automation carries on. To see Pocketbell’s answer, add response_variable: pb to the action, and look at pb.status and pb.content in the automation’s trace:

  • 401 invalid_api_key: the key or its Bearer is missing from secrets.yaml.
  • 400 invalid_request: details in the content names the field.