当前位置:网站首页>In the hot summer, teach you to use Xiaomi smart home accessories + Raspberry Pi 4 to connect to Apple HomeKit
In the hot summer, teach you to use Xiaomi smart home accessories + Raspberry Pi 4 to connect to Apple HomeKit
2022-08-05 04:14:00 【Jerry Yifeng】
前言
Apple HomeKitSmart home solutions,是苹果2016年在WWDC大会上提出来的,至今已经6个年头.It has always been a tepid state in the country,In addition to the follow-up of a large number of domestic manufacturers such as the Mijia solution of Xiaomi smart home,Apple specific“贵”It is also one of its obstacles,The price of a few hundred yuan for a smart socket or an air conditioner companion frightens off a lot of fruit fans(包括我).In addition, Xiaomi's smart home is also supportedHomeKit(需要单独购买HomeKit的网关),Here's how not to buy extraHomeKitunder the premise of the gateway,Implemented using Raspberry PiApple HomeKitSmart home solutions.
接入过程
一、使用ssh登录树莓派,and configure the corresponding packages
接入Apple HomeKit We need to use it on Raspberry Pinpm包管理,如果没有安装npm请自行Goole解决,Usually Raspberry Pi is usedapt-get安装,If not, you can only install it by downloading the official website package.
然后通过npm安装,homebridge,以及homebridge-mi-acpartner(一个homebridgePlugins that support Xiaomi accessories)
sudo npm install -g -unsafe-perm homebridge
sudo npm install -g homebridge-mi-acpartner
然后输入homebridge回车,If a QR code appears on the console, the installation is successful.
homebridge
二、获取小米(绿米)空调伴侣token
There are various ways to obtain here,For example, through the old version of Mijia a mess(Estimated Android package from a few years ago,Can use location)等等.Here is a reliable solution,通过miio 插件.
//Here is to use my ownmacbook获取,not Raspberry Pi,windowMachines do as well.
首先安装miio
npm install miio
After that, press and hold the Xiaomi Air Conditioning Companion to reset,It will appear without a passwordwifi,通过macbook连接该wifi.然后输入以下命令
miio discover
接下来就是见证奇迹的时刻,Air Conditioning Companiontoken已经被发现了.

The next step is to follow the official Xiaomi tutorial,connect to homeWifi,And configure the smart air conditioner remote control.Basically open Mijia,点击添加就OK了.
Do it again at this point
miio discover
Record the route of the air conditioner companionWifi地址,Will need it for a while.

三、配置Homebridge的config.json文件
HomebridgeThe run is actually dependentconfig.jsonfile configuration to run,结合homebridge-mi-acpartnerparameters on the plugin,We write the configuration below.
cd .homebridge
//新建文件
touch config.json
//编辑文件,我这里使用nano, 看个人爱好
sudo nano config.json
写入如下配置
{
"platforms": [
{
"platform": "XiaoMiAcPartner",
"devices": {
"The route of the Mijia Air Conditioning Companion saved aboveip地址": "上面获取到的token"
},
"accessories": [
{
"name": "learnir_switch",
"type": "learnIR"
},
{
"name": "AC Partner",
"type": "climate"
},
{
"name": "ir_switch",
"type": "switch",
"data":{
"on": "FE00000000000000000000000006003222580031003C00AC01C2037A1388430201010101010101010202020202020202020101010101010100020202020202020201010101010101010202020202020583",
"off": "FE00000000000000000000000006003222580034003E00AB01C0037A1388430201000000010000000202020202020202020001000001000001020202020202020201010001000001010202020202020578"
}
}
]
}
]
}
重新启动homebridge
homebridge
通过iPhone家庭AppScan accesshomeBridge,After a confirmation at this time,家庭AppThree switches will appear,Air conditioning respectively、风扇(已改名,对应的是上面的ir_switch),The following will continue to explain how it came about(Obtaining the infrared code).learnir_switch(Red card learning switch),Used to obtain the infrared code of the infrared device.

四、Configure a custom infrared code
There just happens to be a fan here that has a remote control,我以此为例,Let's talk about how to copy the fan's IR code.上面的learnir_switch After switch configuration,通过家庭app打开learn开关,At this point, the Raspberry Pi console will prompt you to start recording,At this time, the infrared codes of all your infrared devices in one minute will be captured and printed,如下,Fill in after we captureon,off栏,At this point a custom infrared switch is complete.

五、给你的HomeKitConfigure remote start
After the above operations are processed,你的HomeKitIn fact, it only works on the local network at home(The phone and the Raspberry Pi are connected to the same router),If you want to warm up the air conditioner remotely on your way home,Then you want to giveHomeKitProvide a home hub.Simply put, you need to have oneiPad或者Home PodStay at home,连接wifi,和iphone以及macbooketc. use the same oneApple 帐号,And turn on the family hub function.I happen to have a deskiPad Pro在家,如下即可,Then you can enjoy the treatment of turning on the air conditioner in advance before going home.

六、Raspberry Pi boot process protection
最后,也就是如何让homebridgePermanent thread,Normally if you close itssh,homebrigeNaturally to you tooclose掉.How do we implement exiting raspberry pi,The process is still there?Then process protection is required,There are many options for process protection,Here I use the simplest one.
安装screen
sudo apt install screen
在scrren中启动homebidge,Then just shut down the Raspberry Pi,具体screen的用法,请自行google.
//Start a name calledhomekit的 screen
screen -S homekit
//A new window will be created,然后启动homebridge
homebridge
末尾
本篇文章就到此为止,如果你有什么想法,欢迎留言评论哈,感谢大家耐心看完,I also invite everyone who passes by to make a one-click three-link,感谢~
边栏推荐
- 【informix】解决启动报错大全,以及解决办法
- 10 years of testing experience, worthless in the face of the biological age of 35
- DEJA_VU3D - Cesium功能集 之 058-高德地图纠偏
- What is the function of industrial-grade remote wireless transmission device?
- 35岁的软件测试工程师,月薪不足2W,辞职又怕找不到工作,该何去何从?
- No regrets, the appium automation environment is perfectly built
- In the WebView page of the UI automation test App, the processing method when the search bar has no search button
- About the installation of sklearn library
- 浅析主流跨端技术方案
- UE4 后期处理体积 (角色受到伤害场景颜色变淡案例)
猜你喜欢

Some conventional routines of program development (1)

The log causes these pits in the thread block, you have to guard against

小程序_动态设置tabBar主题皮肤

【Mysql进阶优化篇02】索引失效的10种情况及原理

flink读取mongodb数据源

A 35-year-old software testing engineer with a monthly salary of less than 2W, resigns and is afraid of not finding a job, what should he do?

UE4 opens doors with overlapping events

Mysql's redo log detailed explanation

七夕节代码表白
![[MRCTF2020]PYWebsite](/img/d4/57e8e5ee45b742894679f3f5671516.png)
[MRCTF2020]PYWebsite
随机推荐
[Geek Challenge 2019]FinalSQL
bytebuffer put flip compact clear 方法演示
DEJA_VU3D - Cesium功能集 之 058-高德地图纠偏
4T硬盘剩余很多提示“No space left on device“磁盘空间不足
UE4 opens door via interaction (keyboard key)
不看后悔,appium自动化环境完美搭建
Talk about 20 common problems in data governance
虚证、实证如何鉴别?
测试薪资这么高?刚毕业就20K
Redis key basic commands
Cron(Crontab)--使用/教程/实例
[MRCTF2020]Ezpop(详解)
【8.2】代码源 - 【货币系统】【硬币】【新年的问题(数据加强版)】【三段式】
Redis1: Introduction to Redis, basic features of Redis, relational database, non-relational database, database development stage
UE4 为子弹蓝图添加声音和粒子效果
flink读取mongodb数据源
App rapid development and construction experience: the importance of small programs + custom plug-ins
Android interview question - how to write with his hands a non-blocking thread safe queue ConcurrentLinkedQueue?
bytebuffer 内部结构
银行数据采集,数据补录与指标管理3大问题如何解决?