<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Tenda BE12 Pro on 龙五的博客</title>
        <link>https://blog.pyle.cc/tags/tenda-be12-pro/</link>
        <description>Recent content in Tenda BE12 Pro on 龙五的博客</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>zh-cn</language>
        <lastBuildDate>Sun, 13 Sep 2026 13:23:33 +0800</lastBuildDate><atom:link href="https://blog.pyle.cc/tags/tenda-be12-pro/index.xml" rel="self" type="application/rss+xml" /><item>
            <title>X-WRT 概览页显示 CPU 温度与 WiFi 温度</title>
            <link>https://blog.pyle.cc/uncategorized/x-wrt-luci-cpu-wifi-temperature.html</link>
            <pubDate>Sun, 13 Sep 2026 13:23:33 +0800</pubDate>
            <guid>https://blog.pyle.cc/uncategorized/x-wrt-luci-cpu-wifi-temperature.html</guid>
            <description>&lt;h2&gt;背景&lt;/h2&gt;&#xA;&lt;p&gt;X-WRT 26.04（Tenda BE12 Pro，mediatek/filogic，内核 6.18.44）的 LuCI 概览页默认不显示温度。底层数据其实一直存在：&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;  &lt;li&gt;CPU 温度：&lt;code&gt;/sys/class/thermal/thermal_zone0/temp&lt;/code&gt;（毫摄氏度）&lt;/li&gt;&#xA;  &lt;li&gt;WiFi 温度：&lt;code&gt;/sys/class/ieee80211/phy0/hwmon*/temp1_input&lt;/code&gt;（毫摄氏度，2.4G / 5G 各一个）&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;目标：在概览页显示一行温度信息，不破坏原有页面结构，固件升级后重新放回文件即可恢复。&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;方案&lt;/h2&gt;&#xA;&lt;p&gt;利用 X-WRT 新版 LuCI 概览页的&lt;strong&gt;模块化加载机制&lt;/strong&gt;：&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;  &lt;li&gt;主 &lt;code&gt;index.ut&lt;/code&gt;（ucode 模板）渲染时会加载 &lt;code&gt;admin_status/luaindex&lt;/code&gt; 子视图&lt;/li&gt;&#xA;  &lt;li&gt;&lt;code&gt;luaindex.htm&lt;/code&gt;（Lua 视图）会扫描 &lt;code&gt;/usr/lib/lua/luci/view/admin_status/index/&lt;/code&gt; 目录，把所有 &lt;code&gt;.htm&lt;/code&gt; 片段 &lt;code&gt;include&lt;/code&gt; 进来&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;我们在这个目录里新建一个片段 &lt;code&gt;99-temperature.htm&lt;/code&gt;，它负责：&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;  &lt;li&gt;读 CPU 和 WiFi 温度&lt;/li&gt;&#xA;  &lt;li&gt;把值写进 &lt;code&gt;window.__cpuTemp&lt;/code&gt; / &lt;code&gt;window.__wifiTemp&lt;/code&gt;&lt;/li&gt;&#xA;  &lt;li&gt;在 &lt;code&gt;#view&lt;/code&gt; 容器&lt;strong&gt;外面&lt;/strong&gt;创建一个横条，显示这两个温度&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;关键设计：&lt;strong&gt;横条插在 &lt;code&gt;#view&lt;/code&gt; 外面&lt;/strong&gt;，因为 LuCI 概览页每 5 秒轮询重绘 &lt;code&gt;#view&lt;/code&gt; 内容，插在里面会被冲掉。&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;完整文件&lt;/h2&gt;&#xA;&lt;p&gt;&lt;code&gt;/usr/lib/lua/luci/view/admin_status/index/99-temperature.htm&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre style=&#34;background:#f6f8fa;border:1px solid #d0d7de;border-radius:6px;padding:12px;overflow:auto;font-size:13px;line-height:1.5;&#34;&gt;&lt;code&gt;&amp;lt;%&#xA;-- CPU 温度&#xA;local f = io.open(&amp;quot;/sys/class/thermal/thermal_zone0/temp&amp;quot;, &amp;quot;r&amp;quot;)&#xA;local craw = f and f:read(&amp;quot;*l&amp;quot;) or nil&#xA;if f then f:close() end&#xA;local ctemp = craw and string.format(&amp;quot;%.1f&amp;quot;, tonumber(craw) / 1000) or &amp;quot;N/A&amp;quot;&#xA;&#xA;-- WiFi 温度：扫所有 /sys/class/ieee80211/phy*/hwmon*/temp1_input&#xA;local wlist = {}&#xA;local p = io.popen(&amp;quot;ls -d /sys/class/ieee80211/phy*/hwmon*/temp1_input 2&amp;gt;/dev/null&amp;quot;)&#xA;if p then&#xA;    for path in p:lines() do&#xA;        local wf = io.open(path, &amp;quot;r&amp;quot;)&#xA;        local wraw = wf and wf:read(&amp;quot;*l&amp;quot;) or nil&#xA;        if wf then wf:close() end&#xA;        if wraw and tonumber(wraw) then&#xA;            wlist[#wlist + 1] = string.format(&amp;quot;%.1f&amp;quot;, tonumber(wraw) / 1000)&#xA;        end&#xA;    end&#xA;    p:close()&#xA;end&#xA;local wtemp = #wlist &amp;gt; 0 and table.concat(wlist, &amp;quot; / &amp;quot;) or &amp;quot;N/A&amp;quot;&#xA;%&amp;gt;&#xA;&amp;lt;script&amp;gt;&#xA;window.__cpuTemp = &#39;&amp;lt;%=ctemp%&amp;gt; °C&#39;;&#xA;window.__wifiTemp = &#39;&amp;lt;%=wtemp%&amp;gt; °C&#39;;&#xA;&#xA;(function() {&#xA;    if (!document.body || document.body.getAttribute(&#39;data-page&#39;) !== &#39;admin-status-overview&#39;)&#xA;        return;&#xA;&#xA;    function build() {&#xA;        var bar = document.getElementById(&#39;cpu-temp-bar&#39;);&#xA;        if (!bar) {&#xA;            var view = document.getElementById(&#39;view&#39;);&#xA;            if (!view || !view.parentNode) return;&#xA;            bar = document.createElement(&#39;div&#39;);&#xA;            bar.id = &#39;cpu-temp-bar&#39;;&#xA;            bar.style.cssText = &#39;margin:8px 0;padding:8px 12px;background:#fff3e0;border:1px solid #ffcc80;border-radius:6px;font-size:14px;&#39;;&#xA;            view.parentNode.insertBefore(bar, view);&#xA;        }&#xA;        bar.textContent = &#39;CPU 温度: &#39; + window.__cpuTemp + &#39;    WiFi 温度: &#39; + window.__wifiTemp;&#xA;    }&#xA;&#xA;    setInterval(build, 500);&#xA;    build();&#xA;})();&#xA;&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;hr /&gt;&#xA;&lt;h2&gt;部署步骤&lt;/h2&gt;&#xA;&lt;pre style=&#34;background:#f6f8fa;border:1px solid #d0d7de;border-radius:6px;padding:12px;overflow:auto;font-size:13px;line-height:1.5;&#34;&gt;&lt;code&gt;# 1. 写入片段文件&#xA;cat &amp;gt; /usr/lib/lua/luci/view/admin_status/index/99-temperature.htm &amp;lt;&amp;lt;&#39;EOF&#39;&#xA;（上面完整内容）&#xA;EOF&#xA;&#xA;# 2. 清 LuCI 模板缓存&#xA;rm -rf /tmp/luci-*&#xA;&#xA;# 3. 重启 web 服务&#xA;/etc/init.d/uwsgi restart 2&amp;gt;/dev/null&#xA;/etc/init.d/uhttpd restart 2&amp;gt;/dev/null&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;浏览器 &lt;strong&gt;Ctrl+F5&lt;/strong&gt; 强刷。&lt;/p&gt;</description>
        </item></channel>
</rss>
