Smart home devices should work without the internet
本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。
Smart home devices should work without the internet
AI;DR: I wrote the first draft, AI helped me edit and rewrite it, and I made the final pass. The rules, setups, and talks are my own.
AI;DR:我写了初稿,AI 协助我进行了编辑和重写,最后由我进行了定稿。其中的规则、设置和演讲内容均出自本人。
TLDR; Nothing core in my house depends on a vendor’s server. If the internet goes down, the house keeps running. That’s been rule one for about ten years, and my other rules came out of it. This post has the rules, then both talks I’ve given on home automation, slide by slide.
TLDR;我家里的核心功能都不依赖于供应商的服务器。如果互联网中断,房子依然能正常运转。这是我过去十年来的第一准则,我的其他准则也由此衍生。这篇文章包含了这些准则,以及我关于家庭自动化的两次演讲内容,按幻灯片逐一展示。
My Nest integration worked until Google broke the API. That’s the failure I plan around now. The talks have a few more: a Samsung fridge showing a TLS certificate error on its own screen, and a Camp Chef grill controller that needs Wi-Fi to show you the temperature.
我的 Nest 集成曾经运行良好,直到 Google 破坏了 API。这就是我现在防范的故障类型。演讲中还提到了其他几个例子:三星冰箱在屏幕上显示 TLS 证书错误,以及 Camp Chef 烤架控制器需要 Wi-Fi 才能显示温度。
Everything that matters runs on hardware I own. That’s Tasmota on ESP boards, an MQTT broker, and Node-RED on a Raspberry Pi. I do use some cloud services, mostly Alexa and a few AWS ones. Alexa is just another way to flip a switch. If it’s down, the wall switches and the wall dashboard still work.
所有重要的事情都运行在我拥有的硬件上。包括运行 Tasmota 的 ESP 开发板、MQTT 代理,以及运行在树莓派上的 Node-RED。我确实使用了一些云服务,主要是 Alexa 和一些 AWS 服务。Alexa 只是开关的一种方式。如果它挂了,墙上的开关和仪表盘依然能正常工作。
From the first talk, restated in the second:
来自第一次演讲,并在第二次演讲中重申:
Added after year five, once more people lived in the house:
在第五年后,当家里住的人变多时增加的准则:
The build I get asked about most is the Tasmota sprinkler controller. It’s in both talks, and so is the garage door setup, which has been running about as long.
我被问到最多的构建项目是 Tasmota 喷淋控制器。它出现在两次演讲中,车库门设置也是如此,它已经运行了同样长的时间。
Nobody needs any of this. I like building things that just work in the background, and each automation is a small puzzle.
其实没人真的需要这些。我只是喜欢构建那些能在后台默默运行的东西,每一个自动化过程都是一个小谜题。
Everything talks to a cloud now: phones, laptops, thermostats, locks. Those clouds may or may not be up when you need them, so know what you’re signing up for before you plug something in.
现在所有东西都连接云端:手机、笔记本电脑、恒温器、锁。当你需要它们时,这些云服务可能在线,也可能离线,所以在插上电源之前,先搞清楚你到底在依赖什么。
Most people start here: a thermostat, a plug, a lock. Each has its own app and account.
大多数人从这里开始:一个恒温器、一个插头、一把锁。每一个都有自己的应用程序和账户。
Every device lands somewhere on this triangle. A cloud camera is cheap and easy, and it costs you privacy. A switch I flash myself takes longer to set up, but I can hook it into anything. I figure out where a device lands before I buy it.
每个设备都在这个三角形的某个位置。云摄像头便宜且易用,但代价是隐私。我自己刷固件的开关设置起来更费时,但我可以把它连接到任何东西上。我在购买设备前会先确定它处于什么位置。
Someone (often me) automates a light, then has to tape the wall switch on so the smart bulb keeps power. If a switch in a room ever did nothing, this is why.
有人(通常是我)自动化了一盏灯,然后不得不把墙上的开关用胶带粘住,以保持智能灯泡通电。如果房间里的某个开关失效了,原因就在这里。
The better fix is an in-wall Wi-Fi switch. The switch still works like a normal switch and I can still automate it. It’s more work to install than a smart plug, but nobody has to change their habits.
更好的解决方法是入墙式 Wi-Fi 开关。这种开关既能像普通开关一样工作,我又能对其进行自动化控制。虽然安装比智能插头麻烦,但没人需要改变他们的使用习惯。
Rule one: if the internet goes down, my lights still turn on.
第一准则:如果互联网中断,我的灯依然能亮。
It’s never done. Rooms get used differently, people move in and out, new devices show up. Whatever you build has to be cheap to change.
这永远没有终点。房间的用途会变,人会搬进搬出,新设备会出现。无论你构建什么,都必须保证修改成本低廉。
The garage cooling flow starts from a manual trigger and checks if the door is closed. Then it opens the door, waits, and turns on the fan. If cooling is already running, it just sends a notification. Small flow, but it has kept the garage from baking more than once.
车库冷却流程从手动触发开始,检查门是否关闭。然后打开门,等待,并开启风扇。如果冷却系统已经在运行,它只会发送通知。流程虽小,但已经不止一次防止车库过热了。
The door sensor and reed switch both report into a transform step that sets a global garage-closed flag and logs to Grafana. Below that is the chart from a few real days: 21 opens, with spikes showing when each one happened. It’s easy to skip reporting/alerting. This can alert me if the garage was left open, which is useful when I accidentally leave it open.
门传感器和磁簧开关都向一个转换步骤报告,该步骤设置全局车库关闭标志并记录到 Grafana。下方是几天内的真实图表:21 次开启,峰值显示了每次发生的时间。跳过报告/警报很容易。如果车库没关,这可以提醒我,这在我无意中忘记关门时非常有用。
Four scheduled triggers all hit the same pump. It’s easy to end up with automations fighting over one device, so every so often I check whether they still make sense together.
四个定时触发器都指向同一个水泵。自动化程序很容易因为争夺同一个设备而冲突,所以我经常检查它们在一起是否仍然合理。
I’ve broken all of these plenty of times, so they’re more like guidelines.
我曾多次破坏过这些规则,所以它们更像是指导方针。
Three ways to do “event in, action out.” Node-RED is my main tool. Alexa routines and IFTTT-style applets cover the stuff I don’t want to build myself.
实现“事件输入,动作输出”的三种方式。Node-RED 是我的主要工具。Alexa 例程和 IFTTT 风格的小程序涵盖了我不想自己构建的部分。
MQTT keeps things decoupled. The temperature sensor publishes and doesn’t care who’s listening, so a phone and a backend can both subscribe without the sensor doing anything extra. The sprinkler controller in the Tasmota post works the same way.
MQTT 保持了系统的解耦。温度传感器发布数据,不在乎谁在监听,因此手机和后端都可以订阅,而传感器无需做任何额外工作。Tasmota 文章中的喷淋控制器也是以同样的方式工作的。
A Sonoff Mini fits inside the fireplace wiring, and the dashboard or Alexa can flip it. A fake fire you can turn on by voice is a good party trick.
一个 Sonoff Mini 可以安装在壁炉线路内,仪表盘或 Alexa 可以控制它。通过语音开启假火是一个不错的聚会小把戏。
The whole sprinkler build: the relay and ESP module in the enclosure, the 3D board render, the Tasmota UI with BME280 sensor readings, the Node-RED schedule feeding the pump, and the finished PCB layout. The sprinkler post has the full writeup, including why I picked Tasmota over custom firmware. It’s a bit hacky but I love it :D
整个喷淋系统的构建:外壳中的继电器和 ESP 模块、3D 电路板渲染图、带有 BME280 传感器读数的 Tasmota 界面、为水泵供电的 Node-RED 时间表,以及最终的 PCB 布局。喷淋系统的文章有完整的记录,包括我为什么选择 Tasmota 而不是自定义固件。虽然有点折腾,但我很喜欢 :D
The whole talk in five lines. The one I break most is the first, don’t introduce a new way while removing the old one, and I regret it every time. The last one stops me from breaking the others for no good reason. “I was in a hurry” doesn’t count.
用五行话总结整个演讲。我最常违反的是第一条:不要在移除旧方法的同时引入新方法,每次我都会为此后悔。最后一条准则阻止我无缘无故地破坏其他准则。“我当时很赶时间”不是理由。
That was talk one. Most of the “memorable automations” later broke in some new way or got replaced, so there’s a sequel.
那是第一次演讲。大多数“令人难忘的自动化”后来都以某种新的方式损坏或被替换了,所以有了续集。
Enough time passed between the talks that I had a new list of problems.
两次演讲之间经过了足够长的时间,我又有了一份新的问题清单。
More devices means more decisions made without me. It’s a little unsettling but mostly harmless.
更多的设备意味着更多的决定是在没有我参与的情况下做出的。这有点令人不安,但大多无害。
Same slide as before, with more icons.
和之前一样的幻灯片,只是图标更多了。
Everyone else is dealing with this too: a fridge showing a TLS certificate error, a grill controller that needs Wi-Fi to show the temperature, and a note taped to a pole about an internet-connected printer someone forgot to log out of.
其他人也在处理这些问题:显示 TLS 证书错误的冰箱、需要 Wi-Fi 才能显示温度的烤架控制器,以及贴在柱子上关于某人忘记退出的联网打印机的便条。
The same rules from talk one, worded a bit tighter, since part of the audience hadn’t seen the first talk.
来自第一次演讲的相同准则,措辞更严谨了一些,因为部分听众没有看过第一次演讲。
The rules stayed the same, but what they had to survive got harder.
准则保持不变,但它们需要应对的挑战变得更严峻了。
My setup assumed one person lived in the house. When that changed, I had to patch a single-user system into a multi-user one. The next few slides are how that went.
我的设置最初假设只有一个人住。当情况改变时,我不得不将单用户系统修补成多用户系统。接下来的几张幻灯片展示了这一过程。
More people meant more foot traffic and more keys, and longer trips away meant things could fail with nobody around to notice. A water flooding scare finally got me to take leak and presence detection seriously.
更多的人意味着更多的走动和更多的钥匙,更长时间的外出意味着系统可能在无人察觉的情况下发生故障。一次漏水惊魂终于让我开始认真对待泄漏和存在检测。
Same joke, new rules. The first set came after year one, these after year five.
同样的笑话,新的准则。第一套准则是在第一年后制定的,这些是在第五年后制定的。
These are rules 6 to 11 at the top of the post, written after the house went from one person to several.
这些是文章开头的第 6 到 11 条准则,是在家里从一个人变成几个人后写的。
Now the builds, my favorite part.
现在是构建部分,我最喜欢的部分。
A motor and PVC pipe rig for outdoor lighting, a UV grow light clipped to a houseplant, and a UV strip under the cabinets for sanitizing.
用于户外照明的电机和 PVC 管装置、夹在室内植物上的紫外线生长灯,以及橱柜下用于消毒的紫外线灯带。
Same sprinkler slide as talk one. It’s one o
与第一次演讲相同的喷淋系统幻灯片。这是其中一个……