一、安装前端更精美的方式(Mushroom 卡)
✨ 优点:体积小、风格统一,特别适合放在顶部导航栏。
- HACS搜索Mushroom
- 安装Lovelace Mushroom Better Sliders,Mushroom Cards 改进版,原版 Mushroom Cards 的改进版,改进了触控滑块体验。
- 切换Mushroom主题:⚙️ 设置 → 个人资料 → 主题 → 选择不同 Mushroom 主题,再刷新仪表盘(Ctrl+F5)。
主题选项说明:Mushroom Shadow(阴影强化版)、Mushroom Square(方形版)、Mushroom Square Shadow(方形 + 阴影)
二、后端脚本(放在 scripts.yaml)
Ping 的 RTT 传感器
refresh_ping_now_and_notify:
alias: 刷新 Ping(同时更新延迟与在线)并通知(覆盖旧提示)
mode: restart
sequence:
# === 同时刷新 RTT(latency)与在线状态 ===
- service: homeassistant.update_entity
data:
entity_id:
# --- A 组:官方 Ping 集成的平均时延实体(请替换为你的真实 ID;没有就注释掉) ---
- sensor.10_10_10_167_average_latency
- sensor.10_10_10_39_average_latency
- sensor.10_10_10_26_average_latency
# --- B 组:若你用自建的 ping sensor(没有就注释掉整组) ---
# - sensor.rtt_qun_hui_218
# - sensor.rtt_qun_hui_6400
# - sensor.rtt_homepc
# --- 在线状态 binary_sensor(保留) ---
- binary_sensor.10_10_10_167
- binary_sensor.10_10_10_39
- binary_sensor.10_10_10_26
# === 刷新成功通知(同 ID 覆盖旧通知,不会堆积)===
- service: persistent_notification.create
data:
title: "🔄 已刷新"
message: >-
手动刷新已执行({{ now().strftime('%H:%M:%S') }})
notification_id: ha_refresh_notice
三、前端整页 YAML(按钮调用上面的脚本;保留原布局)
type: vertical-stack
cards:
# ===== 标题 =====
- type: custom:mushroom-title-card
title: 💻 家庭服务器控制中心
subtitle: 群晖 NAS 与 HomePC · 状态与操作
alignment: center
# ===== 在线状态监控 =====
- type: custom:mushroom-title-card
title: 🟢 在线状态监控
alignment: center
- type: horizontal-stack
cards:
- type: custom:mushroom-entity-card
entity: binary_sensor.10_10_10_167
name: 群晖218+
icon: mdi:nas
layout: vertical
state_color: true
secondary_info: last-changed
fill_container: true
- type: custom:mushroom-entity-card
entity: binary_sensor.10_10_10_39
name: 群晖6400
icon: mdi:server
layout: vertical
state_color: true
secondary_info: last-changed
fill_container: true
- type: custom:mushroom-entity-card
entity: binary_sensor.10_10_10_26
name: HomePC
icon: mdi:desktop-tower-monitor
layout: vertical
state_color: true
secondary_info: last-changed
fill_container: true
# ===== 一键手动刷新(调用脚本+通知覆盖+禁用更多信息弹窗) =====
- type: button
name: 一键手动刷新
icon: mdi:refresh
icon_height: 48px
tap_action:
action: call-service
service: script.refresh_ping_now_and_notify
hold_action:
action: none
double_tap_action:
action: none
# ===== 操作提示 =====
- type: markdown
content: |
## ⚠️ 操作提示
- 👆 **点击刷新按钮**:立即检测设备在线状态,并刷新时延
- 📡 Ping 集成每 **180 秒** 自动刷新一次
- ✉️ 刷新成功后右上角会弹出通知(新的会覆盖旧的)
- 👆 **长按唤醒**,👆👆 **双击关机**,请慎重操作
# ===== 唤醒设备 =====
- type: custom:mushroom-title-card
title: ⚙️ 唤醒设备
alignment: center
- type: horizontal-stack
cards:
- type: custom:mushroom-entity-card
entity: switch.huan_xing_qun_hui_6400
name: 群晖6400
icon: mdi:server
icon_color: green
layout: vertical
hold_action:
action: toggle
confirmation:
text: 你确定要唤醒群晖 6400 吗?
tap_action:
action: none
double_tap_action:
action: none
fill_container: true
- type: custom:mushroom-entity-card
entity: switch.huan_xing_qun_hui_218
name: 群晖218+
icon: mdi:server
icon_color: green
layout: vertical
hold_action:
action: toggle
confirmation:
text: 你确定要唤醒群晖 218+ 吗?
tap_action:
action: none
double_tap_action:
action: none
fill_container: true
- type: custom:mushroom-entity-card
entity: switch.huan_xing_homepc
name: HomePC
icon: mdi:desktop-classic
icon_color: green
layout: vertical
hold_action:
action: toggle
confirmation:
text: 你确定要唤醒 HomePC 吗?
tap_action:
action: none
double_tap_action:
action: none
fill_container: true
# ===== 关闭设备 =====
- type: custom:mushroom-title-card
title: 🔴 关闭设备
alignment: center
- type: horizontal-stack
cards:
- type: custom:mushroom-template-card
primary: 群晖6400
icon: mdi:power
icon_color: red
layout: vertical
double_tap_action:
action: call-service
service: shell_command.shutdown_nas_1
confirmation:
text: 你确定要关闭群晖 6400 吗?
tap_action:
action: none
hold_action:
action: none
fill_container: true
- type: custom:mushroom-template-card
primary: 群晖218+
icon: mdi:power
icon_color: red
layout: vertical
double_tap_action:
action: call-service
service: shell_command.shutdown_nas_2
confirmation:
text: 你确定要关闭群晖 218+ 吗?
tap_action:
action: none
hold_action:
action: none
fill_container: true
- type: custom:mushroom-template-card
primary: HomePC
icon: mdi:power
icon_color: red
layout: vertical
double_tap_action:
action: call-service
service: button.press
data:
entity_id: button.desktop_gurf08h_desktop_gurf08h_shutdown
confirmation:
text: 你确定要关闭 Windows 电脑吗?
tap_action:
action: none
hold_action:
action: none
fill_container: true
