当前位置:网站首页>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,感谢~
边栏推荐
- Defect detection (image processing part)
- NPDP证书含金量高吗?跟PMP相比?
- bytebuffer internal structure
- How to wrap markdown - md file
- [BSidesCF 2019]Kookie
- Paparazzi: Surface Editing by way of Multi-View Image Processing
- DEJA_VU3D - Cesium功能集 之 057-百度地图纠偏
- iMedicalLIS listener (2)
- 2022软件测试工程师最全面试题
- What is the function of industrial-grade remote wireless transmission device?
猜你喜欢
![[MRCTF2020]PYWebsite](/img/d4/57e8e5ee45b742894679f3f5671516.png)
[MRCTF2020]PYWebsite
虚证、实证如何鉴别?

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?

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

Visibility of multi-column attribute column elements: display, visibility, opacity, vertical alignment: vertical-align, z-index The larger it is, the more it will be displayed on the upper layer

如何解决复杂的分销分账问题?

bytebuffer internal structure

使用IDEA连接TDengine服务器

UE4 通过重叠事件开启门
![[CISCN2019 South China Division]Web11](/img/15/843334fec0a5cc8cfaba92aab938db.png)
[CISCN2019 South China Division]Web11
随机推荐
No regrets, the appium automation environment is perfectly built
DNS被劫持如何处理?
程序开发的一些常规套路(一)
关于#SQL#的迭代、父子结构查询问题,如何解决?
[8.2] Code Source - [Currency System] [Coins] [New Year's Questions (Data Enhanced Edition)] [Three Stages]
概率论的学习和整理8: 几何分布和超几何分布
不看后悔,appium自动化环境完美搭建
[SWPU2019]Web1
How to solve complex distribution and ledger problems?
JeeSite新建报表
商业智能BI业务分析思维:现金流量风控分析(一)营运资金风险
In the WebView page of the UI automation test App, the processing method when the search bar has no search button
token, jwt, oauth2, session parsing
bytebuffer put flip compact clear 方法演示
[CISCN2019 South China Division]Web11
Talk about 20 common problems in data governance
Machine Learning Overview
Learning and finishing of probability theory 8: Geometric and hypergeometric distributions
国学*周易*梅花易数 代码实现效果展示 - 梅花心易
Mysql的redo log详解