网站首页 > 技术文章 正文
Home Assistant 是一款在 Python 3 上运行的家庭自动化平台。能够跟踪和控制家庭中的所有设备,并提供自动化控制平台。Home Assistant 有一个简单的、适合移动设备的界面来控制你的所有设备,且不会将任何数据存储在云端,以保护个人隐私。下面,我们以step by step的方式演示一下如何在debian11环境下安装Home Assistant Core(之前叫Home Assistant)
1 安装软件依赖包
更新apt软件列表
root@debian:~# apt-get update |
将系统内核及软件包升级到最新版本
root@debian:~# apt-get upgrade -y |
在这里最好重启一下系统,以确保最新的内核被加载
root@debian:~# reboot |
重启后验证一下内核版本
root@debian:~# uname -a Linux debian 5.10.0-19-amd64 #1 SMP Debian 5.10.149-2 (2022-10-21) x86_64 GNU/Linux |
安装软件依赖,Python需要安装3.9及以上版本(包含python3-dev)
apt-get install -y python3 python3-dev python3-venv python3-pip bluez libffi-dev libssl-dev libjpeg-dev zlib1g-dev autoconf build-essential libopenjp2-7 libtiff5 libturbojpeg0-dev tzdata |
2 创建账号
为Home Assistant Core创建一个账号及home目录
root@debian:~# useradd -rm homeassistant |
3 创建虚拟环境
创建Home Assistant Core的安装目录并更改目录属主账号为homeassistant
root@debian:/home# mkdir /srv/homeassistant root@debian:/home# chown homeassistant:homeassistant /srv/homeassistant |
切换到homeassistant账户下,创建并加载Home Assistant Core运行所需的虚拟环境
root@debian:~# sudo -u homeassistant -H -s homeassistant@debian:/root$ cd /srv/homeassistant homeassistant@debian:/srv/homeassistant$ python3 -m venv . homeassistant@debian:/srv/homeassistant$ source bin/activate (homeassistant) homeassistant@debian:/srv/homeassistant$ |
虚拟环境激活后,运行以下命令来安装所需的Python包
(homeassistant) homeassistant@debian:/srv/homeassistant$ python3 -m pip install wheel |
4 安装Home Assistant Core
采用pip3包管理工具安装homeassistant
(homeassistant) homeassistant@debian:/srv/homeassistant$ pip3 install homeassistant |
首次启动Home Assistant Core。将完成应用安装,自动在/home/homeassistant目录中创建.homeassistance配置目录,并安装所有基本依赖项
(homeassistant) homeassistant@debian:/srv/homeassistant$ hass Unable to find configuration. Creating default one in /home/homeassistant/.homeassistant 2022-11-04 16:18:57.015 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: bluetooth 2022-11-04 16:19:06.153 WARNING (MainThread) [homeassistant.setup] Setup of bluetooth is taking over 10 seconds. 2022-11-04 16:20:45.141 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: default_config |
当您第一次运行hass命令时,它将下载、安装和缓存必要的库/依赖项。此过程可能需要5到10分钟。在此期间,访问web界面时可能会出现“站点无法访问”错误。这只会是第一次,随后的重启会更快。
现在可以通过web界面访问Home Assistant Core
http://主机IP:8123
第一次访问会出现如下注册界面,首先为系统配置一个账号
接下来比较简单,按照提示一步一步完成配置即进入可系统界面
5 配置开机自启动
新建rc.local文件,以homeassistant用户执行服务启动命令
root@debian:/srv/homeassistant/bin# vi /etc/rc.local #!/bin/sh su homeassistant -c '/srv/homeassistant/bin/hass' |
添加可执行权限
root@debian:/srv/homeassistant/bin# chmod +x /etc/rc.local |
从/lib下拷贝一份rc-local.service文件模板
root@debian:/srv/homeassistant/bin# cp /lib/systemd/system/rc-local.service /etc/systemd/system/rc-local.service |
编辑rc-local.service,具体配置如下图所示
root@debian:/srv/homeassistant/bin# vi /etc/systemd/system/rc-local.service # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # This unit gets pulled automatically into multi-user.target by # systemd-rc-local-generator if /etc/rc.local is executable. [Unit] Description=/etc/rc.local Compatibility Documentation=man:systemd-rc-local-generator(8) ConditionFileIsExecutable=/etc/rc.local After=network.target [Service] Type=forking ExecStart=/etc/rc.local start TimeoutSec=0 RemainAfterExit=yes GuessMainPID=no [Install] WantedBy=multi-user.target ~ ~ " |
设置rc-local服务开机自启动
root@debian:/srv/homeassistant/bin# systemctl enable rc-local Created symlink /etc/systemd/system/multi-user.target.wants/rc-local.service → /etc/systemd/system/rc-local.service. |
ok,到此结束,后续有机会我们再摸索一下如何将家庭智能设备接入Home Assistant。
猜你喜欢
- 2025-08-01 AI 推理 | vLLM 快速部署指南
- 2025-08-01 Java实现调用nvidia硬编解码
- 2025-08-01 运维必备:掌握这3个存储技术
- 2025-08-01 Claude Code:完爆 Cursor 的编程体验
- 2025-08-01 【Docker 新手入门指南】第十章:Dockerfile
- 2025-08-01 Linux漏洞检测与修复工具示例
- 2025-08-01 Dify存储告急别焦虑!6步迁移教程,系统无缝切换,流畅度暴涨!
- 2025-08-01 技术栈:全网疯传的Claude code,保姆级使用教程来啦!
- 2025-08-01 如何使用 Prometheus 监控 Linux 服务器性能
- 2025-08-01 LLVM IR入门:编写自定义优化Pass的完整教程与性能影响分析
- 08-01Linux Systemd入门
- 08-01使用 Checkmk 监控 Oracle 服务器
- 08-01核心库CPU飙到99%了!我发现很多DBA都不会看日志……
- 08-01China's CETC Kingbase Unveils AI-Powered Database Appliances Amid Rising Demand for Intelligent Data Infrastructure
- 08-01Docker安装部署Oracle/Sql Server
- 08-01Oracle数据库安装 | 步骤详细
- 08-01基于Springboot + vue实现的社团管理系统
- 08-01前端开发如何用Mock.js进行数据接口模拟
- 1520℃桌面软件开发新体验!用 Blazor Hybrid 打造简洁高效的视频处理工具
- 623℃Dify工具使用全场景:dify-sandbox沙盒的原理(源码篇·第2期)
- 526℃MySQL service启动脚本浅析(r12笔记第59天)
- 492℃启用MySQL查询缓存(mysql8.0查询缓存)
- 491℃服务器异常重启,导致mysql启动失败,问题解决过程记录
- 479℃「赵强老师」MySQL的闪回(赵强iso是哪个大学毕业的)
- 460℃mysql服务怎么启动和关闭?(mysql服务怎么启动和关闭)
- 458℃MySQL server PID file could not be found!失败
- 最近发表
-
- Linux Systemd入门
- 使用 Checkmk 监控 Oracle 服务器
- 核心库CPU飙到99%了!我发现很多DBA都不会看日志……
- China's CETC Kingbase Unveils AI-Powered Database Appliances Amid Rising Demand for Intelligent Data Infrastructure
- Docker安装部署Oracle/Sql Server
- Oracle数据库安装 | 步骤详细
- 基于Springboot + vue实现的社团管理系统
- 前端开发如何用Mock.js进行数据接口模拟
- 使用vite为vue项目配置@别名
- 基于Springboot + vue3实现的教务管理系统
- 标签列表
-
- cmd/c (90)
- c++中::是什么意思 (84)
- 标签用于 (71)
- 主键只能有一个吗 (77)
- c#console.writeline不显示 (95)
- pythoncase语句 (88)
- es6includes (74)
- sqlset (76)
- windowsscripthost (69)
- apt-getinstall-y (100)
- js~~ (67)
- node_modules怎么生成 (87)
- c++int转char (75)
- static函数和普通函数 (76)
- el-date-picker开始日期早于结束日期 (70)
- js判断是否是json字符串 (67)
- c语言min函数头文件 (68)
- asynccallback (71)
- localstorage.removeitem (74)
- vector线程安全吗 (70)
- java (73)
- js数组插入 (83)
- mac安装java (72)
- 查看mysql是否启动 (70)
- 无效的列索引 (74)