HomeAssisstant入门

前言

  • 最近了解到HomeAssistant的香,准备搞一下。由于家中常备的设备只有一台windows台式机,所以先用windows搭一套试一下。
  • 目前家中主要的智能设备概况如下:
  1. 主要都是小米的设备
  2. 网关一个,支持HomeKit+Mi
  3. 一个支持HomeKit的插座,其他都只支持Mi
  4. 小爱音箱两个,支持红外
  5. 温湿度计*1
  6. 门窗开关+光线感应*1
  7. 其他电器若干

Windows安装HomeAssistant

安装python

安装HomeAssistant

  • 执行命令pip3 install homeassistant
  • 报错pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
  • 尝试科学上网,报错ValueError: check_hostname requires server_hostname
  • 尝试换源,阿里源报错ERROR: No matching distribution found for homeassistant
  • 尝试换源,清华源pip3 install homeassistant -i https://pypi.tuna.tsinghua.edu.cn/simple,开始下载
  • 下载完毕后开始安装,报错,缺少C++运行环境
Building wheel for bcrypt (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\administrator\appdata\local\programs\python\python39\python.exe' 'c:\users\administrator\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' build_wheel 'C:\Users\ADMINI~1\AppData\Local\Temp\tmpwzq1wt8b'
       cwd: C:\Users\Administrator\AppData\Local\Temp\pip-install-anssn5i0\bcrypt_deb54a9f143d46d1b170ef5873ee0ef0
  Complete output (14 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.9
  creating build\lib.win-amd64-3.9\bcrypt
  copying src\bcrypt\__about__.py -> build\lib.win-amd64-3.9\bcrypt
  copying src\bcrypt\__init__.py -> build\lib.win-amd64-3.9\bcrypt
  running build_ext
  generating cffi module 'build\\temp.win-amd64-3.9\\Release\\_bcrypt.c'
  creating build\temp.win-amd64-3.9
  creating build\temp.win-amd64-3.9\Release
  building '_bcrypt' extension
  error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
  ----------------------------------------
  ERROR: Failed building wheel for bcrypt
Failed to build bcrypt
ERROR: Could not build wheels for bcrypt which use PEP 517 and cannot be installed directly
  • 安装Visual Studio,并安装C++
  • 安装成功后再次运行pip3 install homeassistant -i https://pypi.tuna.tsinghua.edu.cn/simple,报错权限问题
ERROR: Could not install packages due to an OSError: [WinError 5] 拒绝访问。: 'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-uninstall-s048qyii\\pip3.exe'
Consider using the `--user` option or check the permissions.
  • 运行pip3 install homeassistant -i https://pypi.tuna.tsinghua.edu.cn/simple --user
  • 安装成功

运行HomeAssistant

  • 运行py -m homeassistant --open-ui
  • 首次运行时可能后台在安装组件,需要一段时间才OK
  • 打开控制台 地址:http://localhost:8123/

遗留问题

  • 初始化时无法获取到时区列表,创建失败Error handling message: Invalid time zone passed in. Valid options can be found here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones for dictionary value @ data['time_zone']. Got 'Asia/Shanghai',猜测原因是因为某个数据获取的过程被拦截了

Docker安装

鉴于windows安装出现了一些问题,尝试使用docker安装试一下

查找镜像

  1. 镜像库地址
  2. 或使用命令查询search home-assistant

下载镜像

  1. 执行命令docker pull homeassistant/home-assistant

运行镜像

  1. 执行命令docker run -d --name="home-assistant" -e "TZ=Asia/Shanghai" -v /Users/name/HomeAssistant:/config -p 8123:8123 homeassistant/home-assistant
  2. -v [镜像卷地址/配置放置地址]:/config
  3. 有人告诉我一定要用host模式,但是试了一下,启动后打不开主页,暂且放放

使用

初次登陆

  1. 打开地址:http://localhost:8123
  2. 设置用户名和密码
  3. 选择时区,Asia/Shanghai
  4. 选择是否共享数据以帮助HomeAssistant提升,我什么都没选
  5. 选择是否要导入配置或使用已有的智能设备初始化,我还是什么都没选
  6. 报错Safari浏览器无法打开页面“http://localhost:8123/onboarding.html”。错误是: “Response served by service worker has redirections”(WebKitInternal:0), 再登陆一下就好了,不知道为啥。

查看内容

修改定位

  • 发现地图里家的定位不对,调整配置文件进行指定。打开上面启动时的挂载卷地址,找到configuration.yaml,在根级添加如下配置,经度、纬度、高度可以查看iphone指南针App。保存后重启服务即可。
homeassistant:
  # 经度和纬度数据,用来计算日出和日落时间
  latitude: 32.00335
  longitude: 118.73145

  # 影响天气和日出日落数据(海拔高度,单位:米)
  elevation: 30

  # 公制单位为:'metric',英制单位为:'imperial'
  unit_system: metric

  # 参考以下链接来选择你的时区:
  # http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  time_zone: Asia/Shanghai

  # 运行HomeAssistant系统的地点,可自定义
  name: 我的家1104
  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值