用途:该技能用于生成和解释 Home Assistant 的服务动作(UI 中称为 actions),即控制设备的主要机制,支持 Python 与 YAML 两种写法,适用于灯光、开关、climate、media_player、cover 等实体。
主要能力:
- Python 服务调用:通过 hass.services.async_call 指定 domain、service、service_data 与 target,blocking=True 可等待完成。
- 目标定位:支持 entity_id(可多个)、area_id、device_id 三种方式。
- 自定义动作注册:在 async_setup(而非 async_setup_entry)中注册;数据级动作面向实体时,vol schema 不应声明 entity_id,由 target 解析。
- 条目级动作:面向连接或账户的动作需接受 config_entry_id,查找条目,缺失或未加载时抛出 ServiceValidationError。
- services.yaml:定义动作元数据供 UI 使用,target 块提供 entity_id,Python schema 不得重复声明。
- 实体级动作:HA 2025.9+ 通过 service.async_register_platform_entity_service 从 async_setup 注册平台实体服务,func 指向实体类方法。
- 常见动作参考:灯光 turn_on(brightness_pct、color_temp_kelvin、transition)、climate set_temperature、media_player play_media(media_content_type 应使用 MediaType 枚举,如 MediaType.MUSIC、MediaType.URL)。
- YAML 自动化:action 列表中使用 action、target、data 结构。
使用方式:在 Claude Code 中调用该技能,按需生成或解释上述代码与配置。
适用场景:开发或维护 Home Assistant 集成、编写自动化、调试服务调用。
限制:资料未提供安装命令、收费信息、平台支持范围及具体版本兼容性细节,暂未提供。