不想起床关灯 篇二:DC1 远程控制之路 - K3 安装HomeAssistant 遇坑记
折腾之路
继前篇讲到购买DC1,并使用工具连接上路由器后,由于我家使用的是某讯K3官改版本,其包含控制DC1的功能,如下图:
这个能控制DC1,但我没有找到结合小爱的方法。查找很多,找到另外一个方法,将dc1 接入 homeassistant(以后简称ha,由python编写,我刚认识不久的设备控制中枢),使用ha来控制,然后再结合小爱开放平台,从而实现声控。
在K3中安装ha
1.先在路由器配置域名解析(我k3的位置是 功能设置-高级设置-Host配置),192.168.2.1这里是你ha服务器安装的位置
192.168.2.1 phicomm.me
192.168.2.1 Smartplugconnect.phicomm.com
192.168.2.1 aircat.phicomm.com
2.安装ha,
开始阶段,我是将ha装在NAS,在nas安装ha就简单很多,我就不赘述了。但由于我NAS不是24小时开机,所以我准备在K3路由器(感谢K3官改大佬的强大)上直接安装。
K3的存储不足以支持GCC编译链,故而需要插入一个U盘并将其挂载到opt
#mount -t ext4 /dev/sda1 /opt
安装 entware软件中心
# /usr/entware_install.sh
更新软件中心
#opkg update
(如果opkg install 软件出错,可能是你的网络被ICP缓存了,你在/opt/etc/opkg.conf 未尾添加可用的代理
#vi /opt/etc/opkg.conf
option http_proxy $http_proxy_ip:$http_proxy_port
然后再#opkg update
安装gcc,(参考)
#opkg install gcc ldd make gawk sed
安装系统头文件
#wget -qO- http://bin.entware.net/armv7sf-k2.6/include/include.tar.gz | tar xvz -C /opt/include
#opkg install python3 python3-pip
安装HA
#pip3 install homeassistant
在安装过程中,遇到了 ffi 安装不了的问题,
Using Python
Sometimes you may encounter some errors during compilation. For example when you use pip to install cffi the libffi library will not be found. Entware (Openwrt in fact) does not install libffi.so symlink in /opt/lib. There is only symlink libffi.so.6 there. You can create missing link manually or fix the installation files. This can be done as follows. First download cffi archive and unpack to some directory. Short investigation shows that setup.py has a line libraries = ['ffi'] with the missing library. Edit it, and change to libraries = [':libffi.so.6']. Now run python setyp.py build:
参考 以上链接,建立libffi的软链接,
#ln -s /opt/lib/libffi.so.6 /opt/lib/libffi.so
再次执行安装就可以了。
启动HA
#python3 -m homeassistant --open-ui --config /opt/root/.homeassistant
到此,ha安装完毕,接下来进入 DC1接入ha 配置篇
外观展示
乌海湖畔美如画
校验提示文案
乌海湖畔美如画
校验提示文案