某些卡片支持点击动作。这些动作定义了当您点击或按住卡片中的对象时会发生什么。
以下卡片支持启用动作:
点击动作
当点击卡片上的对象时执行的动作。
tap_action:
action: toggle
Configuration Variables
tap_action map (Optional)
执行的动作(more-info
、toggle
、perform-action
、navigate
、url
、assist
、none
)
Default:
toggle
(如果提供的实体无法切换,某些卡片会将默认值覆盖为more-info
)
navigation_path string (Optional, default: none)
当action
定义为navigate
时导航到的路径(例如,/lovelace/0/
)
navigation_replace boolean (Optional, default: none)
当action
定义为navigate
时,是否用新URL替换历史记录中的当前页面
url_path string (Optional, default: none)
当action
定义为url
时导航到的路径(例如,https://www.home-assistant.io
)
perform_action string (Optional, default: none)
当action
定义为perform-action
时执行的动作(例如,media_player.media_play_pause
)
data string (Optional, default: none)
当action
定义为perform-action
时包含的动作数据(例如,brightness: 100
)
target string (Optional, default: none)
当action
定义为perform-action
时使用的动作目标(例如,entity_id: media_player.bedroom
)
confirmation boolean | map (Optional, default: false)
显示确认对话框以确认动作。请参阅下面的confirmation
对象
pipeline_id string (Optional, default: last_used
)
当action
定义为assist
时使用的助理管道。可以是last_used
、preferred
或管道ID。
start_listening boolean (Optional, default: none)
如果支持,在打开助理对话框并将action
定义为assist
时监听语音命令
entity string (Optional, default: none)
当action
定义为more-info
时覆盖默认显示的实体
按住动作
当点击卡片上的对象,按住至少半秒钟然后释放时执行的动作。动作只会触发一次,而不是在按住期间连续触发。
hold_action:
action: toggle
Configuration Variables
hold_action map (Optional)
action string Required, default: more-info
执行的动作(more-info
、toggle
、perform-action
、navigate
、url
、assist
、none
)
navigation_path string (Optional, default: none)
当action
定义为navigate
时导航到的路径(例如,/lovelace/0/
)
navigation_replace boolean (Optional, default: none)
当action
定义为navigate
时,是否用新URL替换历史记录中的当前页面
url_path string (Optional, default: none)
当action
定义为url
时导航到的路径(例如,https://www.home-assistant.io
)
perform_action string (Optional, default: none)
当action
定义为perform-action
时执行的动作(例如,media_player.media_play_pause
)
data string (Optional, default: none)
当action
定义为perform-action
时包含的动作数据(例如,brightness: 100
)
target string (Optional, default: none)
当action
定义为perform-action
时使用的动作目标(例如,entity_id: media_player.bedroom
)
confirmation boolean | map (Optional, default: false)
显示确认对话框以确认动作。请参阅下面的confirmation
对象
pipeline_id string (Optional, default: none)
当action
定义为assist
时使用的助理管道ID
start_listening boolean (Optional, default: none)
如果支持,在打开助理对话框并将action
定义为assist
时监听语音命令
entity string (Optional, default: none)
当action
定义为more-info
时覆盖默认显示的实体
双击动作
当双击卡片上的对象时执行的动作。
double_tap_action:
action: toggle
Configuration Variables
double_tap_action map (Optional)
action string Required, default: more-info
执行的动作(more-info
、toggle
、perform-action
、navigate
、url
、assist
、none
)
navigation_path string (Optional, default: none)
当action
定义为navigate
时导航到的路径(例如,/lovelace/0/
)
navigation_replace boolean (Optional, default: none)
当action
定义为navigate
时,是否用新URL替换历史记录中的当前页面
url_path string (Optional, default: none)
当action
定义为url
时导航到的路径(例如,https://www.home-assistant.io
)
perform_action string (Optional, default: none)
当action
定义为perform-action
时执行的动作(例如,media_player.media_play_pause
)
data string (Optional, default: none)
当action
定义为perform-action
时包含的动作数据(例如,brightness: 100
)
target string (Optional, default: none)
当action
定义为perform-action
时使用的动作目标(例如,entity_id: media_player.bedroom
)
confirmation boolean | map (Optional, default: false)
显示确认对话框以确认动作。请参阅下面的confirmation
对象
pipeline_id string (Optional, default: none)
当action
定义为assist
时使用的助理管道ID
start_listening boolean (Optional, default: none)
如果支持,在打开助理对话框并将action
定义为assist
时监听语音命令
entity string (Optional, default: none)
当action
定义为more-info
时覆盖默认显示的实体
确认选项
如果将确认定义为对象而不是布尔值,您可以添加更多自定义和配置。
double_tap_action:
action: perform-action
confirmation:
text: 您确定要重启吗?
perform_action: script.restart
hold_action:
action: perform-action
confirmation: true
perform_action: script.do_other_thing
Configuration Variables
exemptions list (Optional)
免除选项
double_tap_action:
action: perform-action
confirmation:
text: 您确定要重启吗?
exemptions:
- user: x9405b8c64ee49bb88c42000e0a9dfa8
- user: 88bcfbdc39155d16c3b2d09cbf8b0367
perform_action: script.restart
示例
在实体按钮卡片上实现点击动作:
type: button
tap_action:
action: toggle
hold_action:
action: more-info
限制
无法为动作使用模板。但调用脚本是一个不错的替代方案。
帮助我们改进翻译
建议编辑此页面,或提供/查看此页面的反馈。