Skip to content

Instantly share code, notes, and snippets.

@hi94740
Created May 7, 2026 08:49
Show Gist options
  • Select an option

  • Save hi94740/9d4e8a98b03e05038113359cf8f0451e to your computer and use it in GitHub Desktop.

Select an option

Save hi94740/9d4e8a98b03e05038113359cf8f0451e to your computer and use it in GitHub Desktop.
Home Assistant 实体状态变化通知蓝图
blueprint:
name: 实体状态变化通知
description: 当实体状态变化时给移动App发送通知。
domain: automation
input:
watched_entities:
name: 监控的实体
description: 选择您想要监控的实体。
selector:
entity:
multiple: true
reorder: true
included_states:
name: 状态白名单
description: 添加要包括的状态。留空则包括所有状态,并可用下面的黑名单过滤。
default: []
selector:
text:
multiple: true
excluded_states:
name: 状态黑名单
description: 添加要过滤的状态(例如:unknown, unavailable, off)。如果上面设置了白名单则不生效。
default: ["unknown", "unavailable"]
selector:
text:
multiple: true
interruption_level:
name: 优先级
description: 通知的优先级,[请参考](https://companion.home-assistant.io/docs/notifications/notifications-basic#interruption-level)。
default: active
selector:
select:
options:
- label: 静默
value: passive
- label: 普通
value: active
- label: 即时通知
value: time-sensitive
- label: ‼️ 重要
value: critical
notify_devices:
name: 通知设备
description: 选择接收通知的移动设备。
selector:
device:
integration: mobile_app
multiple: true
variables:
included_states: !input included_states
excluded_states: !input excluded_states
interruption_level: !input interruption_level
notify_devices: !input notify_devices
trigger:
- platform: state
entity_id: !input watched_entities
to: ~
condition:
- condition: template
value_template: "{{ (included_states and states(trigger.entity_id) in included_states) or states(trigger.entity_id) not in excluded_states }}"
action:
- repeat:
for_each: "{{ notify_devices }}"
sequence:
- service: notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}
data:
title: "{{ state_attr(trigger.entity_id, 'friendly_name') or state_attr(trigger.entity_id, 'name') or trigger.entity_id }}"
message: "{{ state_translated(trigger.entity_id) }}"
data:
url: "/config/devices/device/{{ device_id(trigger.entity_id) }}"
image: "{{ state_attr(trigger.entity_id, 'entity_picture') }}"
push:
interruption-level: "{{ interruption_level }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment