- id: '1570846860035'
alias: 人不在家开始清扫
trigger:
- entity_id: group.people,device_tracker.me
from: home
platform: state
to: not_home
condition:
- condition: template
value_template: "{% if (( as_timestamp(now()) - as_timestamp(strptime(state_attr('vacuum.sao_di_ji_qi_ren','clean_stop')|string, '%d.%m.%Y')) ) / 86400 ) | round(2) <= 1 -%} {% if ((as_timestamp(strptime(state_attr('vacuum.sao_di_ji_qi_ren','clean_stop')|string, '%d.%m.%Y')) - as_timestamp(strptime(state_attr('vacuum.sao_di_ji_qi_ren','clean_start')|string, '%d.%m.%Y'))) / 3600 | round(2) < 30) -%}true{%- else -%}false{%- endif %}{%- else -%}true{%- endif %}"
action:
- data:
entity_id: vacuum.sao_di_ji_qi_ren
service: vacuum.start
加了几个限制条件,1.当天已清扫过就不再清扫;2.如果当天清扫未达三十分钟依旧清扫。
此方法有一种情况无法解决:如果当天清扫过后,又手动开启清扫,然后30分钟内关闭清扫,依旧会触发该自动化。 但介于这种情况我很少出现,故不在乎。
|