Skip to content

Instantly share code, notes, and snippets.

@artistro08
Last active September 8, 2026 20:34
Show Gist options
  • Select an option

  • Save artistro08/e616ab630dc08f10ebcabeb32c065565 to your computer and use it in GitHub Desktop.

Select an option

Save artistro08/e616ab630dc08f10ebcabeb32c065565 to your computer and use it in GitHub Desktop.
Home assistant webhook from n8n
blueprint:
name: Phone Do Not Disturb via Webhook
description: >
Sets Do Not Disturb on an Android phone running the Home Assistant
companion app, driven by an external webhook (n8n, etc.).
POST a JSON body of {"dnd": "on"} or {"dnd": "off"} — an empty body is
treated as "on".
Android only: iOS has no DND notification command. The first command sent
opens a prompt on the phone to grant Home Assistant access to the
Notification Policy; DND won't change until that is granted. On Android 15+
the app can only turn DND back off if the app is what turned it on.
domain: automation
input:
phone:
name: Phone
description: The device running the companion app.
selector:
device:
filter:
- integration: mobile_app
webhook_id:
name: Webhook ID
description: The endpoint becomes /api/webhook/<this value>. Treat it as a secret.
default: phone_dnd
selector:
text:
dnd_mode:
name: DND mode
description: Interruption filter applied when turning DND on.
default: priority_only
selector:
select:
options:
- alarms_only
- priority_only
- total_silence
local_only:
name: Local network only
description: Leave on if the caller (n8n add-on) reaches HA over the local network.
default: true
selector:
boolean:
mode: queued
max: 10
variables:
phone: !input phone
dnd_mode: !input dnd_mode
notify_service: "notify.mobile_app_{{ device_attr(phone, 'name') | slugify }}"
trigger:
- platform: webhook
webhook_id: !input webhook_id
allowed_methods:
- POST
local_only: !input local_only
action:
- variables:
desired: "{{ (trigger.json | default({}, true)).get('dnd', 'on') | string | lower }}"
- choose:
- conditions:
- condition: template
value_template: "{{ desired in ['on', 'true', '1', 'start', 'enable'] }}"
sequence:
- service: "{{ notify_service }}"
data:
message: command_dnd
data:
command: "{{ dnd_mode }}"
default:
- service: "{{ notify_service }}"
data:
message: command_dnd
data:
command: "off"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment