用ES3试了一下这样可行
alias: 人在传感器测试
description: ""
triggers:
- type: occupied
device_id: 62bb15da9e271ce0aa24018f62c955df
entity_id: 52ae142a3c7282ecdec83f7f77a7dc81
domain: binary_sensor
trigger: device
conditions:
- condition: template
value_template: >-
{{ trigger.from_state is not none and trigger.from_state['state'] ==
'off' and int(as_timestamp(now()) -
as_timestamp(trigger.from_state.last_updated)) > 30*60 }}
actions:
- action: notify.persistent_notification
metadata: {}
data:
message: >-
传感器变为有人状态
当前时间:{{ as_timestamp(now()) | timestamp_custom('%H:%M:%S') }}
上次的无人状态时间:{{ as_timestamp(trigger.from_state.last_updated) |
timestamp_custom ('%H:%M:%S') }}
上次的无人状态持续时间:{{ (as_timestamp(now()) -
as_timestamp(trigger.from_state.last_updated)) |
timestamp_custom('%H:%M:%S',False) }}
title: 测试
mode: single
|