Home Assistant 联动主流语音助手实现智能家居控制
语音控制是智能家居的重要交互方式。本文介绍如何将 Home Assistant 与 Google Assistant、Amazon Alexa 及 Apple Siri 进行集成,实现本地化或云端控制的自动化流程。
为什么选择 Home Assistant?
Home Assistant 不售卖硬件、不锁定生态、数据不强制上云。它是开源的,运行在本地设备(如树莓派或 NAS)上,所有设备状态均在本地流转。它支持超过 2000 种设备协议,包括 Zigbee、Z-Wave、MQTT、Bluetooth、Modbus 等。这意味着不同品牌的设备可以在一个界面上统一管理。
要实现无感交互,语音是关键入口。关键在于让语音助手'认识'你家的设备。Google、Alexa、Siri 本身不认识 Zigbee 或 MQTT,它们只认自家定义的设备模型(如 light、switch、thermostat)。因此需要将 HA 里的实体'翻译'成它们能理解的语言。
集成方案
Google Assistant
需要配置 Google Device Access 项目。
- 为 HA 实例配置公网 HTTPS 地址(可使用 DuckDNS + Let's Encrypt)。
- 在 Google Developer Console 注册项目。
- 下载服务账户密钥(JSON 文件)。
- 在
configuration.yaml中配置:
google_assistant:
project_id: your-device-access-project-id
service_account: !include google_service_account.json
report_state: true
exposed_domains:
- light
- switch
- climate
配置完成后,在 Google Home App 中添加账号即可同步设备。建议给设备起明确的名称,并开启 report_state 以同步状态。
Amazon Alexa
通过 Smart Home Skill 机制对接。HA 内置了 alexa 集成,需配置 HTTPS 端点。
http:
ssl_certificate: /ssl/fullchain.pem
ssl_key: /ssl/privkey.pem
alexa:
smart_home:
endpoint: https://your-domain.duckdns.org/api/alexa/smart_home
client_id: amzn-client-id

