如果我在开发者工具-服务里面使用模板
service: shell_command.setimportant
data:
Id: >-
{{
state_attr('sensor.jin_3tian_zhong_yao_shi_jian','important1').split(',')[3]
}}
能正常。但是,我在button里面就不能正常,会报错
show_name: true
show_icon: true
type: button
tap_action:
action: call-service
service: shell_command.setimportant
data:
Id: >-
{{
state_attr('sensor.jin_3tian_zhong_yao_shi_jian','important1').split(',')[3]
}}
entity: switch.livingroomlight
2024-06-30 12:14:44.769 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'data' is undefined when rendering '/config/script/setimportant.py '{{data}}{{Id}}''
这是什么原理呢?
|