alias: 测试消息推送
description: ""
trigger:
- platform: event
event_type: test
condition: []
action:
- alias: 设置actionId
variables:
action_open: "{{ 'OPEN_' ~ context.id }}"
action_close: "{{ 'CLOSE_' ~ context.id }}"
- alias: 发送推送消息
service: notify.mobile_XXX
data:
message: 检测到你已到小区并且气温过低,需要开启电暖器吗吗?
data:
actions:
- action: "{{ action_open }}"
title: 开启
- action: "{{ action_close }}"
title: 关闭
- alias: 等待消息按钮点击
wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_open }}"
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_close }}"
continue_on_timeout: true
- alias: 处理点击后的操作
choose:
- conditions: "{{ wait.trigger.event.data.action == action_open }}"
sequence:
- service: notify.mobile_app_XXX
data:
message: 电暖器已开启
- conditions: "{{ wait.trigger.event.data.action == action_close }}"
sequence:
- service: notify.mobile_app_XXX
data:
message: 你选择了关闭
mode: single