Linux内核开发者玩转Home Assistant:案例研究
A Linux kernel developer plays with Home Assistant: case studies

原始链接: https://lwn.net/SubscriberLink/1017945/93d12d28178b372e/

本文重点介绍Home Assistant如何解决与太阳能面板数据、热泵和电力监控相关的现实问题,强调了数据所有权和控制的重要性。当作者的太阳能面板监控数据被一家破产公司“劫持”时,Home Assistant提供了一个本地解决方案,提供了比原始应用程序更好的数据可视化和访问功能。 Home Assistant在热泵方面也证明了其效用,它取代了供应商存在问题的“Kumo Cloud”应用程序。它允许本地控制,显示整个房屋的温度数据并控制气候设置。该集成促进了电力监控,揭示了能耗模式并识别了一个热泵中的“短周期运行”等问题。 作者强调了物联网设备将数据导出到外部服务器的令人担忧的趋势,这引发了隐私问题。Home Assistant提供了一个解决方案:一个免费的、本地控制的系统。尽管需要一些技术努力,但Home Assistant提供了一个强大而通用的家庭自动化和数据管理工具,赋能用户,并展现了更加以用户为中心的科技发展蓝图。

Hacker News 的讨论总结如下:一位 Linux 内核开发者体验了 Home Assistant,引来了 Home Assistant 创始人 Paulus 的回应。Paulus 对看到用户如何利用该平台表示赞赏,并强调了开放家庭基金会(Open Home Foundation)的成立,这是一个由用户资助的瑞士非营利组织,Home Assistant 已捐赠给了该基金会。此举突出了对智能家居技术中本地控制和隐私的承诺,承认现有不足,但重申了对开放和持续改进的决心。 另一位评论者 readthenotes1 将数据所有权比作一种可能不道德的商业模式:将长期健身会员资格卖给第三方,然后健身房倒闭,会员仍然受合同约束。

原文

Welcome to LWN.net

The following subscription-only content has been made available to you by an LWN subscriber. Thousands of subscribers depend on LWN for the best news from the Linux and free software communities. If you enjoy this article, please consider subscribing to LWN. Thank you for visiting LWN.net!

By Jonathan Corbet
May 16, 2025

The first article in this series provided an overview of Home Assistant, its community, and its capabilities. It was deliberately short on descriptions of interesting things that can be done with Home Assistant, though — the reasons why one might actually want to use this program. In this closing article, we'll look at how Home Assistant was used to solve some real problems.

Solar panels

Electrification is good, but it is even better in the presence of abundant electricity; thus, some years ago, an investment was made to cover my roof with solar panels. The result was indeed abundant power, about double what the home and the (non-Musky) electric vehicle actually used, which was a good thing. But the situation could have been better.

The panels came with a monitoring system from a company called SunPower; it collects data on panel performance and grid usage, reporting it all to some system in the cloud somewhere. The company produced a reasonably competent app that provided information about current and past performance, including data on each individual panel. Naturally, the app was the only point of access to that data, a fact which made me a bit nervous. Depending on a "free" cloud service from some vendor often does not go well.

Sure enough, in 2024, SunPower went bankrupt. The company that acquired SunPower's assets (among which are counted me and my data) goes by the name SunStrong. This company recently informed me that free access to my data was coming to an end; without a payment, the app would only provide basic instantaneous data. In other words, the data generated by the solar panels, which I own, is collected by the monitoring system, which I own, and sent off to a cloud system, which I definitely do not own and which will hold my own data hostage.

That, of course, is just the sort of situation I got into free software to prevent. Fortunately, my early nervousness had led me to look for ways to collect and hold that data locally; it is what drove me to install Home Assistant. As it happens, the monitoring system does not readily give up its information to the confused people who think they own it, but somebody out there on the net figured out a way using a network port intended for installation-time diagnostics, and documented it thoroughly. I was able to solve the problem in a slightly simpler way (the machine running Home Assistant has two network ports, so I was able to do without the intermediate Raspberry Pi system), and have had full access to the data from the solar system ever since.

[Panel production plot] After some of the inevitable fiddling (see the first article for some details), the result is a far better interface to solar-related information than the app ever provided. As one example, see the image to the right, plotting the output from a sub-cluster of panels, clearly showing the effects of the partial shading of two panels, even at the beginning of April. It has become easy to see how well each part of the system is performing and, should a panel or its inverter go bad someday, which panel is the problem will be immediately apparent.

This kind of data should not be held hostage by some corporation that feels empowered to alter the deal whenever it sees fit. Freedom from that situation is, in my mind, one of the most compelling reasons to use a tool like Home Assistant.

Helpers

That said, as mentioned before, Home Assistant requires some fiddling to get to a useful point. As an example, consider that the monitoring system reports the instantaneous power from both the panels and the grid. It does not report the power consumed by the house, which is often of interest. Of course, that quantity is easily enough obtained: it is simply the sum of the solar and grid power flows. At least, it is easy once one figures out the abstraction known as "helpers".

If one goes into the "Settings" screen of the Home-Assistant interface, then into "Devices & services", one will see a tab marked "Helpers". A helper, as it turns out, is a way to instantiate a virtual sensor that is defined as a function of one or more existing sensors. This screen, among many other things, enables the creation of a "home power usage" helper that is the sum of the solar and grid power sensors. Once it exists, it can be used to generate plots, as input to other helpers, or as part of an automation.

Now imagine that it might be nice to know how much power the house has consumed in any given day. The "integral" helper comes in handy here; the house power helper we just found can be fed into this new helper, which will integrate its value over time, turning kilowatts into kilowatt-hours. That will yield a constantly increasing value that is nice if you want to know the house's all-time usage, but it is less useful to tell how the day is going. Happily, there is yet another type of helper called a "utility meter" that can be configured to reset to zero at a given interval — every night at midnight being a logical choice. The output of that helper will be the day's usage.

The end result of all this is that helpers can do a lot of interesting things with the data collected by Home Assistant, but that their use does require a lot of clicking around in the interface (or YAML writing for those with that inclination). That work can add up; if there is a way to generate, say, daily production totals for each of 22 panels without manually creating a helper chain for each, I have not found it.

Another way to put this is that Home Assistant could really use a more general sort of query language for the data it manages. But, as a system that is set up once then used for years, what is there works pretty well.

One other note regarding data is worth mentioning: Home Assistant will collect high-resolution data from sources that provide it, and that data is stored — but only for a while. Unless configured otherwise, data more than ten days old will be boiled down severely, seemingly to one sample per hour. Since many people run Home Assistant on small, resource-constrained systems, taking some pains to reduce the amount of storage space required is understandable. But this discarding of data may come as a surprise to users with large disks who were hoping to retain full-resolution data indefinitely.

Heat pumps

What does one do with a surplus of electricity? Donating it back to the electric utility company (or something close to that effect) has little appeal. It is better to find a good use for that power, so the next step was to install air-source heat pumps and stop heating the house with fossil fuels. It takes a bit of a leap of faith to do this in Colorado, where the temperature dropped to -15°F (-26°C) this winter, but that technology has come a long way; the house remained warm.

The pre-purchase research yielded a clear indication that heat pumps made by Mitsubishi can work in this sort of climate. Respect for that company's hardware is universally high. It was also clear, before the purchase, that respect for Mitsubishi's software, and its "Kumo Cloud" app, was rather lower. Kumo Cloud is, as its name would suggest, a cloud-based solution that requires an Internet connection to work. The app was just as bad as the reviews had suggested. In March, with much hype, Mitsubishi replaced it with a new app called "Comfort"; it has been completely rewritten and is far worse.

[Heat-pump control] Naturally, Home Assistant has a Mitsubishi integration. It requires access to the cloud account at initialization to obtain the IP addresses for the controllers in each of the heat-pump heads; thereafter, it can interoperate with the controllers locally. This integration collects the data provided by the hardware (operating mode, temperature, set point, humidity), and can make it available in the usual sorts of ways. The app (in either version) is unable to plot the temperature of the room throughout the day, for example, but Home Assistant can do that.

It can also, of course, control the hardware through a simple thermostat-like widget that can be placed on a dashboard. It is easy to see the climate-control configuration of the entire house on a single screen. If remote access has been set up, it is also possible to change that configuration while away, perhaps turning the heat up while on the way home.

While I have not done this, it is possible to do a lot more by setting up automations. One can set up a schedule to vary the set temperature over the course of the day. A more complex setup might use motion or Bluetooth sensors to determine which rooms are occupied and adjust the climate-control settings accordingly. But even as a way to just control what the heat pumps are set to at any given time, Home Assistant has replaced the use of the vendor app. At some point, I may cut the controllers off from the Internet entirely.

Power monitoring

The heat pumps have done a fine job of keeping the house warm in the winter, but they also had the effect of causing that surplus of electricity to disappear. That naturally led to a higher degree of interest in how power is consumed in the house; the simple data provided by the SunPower unit was not sufficient. Wouldn't it be nice to know what specific rooms or appliances are consuming? It turns out that there are a number of companies selling power monitors that can report usage on a number of circuits in the house; it was just a matter of picking one.

That question turned out to be easy to answer in the end. There is one unit, made by Refoss, that is affordable and able to monitor sixteen independent circuits in the house. (Note: that product page may not be available in all regions. The main site is available here.) Readers will undoubtedly be surprised to learn that this device is designed to report data to a cloud server, which will then make it available via an app. There is a crucial difference here, though: the Home-Assistant integration for Refoss devices, which interfaces directly with the monitor and needs no cloud connectivity, is written and provided by Refoss itself. Home-Assistant compatibility is the first bullet item on the above-linked product page.

There are not many companies that see fit to support Home-Assistant integration for their products; there are probably more that are actively hostile to it. So when a company supports this integration, it moves directly to the top of my list of candidates; that is what happened here. After a few hours of nervous work inside the main service panel for the house and more time spent tweaking the names of all the sensors, the monitor was up and reporting into Home Assistant as designed.

[Heat-pump power usage] The data returned by the monitor turned out to be immediately useful. The plot to the right shows the power consumption of the two installed exterior heat-pump units, one for the downstairs, one for the up. The blue trace (downstairs) shows how these systems are meant to operate; they should cycle rarely, and run steadily for some time once they start. The yellow trace (upstairs), instead, demonstrates a problem called "short cycling"; it results in increased power usage and increased wear on the unit. Short cycling can be caused by a number of problems, including configuration mistakes or hardware problems.

In this case, the cause would appear to be hardware, but it has taken some time to reach that diagnosis. It was, however, easy to demonstrate the problem to the repair technicians by showing them a plot like this one. Without detailed power-usage information, the conversation with the technicians would likely have been a far longer one. There is value in having visibility into the operation of crucial systems — like one's house.

Having power information has helped in other ways. Seeing how much current is drawn by my monitors in their "power save" mode has led to them being turned off at night. It has become easier to say what is using power during the high-cost times of day and shift that use to other times. It is amusing to learn that a full kernel build costs about 20Wh. In general, visibility into how the house is working is both interesting and useful.

To close

It is also sobering to realize how much that information can reveal about what is going on in the house — how many people are present, which rooms they are in, what they are doing in those rooms, etc. The thought that nobody is out there trying to gain access to (and exploit) that data seems naive at best. Yet we happily allow that data to be exported and stored on somebody else's server with no real idea of how long we'll have access to it, how well that server is protected, or even where it is. That is the world we have built for ourselves, but it is not the one many of us envisioned.

Tools like Home Assistant offer a different vision of how the world could be — how we should have built it in the first place. Free software is not just for operating systems; it is for all of the systems that touch our lives. It is software that actually serves us, rather than the people who sold it to us.

Home Assistant is a wildly successful project, with vast numbers of users, but most people still have never heard of it. Many others, undoubtedly, have been scared away by the fiddly nature of the system and the challenges of integrating devices that were never designed to work together. Continued success will require a lot more effort to make things Just Work. There is almost certainly a business to be had in this area, just waiting for somebody with the requisite energy and skills to make it real. Meanwhile, a versatile and useful tool is available for those who are willing to put the effort into it.

Here ends this look at Home Assistant. It is a partial look at best; as mentioned before, I have not yet had the time to play much with features like automations and scenes. There is voice control under development, and Music Assistant for media streaming. My house is also devoid of motion sensors, remote-control light bulbs, video doorbells, automatic blinds, Internet-connected cookware, app-driven pet feeders, "smart speakers", and other sorts of IoT stuff, all of which can be connected to Home Assistant if it is present. So I have been unable to test those integrations. In the end, every deployment will, like every home, be different — but all will be free and under the owner's control.



联系我们 contact @ memedata.com