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.
Set it up
Section titled “Set it up”-
In the Pocketbell app, create a Source named Home Assistant, choose API, and copy its key.
-
Add the key to
secrets.yaml, withBearerin front of it:pocketbell_auth: "Bearer pb_live_…" -
Add this to
configuration.yaml:rest_command:pocketbell:url: "https://api.pocketbell.dev/v1/messages"method: postheaders:authorization: !secret pocketbell_authcontent_type: "application/json"timeout: 15payload: >-{"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 %}} -
Restart Home Assistant. After that, a change to the command can be reloaded from Developer tools → YAML without a restart.
Use it in an automation
Section titled “Use it in an automation”A leak sensor that sends a Critical notification, repeating until you acknowledge it:
alias: Water leaktriggers: - 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-leakA door left open, as Time Sensitive:
alias: Front door left opentriggers: - 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: importantIn the automation editor, choose Add action → RESTful Command: pocketbell and fill in the same fields.
How it behaves
Section titled “How it behaves”priorityis one ofsilent,quiet,normal,importantandcritical. Leave it out fornormal.replacenames the event. Send a second automation with the same key when the leak sensor dries, such asmessage: Dry againandpriority: normal, and it takes the alert’s place and stops the repeats.| tojsonturns each value into a JSON string, so a sensor name with quotes in it still makes a valid request.
If nothing arrives
Section titled “If nothing arrives”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 itsBeareris missing fromsecrets.yaml. - 400
invalid_request:detailsin the content names the field.