Home Assistant 配置项目教程
1. 项目的目录结构及介绍
目录结构
homeassistant-config/
├── automations/
├── scripts/
├── scenes/
├── themes/
├── configuration.yaml
├── customize.yaml
├── groups.yaml
├── home-assistant.log
├── secrets.yaml
└── .gitignore
目录介绍
- automations/: 存放自动化脚本的目录。
- scripts/: 存放自定义脚本的目录。
- scenes/: 存放场景配置的目录。
- themes/: 存放主题配置的目录。
- configuration.yaml: 主配置文件。
- customize.yaml: 用于自定义实体属性的文件。
- groups.yaml: 用于定义组和权限的文件。
- home-assistant.log: 日志文件。
- secrets.yaml: 用于存储敏感信息的文件。
- .gitignore: Git 忽略文件配置。
2. 项目的启动文件介绍
启动文件
- configuration.yaml: 这是 Home Assistant 的主配置文件,包含了大部分的配置信息,如集成、设备、自动化等。
启动流程
- 加载配置文件: Home Assistant 启动时会首先加载
configuration.yaml
文件。 - 初始化集成: 根据配置文件中的集成列表,初始化各个集成。
- 启动服务: 启动各个服务,如 Web 服务、API 服务等。
3. 项目的配置文件介绍
配置文件
- configuration.yaml: 主配置文件,包含了 Home Assistant 的所有基本配置。
- customize.yaml: 用于自定义实体的属性,如名称、图标等。
- groups.yaml: 用于定义组和权限。
- secrets.yaml: 用于存储敏感信息,如密码、API 密钥等。
配置示例
configuration.yaml
homeassistant:
name: Home
latitude: 37.8267
longitude: -122.4233
elevation: 10
unit_system: metric
time_zone: America/Los_Angeles
frontend:
http:
api_password: !secret http_password
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
customize.yaml
light.living_room:
friendly_name: 客厅灯
icon: mdi:lamp
switch.kitchen:
friendly_name: 厨房开关
icon: mdi:light-switch
groups.yaml
default_view:
view: yes
entities:
- group.living_room
- group.kitchen
group.living_room:
name: 客厅
entities:
- light.living_room
- switch.living_room
group.kitchen:
name: 厨房
entities:
- light.kitchen
- switch.kitchen
secrets.yaml
http_password: your_password
通过以上配置文件,可以实现对 Home Assistant 的详细配置和管理。