HomeAssistant自定义按钮调用remote.send_command服务报错求助
问题描述
在HomeAssistant中,通过开发者工具调用remote.send_command服务可正常开启客厅空调,配置如下:
service: remote.send_command data: device: Livingroom-aircon command: "On" target: entity_id: remote.broadlink_rm4_pro
但使用custom:button-card配置自定义按钮时,点击出现报错:
Failed to call service remote/send_command. required key not provided @data['command']
使用原生button组件配置相同服务调用则正常工作,需解决custom:button-card的调用问题,以支持自定义图形、信息与动画效果。
解决方案
custom:button-card的服务调用格式与原生button组件存在差异,需将服务参数放入service_data字段中,而非直接使用data字段。正确配置示例如下:
type: custom:button-card name: 开启客厅空调 tap_action: action: call-service service: remote.send_command service_data: device: Livingroom-aircon command: "On" target: entity_id: remote.broadlink_rm4_pro
关键说明
- 原生button组件中直接使用
data传递服务参数,但custom:button-card要求将这些参数放在service_data下 target字段可直接与service、service_data同级放置在tap_action内
内容的提问来源于stack exchange,提问作者Peter Page
相关产品推荐
相关产品推荐

