当前位置:网站首页>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,感谢~
边栏推荐
- 小程序_动态设置tabBar主题皮肤
- C++ core programming
- UE4 通过与其它Actor互动开门
- 10 years of testing experience, worthless in the face of the biological age of 35
- 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?
- Spark Basics [Introduction, Getting Started with WordCount Cases]
- 工业级远距离无线传输装置的功能有哪些?
- iMedicalLIS listener (2)
- 【8.2】代码源 - 【货币系统】【硬币】【新年的问题(数据加强版)】【三段式】
- 2022软件测试工程师最全面试题
猜你喜欢
动力小帆船制作方法简单,电动小帆船制作方法
日志导致线程Block的这些坑,你不得不防
UE4 opens doors with overlapping events
Index Mysql in order to optimize paper 02 】 【 10 kinds of circumstances and the principle of failure
token, jwt, oauth2, session parsing
36-Jenkins-Job迁移
Defect detection (image processing part)
测试薪资这么高?刚毕业就20K
flink reads mongodb data source
Acid (ACID) Base (BASE) Principles for Database Design
随机推荐
关于#SQL#的迭代、父子结构查询问题,如何解决?
[CISCN2019 South China Division]Web11
What is the difference between SAP ERP and ORACLE ERP?
C++ core programming
Spark基础【介绍、入门WordCount案例】
Redis1: Introduction to Redis, basic features of Redis, relational database, non-relational database, database development stage
token, jwt, oauth2, session parsing
说说数据治理中常见的20个问题
Redis key basic commands
[BSidesCF 2019]Kookie
七夕节代码表白
[MRCTF2020] Ezpop (detailed)
四位数显表头设计
UE4 第一人称角色模板 添加冲刺(加速)功能
Some conventional routines of program development (1)
UE4 更改组件变量 (以修改第一人称角色模板的最大行走速度和跳跃高度为例)
【8.2】代码源 - 【货币系统】【硬币】【新年的问题(数据加强版)】【三段式】
The log causes these pits in the thread block, you have to guard against
[BJDCTF2020] EasySearch
Mysql的undo log详解