home assistant安装方法

home assistant安装 现在实验室虽然在2楼还是很潮,打印用的材料总是受潮,所以老师让买了一个小米除湿器,这个设备可以直接加入米家远程控制,但我用的是iPhone想体验一下homekit,冲浪之后发现home assistant可以实现米家接入homekit,网上的教程有些代码过期了,因此整理一下安装过程。 docker安装 Mac下的docker 安装docker 部署镜像 #拉取hass的最新版镜像(注意:根据自己需求选择对应版本,并不是越新越好) docker pull homeassistant/home-assistant:latest #创建容器并运行 docker run -d --name="hass" -v /Users/wenqian/home-assistants:/config -p 8123:8123 -p homeassistant/home-assistant:latest 解释: -d:表示在后台运行 –name:给容器设置一个名称,用于识别,这里起名叫做hass -v:配置目录映射(容器内的指定目录直接映射到本地主机的对应目录,比如上面那句命令,意思就是将容器里hass的 config 目录映射到 /Users/wenqian/home-assistants 这个目录里面) -p:映射端口(将容器内的8123端口直接映射到物理机的8123端口,这样服务器的IP地址+端口号即可访问hass页面) 访问hass 浏览器访问localhost:8123/ip:8123,设置用户名并登录, 安装hacs商店 官网链接 hacs # 进入docker容器内 docker exec -it hass bash # 下载 wget -O - https://get.hacs.xyz | bash - hacs内安装xiaomi miot hass内安装xiaomi miot hass内安装apple homekit并设置桥接 docker内容器的ip不是桥接,因此homekit桥接失败,我还搞明白如何修改,看了网上代码好麻烦,直接放弃了 虚拟机安装 Mac虚拟机 我直接下载了官网推荐的VirtualBox虚拟机软件,但是无法安装64位虚拟机,遂放弃…… windows虚拟机hyper 从home assistant官网下载windows下hyper对应的虚拟机文件,参考官网设置,等待系统启动即可使用。 我们学校内有线网可以使用ipv6,访问github会快一点,所以虚拟交换机为与有线网卡的桥接,这样hass虚拟机直接获得了校内ipv4和校内ipv6,理论上我在校园网下手机homekit可以直接控制设备,不用额外搭配家庭中枢(HomePod、Apple TV)【我试了食堂的网络 不行 哈哈哈哈】 具体操作有人问了我再补充吧

2022年11月10日 · 1 分钟 · Vinkey

搭建自己的随机图API

因为一直没有为博客的随机封面找到好的api,所以就在网上搜索如何自己制作,发现很简单,只需要:有图、写个php。 生成图片链接 首先选好自己的目标图片,上传至internet,可以选择自己服务器、云存储空间、GitHub图床等,获取所有图片外链即可,建议图片名字选择纯数字。 PHP生成随机链接 制作图片api的方式有很多,本文参考如下代码,通过php生成随机数字,拼接得到随机访问图片的链接,然后跳转对应链接。 <?php //初始化随机数生成器种子,这行代码也可以删除 $seed = time(); //获取随机数 $num = rand(1,42); //拼接图片地址 $picpath = "http://ritn3ta2k.hn-bkt.clouddn.com/api-img/".$num.".jpg"; //重定位到图片 die(header("Location: $picpath")); ?> 参考资料

2022年10月4日 · 1 分钟 · Vinkey

Mac下Nginx的安装与配置

环境:MacBook Air M1, macOS Monterey 12.6 安装 建议选择homebrew安装,安装完成后会显示基本信息,后续如果要重新查看可通过命令实现。 brew install nginx 安装 brew info nginx 查看信息 Docroot is: /opt/homebrew/var/www The default port has been set in /opt/homebrew/etc/nginx/nginx.conf to 8080 so that nginx can run without sudo. nginx will load all files in /opt/homebrew/etc/nginx/servers/. To restart nginx after an upgrade: brew services restart nginx Or, if you don't want/need a background service you can just run: /opt/homebrew/opt/nginx/bin/nginx -g daemon off; 使用 brew services start nginx 启动 brew services stop nginx 停止 nginx -t 测试配置文件 ...

2022年10月2日 · 2 分钟 · Vinkey