当前位置:网站首页>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,感谢~
边栏推荐
- 不看后悔,appium自动化环境完美搭建
- 动力小帆船制作方法简单,电动小帆船制作方法
- The log causes these pits in the thread block, you have to guard against
- UE4 第一人称角色模板 添加生命值和调试伤害
- iMedicalLIS listener (2)
- 炎炎夏日教你利用小米智能家居配件+树莓派4接入Apple HomeKit
- 2022软件测试工程师最全面试题
- 多列属性column元素的可见性:display、visibility、opacity、垂直对齐方式:vertical-align、z-index 越大越显示在上层
- 商业智能BI业务分析思维:现金流量风控分析(一)营运资金风险
- bytebuffer 使用demo
猜你喜欢

MySql的索引学习和使用;(本人觉得足够详细)

Ali's local life's single-quarter revenue is 10.6 billion, Da Wenyu's revenue is 7.2 billion, and Cainiao's revenue is 12.1 billion

App rapid development and construction experience: the importance of small programs + custom plug-ins

AUTOCAD——标注关联

程序开发的一些常规套路(一)

Defect detection (image processing part)

动力小帆船制作方法简单,电动小帆船制作方法

creo怎么测量点到面的距离
![[BSidesCF 2019] Kookie](/img/29/19e7c244feb86b37ab32a53aa11f25.png)
[BSidesCF 2019] Kookie

bytebuffer use demo
随机推荐
UE4 第一人称角色模板 添加生命值和调试伤害
Mini Program_Dynamic setting of tabBar theme skin
[CISCN2019 South China Division]Web11
UE4 通过互动(键盘按键)开门
【informix】解决启动报错大全,以及解决办法
多列属性column元素的可见性:display、visibility、opacity、垂直对齐方式:vertical-align、z-index 越大越显示在上层
Industry Status?Why do Internet companies prefer to spend 20k to recruit people rather than raise their salary to retain old employees~
新人如何入门和学习软件测试?
[MRCTF2020]Ezpop(详解)
Spark Basics [Introduction, Getting Started with WordCount Cases]
The test salary is so high?20K just graduated
如何解决复杂的分销分账问题?
What is ASEMI photovoltaic diode, the role of photovoltaic diode
How to solve complex distribution and ledger problems?
What is the function of industrial-grade remote wireless transmission device?
pyqt5 + socket 实现客户端A经socket服务器中转后主动向客户端B发送文件
[MRCTF2020] Ezpop (detailed)
Index Mysql in order to optimize paper 02 】 【 10 kinds of circumstances and the principle of failure
数组常用方法总结
36-Jenkins-Job迁移