This post is originally from www.jaredwolff.com
这篇文章最初来自www.jaredwolff.com
I’ve been nerding out. It’s something I just can’t stop sometimes.
我一直在书呆子。 这是我有时无法停止的事情。
Most recently working on making our home more connected and efficient. Part of the effort was experimenting with some Wemos I had purchased off of eBay about a month ago. The Wemo app works alright but there’s definitely more to be desired there. (Plus it makes me cringe to think every Wemo is running DDWRT)
最近的工作是使我们的家更连通,更高效。 一部分工作是尝试试用一个月前我从eBay上购买的Wemos。 Wemo应用程序可以正常运行,但是肯定还有更多的需求。 (此外,让我不敢相信每个Wemo都在运行DDWRT)
The main problem? Wemo doesn’t support Apple Homekit.
主要问题? Wemo不支持Apple Homekit。
So I got to researching and found the Homebridge project to be just what I was looking for. Basically, it emulates a device that operates on the HAP protocol that Apple supports for Homekit. Within Homebridge, you can configure as many devices via as many different interfaces you could imagine. Deploying it to a Raspberry Pi, or similar, can be troublesome and wrought with errors. So why not take a different approach?
因此,我进行了研究,发现Homebridge项目正是我想要的。 基本上,它模拟的设备运行的是Apple支持Homekit的HAP协议。 在Homebridge中,您可以通过可以想象的许多不同接口配置尽可能多的设备。 将其部署到Raspberry Pi或类似设备上可能会很麻烦,而且会出错。 那么,为什么不采用其他方法呢?
Enter Resin OS.
输入Resin OS。
Some advantages of Resin OS are:
Resin OS的一些优点是:
- Deploying a pre-optimized image for the Yocto platform 为Yocto平台部署预优化的映像
- No configuring of any Linux anything (except for the config.json) 无需配置任何Linux(config.json除外)
- Get up and running in a few minutes (mostly flashing and container initialization) 几分钟后即可启动并运行(主要是闪烁和容器初始化)
I originally played around with Resin’s online platform which shows some promise. For those developers who don’t want to spend time writing code for OTA updates and building Yocto images manually, you should definitely take a look at Resin.io.
我最初在Resin的在线平台上玩耍,这显示了一些希望。 对于那些不想花时间编写OTA更新代码和手动构建Yocto图像的开发人员,您绝对应该看看Resin.io。
(By the way, I have no affiliation with Resin, I think they’ve done a great job and they’ve contributed to the community significantly with their open source tools: http://resinos.io , https://etcher.io , https://www.balena.io )
(顺便说一句,我与Resin没有关系,我认为他们做得很好,并且他们使用开放源代码工具对社区做出了巨大贡献: http ://resinos.io、https:// etcher。 io , https://www.balena.io )
![HomeKit on iPhone](https://i-blog.csdnimg.cn/blog_migrate/e8a5bc92fa29691c27e9729ee5a289ea.jpeg)
So how do I get a Wemo working with Homekit?
那么,如何让Wemo与Homekit一起使用?
Resin themselves have some fantastic documentation. I barely had to look anywhere when error messages came up when developing my first crack at the Docker container. (I was originally using the slim image which does not have all the needed utilities that Homebridge requires, easier to just use the latest image instead)
树脂本身有一些很棒的文档。 在Docker容器上开发我的第一个破解程序时,我几乎不必去寻找错误消息。 (我最初使用的是细长映像,它没有Homebridge所需的所有必需实用程序,更容易使用最新映像)
The instructions are as follows:
说明如下:
Install dependencies. On Mac, Node is the only thing you may need to install. Homebrew works best here.
安装依赖项。 在Mac上, Node是唯一可能需要安装的东西。 家酿在这里效果最好。
brew install node
Download and install the resin-cli:
下载并安装resin-cli:
npm install —global —production resin-cli
Download your image from the download link if you haven’t already.
如果尚未下载图片,请从下载链接下载图片。
Modify the image to your liking by using the cli.
使用cli根据自己的喜好修改图像。
$ sudo resin local configure ~/Downloads/resin.img ? Network SSID Wolff Den ? Network Key This is not our password. ? Do you want to set advanced settings? Yes ? Device Hostname resin ? Do you want to enable persistent logging? no Done!
“Flash” the image to an SD card. Make sure you have a free device to write to!
将图像“闪存”到SD卡。 确保您有可写的免费设备!
$ sudo resin local flash ~/Downloads/resin.img Password: ? Select drive (Use arrow keys) ❯ /dev/disk1 (32 GB) - RESIN
Wait for the process to complete and then eject the card. Pop it into the device you’ve configured the image for.
等待该过程完成,然后弹出卡。 将其弹出到您为其配置图像的设备中。
Once booted, you should be able to ping the device.
一旦启动,您应该能够ping设备。
ping resin.local PING resin.local (192.168.7.45): 56 data bytes 64 bytes from 192.168.7.45: icmp_seq=0 ttl=64 time=9.004 ms 64 bytes from 192.168.7.45: icmp_seq=1 ttl=64 time=6.411 ms 64 bytes from 192.168.7.45: icmp_seq=2 ttl=64 time=4.337 ms 64 bytes from 192.168.7.45: icmp_seq=3 ttl=64 time=4.374 ms
Modify the config.json file to your liking. Highly suggest changing the pin to something different as this is the one that Homebridge uses in their examples.
根据您的喜好修改config.json文件。 强烈建议将引脚更改为其他引脚,因为这是Homebridge在其示例中使用的引脚。
Also, feel free to modify the Dockerfile to match your needs. In this example the only thing that you may want to change is the image name. By default I have hummingboard-node:latest as the main image.
另外,请随时修改Dockerfile以满足您的需求。 在此示例中,您唯一想更改的就是图像名称。 默认情况下,我将hummingboard-node:latest作为主图像。
You can now push the included Homebridge Docker file and associated files directly to your embedded device.
现在,您可以将随附的Homebridge Docker文件和关联的文件直接推送到嵌入式设备。
sudo resin local push resin.local —source .
Note: this will take several minutes as it will be building the docker image on the embedded device. This takes much less time using the Resin.io platform as it builds on your local machine and then sent to the embedded device as a complete image
注意:这将需要几分钟,因为它将在嵌入式设备上构建docker映像。 使用Resin.io平台,因为它在本地计算机上构建,然后作为完整映像发送到嵌入式设备,因此花费的时间要少得多
Wait to see the output from Homebridge indicating it’s running. rdt push completed successfully!
等待查看Homebridge的输出,表明它正在运行。 rdt push成功完成!
Streaming application logs.. *** WARNING *** The program ‘node’ uses the Apple Bonjour compatibility layer of Avahi. *** WARNING *** Please fix your application to use the native API of Avahi! *** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node> *** WARNING *** The program ‘node’ called ‘DNSServiceRegister()’ which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi. *** WARNING *** Please fix your application to use the native API of Avahi! *** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister> [2017-11-2 02:09:43] Loaded plugin: homebridge-platform-wemo [2017-11-2 02:09:43] Registering platform ‘homebridge-platform-wemo.BelkinWeMo’ [2017-11-2 02:09:43] — [2017-11-2 02:09:43] Loaded config.json with 0 accessories and 1 platforms. [2017-11-2 02:09:43] — [2017-11-2 02:09:43] Loading 1 platforms… [2017-11-2 02:09:43] [WeMo Platform] Initializing BelkinWeMo platform… Scan this code with your HomeKit App on your iOS device to pair with Homebridge: ┌────────────┐ │ 031-45-154 │ └────────────┘ [2017-11-2 02:09:43] Homebridge is running on port 51826. [2017-11-2 02:09:43] [WeMo Platform] Found: Master Den [123456789ABC] [2017-11-2 02:09:43] [WeMo Platform] Found: Jarchel Den [123456789BAC] [2017-11-2 02:09:43] [WeMo Platform] Found: Front Door Light [123456789CBA] [2017-11-2 02:09:44] [WeMo Platform] Jarchel Den - Get state: On
Pop open your phone and look for an available accessory in HomeKit. You will likely have to tap on “Don’t Have a Code or Can’t Scan?” and enter the number manually.
弹出您的手机,然后在HomeKit中寻找可用的配件。 您可能必须点击“没有密码或无法扫描?” 并手动输入号码。
Add your accessory by entering the passcode displayed earlier.
通过输入前面显示的密码来添加配件。
Congrats! All your Wemo devices should show up now. Enjoy using Siri with your Wemo devices.
恭喜! 您的所有Wemo设备现在都应显示。 享受在您的Wemo设备上使用Siri的乐趣。
![Default screen](https://i-blog.csdnimg.cn/blog_migrate/23d9ae76aa069030d825af14e36ff496.jpeg)
Found this tutorial useful? Here are some of my other Raspberry Pi related posts.
觉得本教程有用吗? 这是我与Raspberry Pi相关的其他一些帖子。
翻译自: https://www.freecodecamp.org/news/how-to-add-wemo-to-homekit-with-this-powerful-tool/