本帖最后由 jk_1 于 2024-2-21 17:53 编辑
1. 触发条件:设备开启
2. 环境条件:跟上次关闭时间小于1小时(该条件不知道怎么写 胡乱试过下面写法也不对: {{ now() - states('media_player.sony_xr_75x90j').off.as_timestamp() < 3600 }})
3. 执行:关闭设备
trigger:
- platform: device
type: turned_on
device_id: 3c90eeec950ca2125d5cade55b543eb0
entity_id: e9f8f574eda028193e5cbb720a6b4119
domain: remote
for:
hours: 0
minutes: 0
seconds: 6
condition:
- condition: and
conditions:
- condition: time
after: "08:00:00"
before: "17:00:00"
- condition: template
value_template: " {{ now() - states('media_player.sony_xr_75x90j').off.as_timestamp() < 3600 }}"
action:
- type: turn_off
device_id: 3c90eeec950ca2125d5cade55b543eb0
entity_id: e9f8f574eda028193e5cbb720a6b4119
domain: remote
求助!
贴一下最后的。感谢 Roger 及 cjnt007
alias: sony_lastoff
description: ""
trigger:
- platform: device
device_id: 3c90eeec950ca2125d5cade55b543eb0
domain: media_player
entity_id: de4edf74613e55cd80e9a8fdc88b182e
type: turned_off
condition: []
action: []
trigger:
- platform: device
type: turned_on
device_id: 3c90eeec950ca2125d5cade55b543eb0
entity_id: e9f8f574eda028193e5cbb720a6b4119
domain: remote
for:
hours: 0
minutes: 0
seconds: 6
condition:
- condition: time
after: "08:00:00"
before: "17:00:00"
- condition: template
value_template: >-
{{
(as_timestamp(now())-as_timestamp(states.automation.sony_lastoff.last_updated))
< 1800 }}
action:
- type: turn_off
device_id: 3c90eeec950ca2125d5cade55b543eb0
entity_id: e9f8f574eda028193e5cbb720a6b4119
domain: remote
- delay:
hours: 0
minutes: 0
seconds: 2
milliseconds: 0
- service: xiaomi_miot.intelligent_speaker
data:
entity_id: media_player.xiaomi_l05c_2c30_play_control
text: 请让电视机休息一会吧
execute: false
|