alias: 操作消息 - 快到家开空调
description: ""
trigger:
- platform: zone
entity_id: device_tracker.iphone15_lu_icloud
zone: zone.home
event: enter
condition:
- condition: numeric_state
entity_id: sensor.living_room_climate_indoor_temperature
above: 29
- condition: state
entity_id: device_tracker.iphone15_lu_icloud
state: not_home
for:
minutes: 30
action:
- variables:
action_climate_living: "{{ 'climate_living_' ~ context.id }}"
action_nothing: "{{ 'nothing_' ~ context.id }}"
- service: notify.mobile_app_zhong_hao_ban_zhuan
data:
message: 快到家了
title: 家里温度超过30℃,要提前把空调打开吗?
data:
actions:
- action: "{{ action_climate_living }}"
title: 打开客厅空调
- action: "{{ action_nothing }}"
title: 不用了
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_climate_living }}"
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_nothing }}"
- choose:
- conditions:
- condition: template
value_template: "{{ wait.trigger.event.data.action == action_nothing }}"
sequence: []
- conditions:
- condition: template
value_template: "{{ wait.trigger.event.data.action == action_climate_living }}"
sequence:
- service: climate.turn_on
metadata: {}
data: {}
target:
entity_id: climate.living_room_climate_climate
- service: climate.set_hvac_mode
metadata: {}
data:
hvac_mode: fan_only
target:
entity_id: climate.living_room_climate_climate
mode: single
initial_state: true
修改了一下,只需要一条自动化就可以执行
|