各位大佬,我写了一段自动化代码,30分钟内循环5次,但是自定义的变量不更新是啥情况?
alias: 关灯前提前5分钟提醒,并增大音量
description: 关灯前30分钟提醒,每5分钟提醒一次,提醒时加大音量,提醒完成音量恢复!
trigger:
- platform: time
at: "20:30:00"
condition: []
action:
- variables:
original_volume: "{{ state_attr('media_player.ke_ting', 'volume_level') }}"
countdown: 30
enabled: true
- service: media_player.volume_set
data:
volume_level: 0.29
target:
entity_id:
- media_player.ke_ting
enabled: false
- repeat:
count: 5
sequence:
- service: tts.edge_tts_say
data:
cache: false
entity_id:
- media_player.ke_ting
message: '还有{{ countdown }}分钟关灯啦,宝贝们抓紧呀!'
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- variables:
countdown: "{{ countdown - 5 }}"
- service: media_player.volume_set
data:
entity_id:
- media_player.ke_ting
volume_level: "{{ original_volume }}"
enabled: false
mode: single
就是这一句没什么作用
countdown: "{{ countdown - 5 }}"
请各位路过的大佬不吝赐教。谢谢 |