本帖最后由 dscao 于 2023-10-16 09:53 编辑
如果 sensor.roborock_s5_last_clean_end 值的格式为: 2023-10-16 9:48:03
可以这样试一下:
alias: 离家模式启动扫地机
description: ""
trigger:
- platform: state
entity_id:
- sensor.0x54ef4410007afb46_lock_event
to: Away-from-home mode is enabled
condition:
- condition: template
value_template: >-
{{((as_timestamp(now()) - as_timestamp(strptime(states('sensor.roborock_s5_last_clean_end'),
'%Y-%m-%d %H:%M:%S', ''))) / 3600)>20 }}
action:
- device_id: 3e7dab7fd79dbaa0cad70d019092b10a
domain: vacuum
entity_id: vacuum.roborock_s5
type: clean
mode: single
|